summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/arch/qatomic_sparc.h16
-rw-r--r--src/corelib/codecs/codecs.qdoc14
-rw-r--r--src/corelib/codecs/qtextcodec.cpp6
-rw-r--r--src/corelib/corelib.pro3
-rw-r--r--src/corelib/doc/doc.pri3
-rw-r--r--src/corelib/doc/images/abstract-connections.pngbin0 -> 19849 bytes
-rw-r--r--src/corelib/doc/images/brush-styles.pngbin0 -> 13980 bytes
-rw-r--r--src/corelib/doc/images/cursor-arrow.pngbin0 -> 171 bytes
-rw-r--r--src/corelib/doc/images/cursor-busy.pngbin0 -> 201 bytes
-rw-r--r--src/corelib/doc/images/cursor-closedhand.pngbin0 -> 147 bytes
-rw-r--r--src/corelib/doc/images/cursor-cross.pngbin0 -> 130 bytes
-rw-r--r--src/corelib/doc/images/cursor-forbidden.pngbin0 -> 199 bytes
-rw-r--r--src/corelib/doc/images/cursor-hand.pngbin0 -> 159 bytes
-rw-r--r--src/corelib/doc/images/cursor-hsplit.pngbin0 -> 155 bytes
-rw-r--r--src/corelib/doc/images/cursor-ibeam.pngbin0 -> 124 bytes
-rw-r--r--src/corelib/doc/images/cursor-openhand.pngbin0 -> 160 bytes
-rw-r--r--src/corelib/doc/images/cursor-sizeall.pngbin0 -> 174 bytes
-rw-r--r--src/corelib/doc/images/cursor-sizeb.pngbin0 -> 161 bytes
-rw-r--r--src/corelib/doc/images/cursor-sizef.pngbin0 -> 161 bytes
-rw-r--r--src/corelib/doc/images/cursor-sizeh.pngbin0 -> 145 bytes
-rw-r--r--src/corelib/doc/images/cursor-sizev.pngbin0 -> 141 bytes
-rw-r--r--src/corelib/doc/images/cursor-uparrow.pngbin0 -> 132 bytes
-rw-r--r--src/corelib/doc/images/cursor-vsplit.pngbin0 -> 161 bytes
-rw-r--r--src/corelib/doc/images/cursor-wait.pngbin0 -> 172 bytes
-rw-r--r--src/corelib/doc/images/cursor-whatsthis.pngbin0 -> 191 bytes
-rw-r--r--src/corelib/doc/images/javaiterators1.pngbin0 -> 1062 bytes
-rw-r--r--src/corelib/doc/images/javaiterators2.pngbin0 -> 2011 bytes
-rw-r--r--src/corelib/doc/images/modelindex-no-parent.pngbin0 -> 7407 bytes
-rw-r--r--src/corelib/doc/images/modelview-begin-append-columns.pngbin0 -> 12798 bytes
-rw-r--r--src/corelib/doc/images/modelview-begin-append-rows.pngbin0 -> 8967 bytes
-rw-r--r--src/corelib/doc/images/modelview-begin-insert-columns.pngbin0 -> 14476 bytes
-rw-r--r--src/corelib/doc/images/modelview-begin-insert-rows.pngbin0 -> 12565 bytes
-rw-r--r--src/corelib/doc/images/modelview-begin-remove-columns.pngbin0 -> 14518 bytes
-rw-r--r--src/corelib/doc/images/modelview-begin-remove-rows.pngbin0 -> 10896 bytes
-rw-r--r--src/corelib/doc/images/modelview-move-rows-1.pngbin0 -> 19709 bytes
-rw-r--r--src/corelib/doc/images/modelview-move-rows-2.pngbin0 -> 19385 bytes
-rw-r--r--src/corelib/doc/images/modelview-move-rows-3.pngbin0 -> 9281 bytes
-rw-r--r--src/corelib/doc/images/modelview-move-rows-4.pngbin0 -> 9381 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inback.pngbin0 -> 2808 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inbounce.pngbin0 -> 3154 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-incirc.pngbin0 -> 2605 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-incubic.pngbin0 -> 2722 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inelastic.pngbin0 -> 3304 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inexpo.pngbin0 -> 2675 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutback.pngbin0 -> 3241 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutbounce.pngbin0 -> 3386 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutcirc.pngbin0 -> 2843 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutcubic.pngbin0 -> 2931 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutelastic.pngbin0 -> 3461 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutexpo.pngbin0 -> 3004 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutquad.pngbin0 -> 2893 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutquart.pngbin0 -> 2925 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutquint.pngbin0 -> 2823 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inoutsine.pngbin0 -> 2891 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inquad.pngbin0 -> 2733 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inquart.pngbin0 -> 2727 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-inquint.pngbin0 -> 2630 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-insine.pngbin0 -> 2567 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-linear.pngbin0 -> 2318 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outback.pngbin0 -> 2852 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outbounce.pngbin0 -> 3360 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outcirc.pngbin0 -> 2796 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outcubic.pngbin0 -> 2792 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outelastic.pngbin0 -> 3423 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outexpo.pngbin0 -> 2803 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outinback.pngbin0 -> 3026 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outinbounce.pngbin0 -> 3629 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outincirc.pngbin0 -> 2822 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outincubic.pngbin0 -> 2872 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outinelastic.pngbin0 -> 3941 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outinexpo.pngbin0 -> 2923 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outinquad.pngbin0 -> 2858 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outinquart.pngbin0 -> 2830 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outinquint.pngbin0 -> 2724 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outinsine.pngbin0 -> 2817 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outquad.pngbin0 -> 2760 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outquart.pngbin0 -> 2764 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outquint.pngbin0 -> 2687 bytes
-rw-r--r--src/corelib/doc/images/qeasingcurve-outsine.pngbin0 -> 2773 bytes
-rw-r--r--src/corelib/doc/images/qimage-scaling.pngbin0 -> 34785 bytes
-rw-r--r--src/corelib/doc/images/qline-coordinates.pngbin0 -> 9459 bytes
-rw-r--r--src/corelib/doc/images/qline-point.pngbin0 -> 8484 bytes
-rw-r--r--src/corelib/doc/images/qlinef-angle-identicaldirection.pngbin0 -> 6004 bytes
-rw-r--r--src/corelib/doc/images/qlinef-angle-oppositedirection.pngbin0 -> 5834 bytes
-rw-r--r--src/corelib/doc/images/qlinef-bounded.pngbin0 -> 4183 bytes
-rw-r--r--src/corelib/doc/images/qlinef-normalvector.pngbin0 -> 9432 bytes
-rw-r--r--src/corelib/doc/images/qlinef-unbounded.pngbin0 -> 3992 bytes
-rw-r--r--src/corelib/doc/images/qpen-bevel.pngbin0 -> 11527 bytes
-rw-r--r--src/corelib/doc/images/qpen-custom.pngbin0 -> 6254 bytes
-rw-r--r--src/corelib/doc/images/qpen-dash.pngbin0 -> 8221 bytes
-rw-r--r--src/corelib/doc/images/qpen-dashdot.pngbin0 -> 5961 bytes
-rw-r--r--src/corelib/doc/images/qpen-dashdotdot.pngbin0 -> 5999 bytes
-rw-r--r--src/corelib/doc/images/qpen-dot.pngbin0 -> 5386 bytes
-rw-r--r--src/corelib/doc/images/qpen-flat.pngbin0 -> 1885 bytes
-rw-r--r--src/corelib/doc/images/qpen-miter.pngbin0 -> 11734 bytes
-rw-r--r--src/corelib/doc/images/qpen-roundcap.pngbin0 -> 1920 bytes
-rw-r--r--src/corelib/doc/images/qpen-roundjoin.pngbin0 -> 11878 bytes
-rw-r--r--src/corelib/doc/images/qpen-solid.pngbin0 -> 7416 bytes
-rw-r--r--src/corelib/doc/images/qpen-square.pngbin0 -> 2651 bytes
-rw-r--r--src/corelib/doc/images/qrect-coordinates.pngbin0 -> 22218 bytes
-rw-r--r--src/corelib/doc/images/qrect-diagram-one.pngbin0 -> 9616 bytes
-rw-r--r--src/corelib/doc/images/qrect-diagram-three.pngbin0 -> 9458 bytes
-rw-r--r--src/corelib/doc/images/qrect-diagram-two.pngbin0 -> 9378 bytes
-rw-r--r--src/corelib/doc/images/qrect-diagram-zero.pngbin0 -> 5198 bytes
-rw-r--r--src/corelib/doc/images/qrect-intersect.pngbin0 -> 8742 bytes
-rw-r--r--src/corelib/doc/images/qrect-unite.pngbin0 -> 4626 bytes
-rw-r--r--src/corelib/doc/images/qrectf-coordinates.pngbin0 -> 21749 bytes
-rw-r--r--src/corelib/doc/images/qrectf-diagram-one.pngbin0 -> 9594 bytes
-rw-r--r--src/corelib/doc/images/qrectf-diagram-three.pngbin0 -> 9392 bytes
-rw-r--r--src/corelib/doc/images/qrectf-diagram-two.pngbin0 -> 9387 bytes
-rw-r--r--src/corelib/doc/images/qsortfilterproxymodel-sorting.pngbin0 -> 11005 bytes
-rw-r--r--src/corelib/doc/images/qurl-authority.pngbin0 -> 5099 bytes
-rw-r--r--src/corelib/doc/images/qurl-authority2.pngbin0 -> 2350 bytes
-rw-r--r--src/corelib/doc/images/qurl-authority3.pngbin0 -> 3552 bytes
-rw-r--r--src/corelib/doc/images/qurl-fragment.pngbin0 -> 2333 bytes
-rw-r--r--src/corelib/doc/images/qurl-ftppath.pngbin0 -> 1974 bytes
-rw-r--r--src/corelib/doc/images/qurl-mailtopath.pngbin0 -> 1679 bytes
-rw-r--r--src/corelib/doc/images/qurl-querystring.pngbin0 -> 2955 bytes
-rw-r--r--src/corelib/doc/images/stliterators1.pngbin0 -> 1671 bytes
-rw-r--r--src/corelib/doc/images/thread_clock.pngbin0 -> 5964 bytes
-rw-r--r--src/corelib/doc/images/threadsandobjects.pngbin0 -> 66096 bytes
-rw-r--r--src/corelib/doc/images/threadvisual-example.pngbin0 -> 16823 bytes
-rw-r--r--src/corelib/doc/qtcore.qdocconf90
-rw-r--r--src/corelib/doc/snippets/buffer/buffer.cpp124
-rw-r--r--src/corelib/doc/snippets/code/doc_src_containers.cpp275
-rw-r--r--src/corelib/doc/snippets/code/doc_src_groups.cpp66
-rw-r--r--src/corelib/doc/snippets/code/doc_src_objecttrees.cpp60
-rw-r--r--src/corelib/doc/snippets/code/doc_src_properties.cpp132
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp354
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qcache.cpp57
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qiterator.cpp420
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qnamespace.cpp59
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qnamespace.qdoc43
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qpair.cpp55
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qplugin.cpp64
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qplugin.pro4
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qset.cpp166
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qtcore.cpp43
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qvarlengtharray.cpp78
-rw-r--r--src/corelib/doc/snippets/code/qlogging/qlogging.cpp54
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_codecs_qtextcodec.cpp75
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_concurrent_qthreadpool.cpp53
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp586
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qabstractfileengine.cpp120
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qdatastream.cpp121
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qdir.cpp175
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qdiriterator.cpp52
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qfile.cpp75
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qfileinfo.cpp146
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qiodevice.cpp99
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qprocess.cpp134
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qsettings.cpp316
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qtemporarydir.cpp53
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qtemporaryfile.cpp53
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp129
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp87
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp43
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp99
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp126
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp140
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp114
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qmimedata.cpp108
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp501
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp61
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qtimer.cpp52
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp136
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp47
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_plugin_qlibrary.cpp84
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp44
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp55
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qatomic.cpp98
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qmutex.cpp193
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qmutexpool.cpp61
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qreadwritelock.cpp109
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qsemaphore.cpp73
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp56
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp89
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qbitarray.cpp176
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp421
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp146
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qeasingcurve.cpp44
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp299
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp204
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp267
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlocale.cpp95
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp313
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp149
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qqueue.cpp48
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qrect.cpp50
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qregexp.cpp224
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp289
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qscopedpointer.cpp138
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qsize.cpp136
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qstring.cpp94
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp55
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp183
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_xml_qxmlstream.cpp67
-rw-r--r--src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp148
-rw-r--r--src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp64
-rw-r--r--src/corelib/doc/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp50
-rw-r--r--src/corelib/doc/snippets/file/file.cpp123
-rw-r--r--src/corelib/doc/snippets/fileinfo/main.cpp92
-rw-r--r--src/corelib/doc/snippets/ntfsp.cpp50
-rw-r--r--src/corelib/doc/snippets/pointer/pointer.cpp60
-rw-r--r--src/corelib/doc/snippets/process/process.cpp76
-rw-r--r--src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp73
-rw-r--r--src/corelib/doc/snippets/qdir-listfiles/main.cpp62
-rw-r--r--src/corelib/doc/snippets/qdir-namefilters/main.cpp65
-rw-r--r--src/corelib/doc/snippets/qelapsedtimer/main.cpp111
-rw-r--r--src/corelib/doc/snippets/qmetaobject-invokable/main.cpp52
-rw-r--r--src/corelib/doc/snippets/qmetaobject-invokable/qmetaobject-invokable.pro3
-rw-r--r--src/corelib/doc/snippets/qmetaobject-invokable/window.cpp57
-rw-r--r--src/corelib/doc/snippets/qmetaobject-invokable/window.h58
-rw-r--r--src/corelib/doc/snippets/qprocess-environment/main.cpp73
-rw-r--r--src/corelib/doc/snippets/qprocess/qprocess-simpleexecution.cpp66
-rw-r--r--src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp66
-rw-r--r--src/corelib/doc/snippets/qsignalmapper/buttonwidget.h67
-rw-r--r--src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp99
-rw-r--r--src/corelib/doc/snippets/qstack/main.cpp55
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp997
-rw-r--r--src/corelib/doc/snippets/qstring/stringbuilder.cpp62
-rw-r--r--src/corelib/doc/snippets/qstringlist/main.cpp170
-rw-r--r--src/corelib/doc/snippets/qstringlistmodel/main.cpp66
-rw-r--r--src/corelib/doc/snippets/qtcast/qtcast.cpp79
-rw-r--r--src/corelib/doc/snippets/qxmlstreamwriter/main.cpp76
-rw-r--r--src/corelib/doc/snippets/settings/settings.cpp184
-rw-r--r--src/corelib/doc/snippets/sharedemployee/employee.h94
-rw-r--r--src/corelib/doc/snippets/sharedemployee/main.cpp50
-rw-r--r--src/corelib/doc/snippets/signalmapper/filereader.cpp107
-rw-r--r--src/corelib/doc/snippets/signalsandslots/lcdnumber.h88
-rw-r--r--src/corelib/doc/snippets/signalsandslots/signalsandslots.cpp84
-rw-r--r--src/corelib/doc/snippets/signalsandslots/signalsandslots.h89
-rw-r--r--src/corelib/doc/snippets/streaming/main.cpp108
-rw-r--r--src/corelib/doc/snippets/streaming/streaming.pro2
-rw-r--r--src/corelib/doc/snippets/threads/threads.cpp117
-rw-r--r--src/corelib/doc/snippets/threads/threads.h51
-rw-r--r--src/corelib/doc/snippets/timers/timers.cpp78
-rw-r--r--src/corelib/doc/src/containers.qdoc803
-rw-r--r--src/corelib/doc/src/datastreamformat.qdoc373
-rw-r--r--src/corelib/doc/src/implicit-sharing.qdoc138
-rw-r--r--src/corelib/doc/src/json.qdoc118
-rw-r--r--src/corelib/doc/src/objectmodel/metaobjects.qdoc137
-rw-r--r--src/corelib/doc/src/objectmodel/object.qdoc124
-rw-r--r--src/corelib/doc/src/objectmodel/objecttrees.qdoc102
-rw-r--r--src/corelib/doc/src/objectmodel/properties.qdoc273
-rw-r--r--src/corelib/doc/src/objectmodel/signalsandslots.qdoc468
-rw-r--r--src/corelib/doc/src/qtcore.qdoc42
-rw-r--r--src/corelib/doc/src/threads-basics.qdoc572
-rw-r--r--src/corelib/doc/src/threads.qdoc705
-rw-r--r--src/corelib/global/qcompilerdetection.h157
-rw-r--r--src/corelib/global/qconfig-medium.h3
-rw-r--r--src/corelib/global/qconfig-minimal.h3
-rw-r--r--src/corelib/global/qconfig-nacl.h3
-rw-r--r--src/corelib/global/qconfig-small.h3
-rw-r--r--src/corelib/global/qfeatures.h3
-rw-r--r--src/corelib/global/qglobal.cpp244
-rw-r--r--src/corelib/global/qglobal.h222
-rw-r--r--src/corelib/global/qlogging.cpp114
-rw-r--r--src/corelib/global/qlogging.h4
-rw-r--r--src/corelib/global/qnamespace.h10
-rw-r--r--src/corelib/global/qnamespace.qdoc18
-rw-r--r--src/corelib/global/qprocessordetection.h4
-rw-r--r--src/corelib/global/qsystemdetection.h4
-rw-r--r--src/corelib/io/io.pri2
-rw-r--r--src/corelib/io/qabstractfileengine.cpp20
-rw-r--r--src/corelib/io/qbuffer.cpp29
-rw-r--r--src/corelib/io/qbuffer.h4
-rw-r--r--src/corelib/io/qdatastream.cpp31
-rw-r--r--src/corelib/io/qdebug.cpp6
-rw-r--r--src/corelib/io/qdir.cpp62
-rw-r--r--src/corelib/io/qdiriterator.cpp5
-rw-r--r--src/corelib/io/qfile.cpp22
-rw-r--r--src/corelib/io/qfileinfo.cpp34
-rw-r--r--src/corelib/io/qfilesystemengine.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine_p.h2
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp21
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h4
-rw-r--r--src/corelib/io/qiodevice.cpp56
-rw-r--r--src/corelib/io/qiodevice_p.h5
-rw-r--r--src/corelib/io/qprocess.cpp34
-rw-r--r--src/corelib/io/qprocess_unix.cpp11
-rw-r--r--src/corelib/io/qresource.cpp2
-rw-r--r--src/corelib/io/qsettings.cpp106
-rw-r--r--src/corelib/io/qsettings_mac.cpp2
-rw-r--r--src/corelib/io/qstandardpaths.cpp2
-rw-r--r--src/corelib/io/qstandardpaths_json.cpp2
-rw-r--r--src/corelib/io/qtemporarydir.cpp6
-rw-r--r--src/corelib/io/qtemporaryfile.cpp2
-rw-r--r--src/corelib/io/qtextstream.cpp42
-rw-r--r--src/corelib/io/qurl.cpp209
-rw-r--r--src/corelib/io/qurl_p.h1
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp48
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.cpp2
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp12
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp16
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.cpp2
-rw-r--r--src/corelib/json/qjsonarray.cpp13
-rw-r--r--src/corelib/json/qjsondocument.cpp16
-rw-r--r--src/corelib/json/qjsonobject.cpp44
-rw-r--r--src/corelib/kernel/kernel.pri8
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp4
-rw-r--r--src/corelib/kernel/qbasictimer.cpp8
-rw-r--r--src/corelib/kernel/qcore_mac_p.h2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp42
-rw-r--r--src/corelib/kernel/qeventdispatcher_blackberry.cpp262
-rw-r--r--src/corelib/kernel/qeventdispatcher_blackberry_p.h96
-rw-r--r--src/corelib/kernel/qeventloop.cpp2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp153
-rw-r--r--src/corelib/kernel/qmetaobject.h22
-rw-r--r--src/corelib/kernel/qmetaobject_p.h7
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder.cpp49
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder_p.h2
-rw-r--r--src/corelib/kernel/qmetatype.cpp118
-rw-r--r--src/corelib/kernel/qmetatype.h69
-rw-r--r--src/corelib/kernel/qmetatype_p.h2
-rw-r--r--src/corelib/kernel/qmimedata.cpp16
-rw-r--r--src/corelib/kernel/qobject.cpp329
-rw-r--r--src/corelib/kernel/qobject.h5
-rw-r--r--src/corelib/kernel/qobject_impl.h425
-rw-r--r--src/corelib/kernel/qobject_p.h3
-rw-r--r--src/corelib/kernel/qobjectcleanuphandler.cpp2
-rw-r--r--src/corelib/kernel/qobjectdefs.h21
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h485
-rw-r--r--src/corelib/kernel/qpointer.cpp6
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp14
-rw-r--r--src/corelib/kernel/qsignalmapper.cpp10
-rw-r--r--src/corelib/kernel/qsystemsemaphore.cpp6
-rw-r--r--src/corelib/kernel/qtimer.cpp18
-rw-r--r--src/corelib/kernel/qtranslator.cpp2
-rw-r--r--src/corelib/kernel/qvariant.cpp39
-rw-r--r--src/corelib/kernel/qwineventnotifier.cpp45
-rw-r--r--src/corelib/kernel/qwineventnotifier.h8
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp2
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern.cpp2
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp29
-rw-r--r--src/corelib/plugin/qlibrary.cpp16
-rw-r--r--src/corelib/plugin/qlibrary.h3
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp12
-rw-r--r--src/corelib/plugin/qplugin.qdoc10
-rw-r--r--src/corelib/plugin/qpluginloader.h2
-rw-r--r--src/corelib/plugin/quuid.cpp6
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp10
-rw-r--r--src/corelib/thread/qatomic.cpp77
-rw-r--r--src/corelib/thread/qatomic.h4
-rw-r--r--src/corelib/thread/qmutex.cpp42
-rw-r--r--src/corelib/thread/qmutex.h1
-rw-r--r--src/corelib/thread/qmutex_linux.cpp9
-rw-r--r--src/corelib/thread/qmutexpool.cpp4
-rw-r--r--src/corelib/thread/qreadwritelock.cpp24
-rw-r--r--src/corelib/thread/qsemaphore.cpp8
-rw-r--r--src/corelib/thread/qthread.cpp12
-rw-r--r--src/corelib/thread/qthread_unix.cpp27
-rw-r--r--src/corelib/thread/qthread_win.cpp2
-rw-r--r--src/corelib/thread/qthreadpool.cpp43
-rw-r--r--src/corelib/thread/qthreadpool.h3
-rw-r--r--src/corelib/thread/qthreadpool_p.h2
-rw-r--r--src/corelib/thread/qthreadstorage.cpp6
-rw-r--r--src/corelib/thread/qwaitcondition.qdoc8
-rw-r--r--src/corelib/tools/qalgorithms.qdoc52
-rw-r--r--src/corelib/tools/qarraydata.cpp2
-rw-r--r--src/corelib/tools/qarraydata.h2
-rw-r--r--src/corelib/tools/qbitarray.cpp34
-rw-r--r--src/corelib/tools/qbytearray.cpp125
-rw-r--r--src/corelib/tools/qcache.qdoc6
-rw-r--r--src/corelib/tools/qchar.cpp272
-rw-r--r--src/corelib/tools/qchar.h22
-rw-r--r--src/corelib/tools/qdatetime.cpp56
-rw-r--r--src/corelib/tools/qeasingcurve.cpp186
-rw-r--r--src/corelib/tools/qelapsedtimer.cpp6
-rw-r--r--src/corelib/tools/qelapsedtimer_generic.cpp4
-rw-r--r--src/corelib/tools/qhash.cpp57
-rw-r--r--src/corelib/tools/qhash.h28
-rw-r--r--src/corelib/tools/qiterator.qdoc104
-rw-r--r--src/corelib/tools/qlinkedlist.cpp40
-rw-r--r--src/corelib/tools/qlist.cpp58
-rw-r--r--src/corelib/tools/qlocale.cpp475
-rw-r--r--src/corelib/tools/qlocale.h21
-rw-r--r--src/corelib/tools/qlocale.qdoc8
-rw-r--r--src/corelib/tools/qlocale_data_p.h2
-rw-r--r--src/corelib/tools/qlocale_p.h126
-rw-r--r--src/corelib/tools/qlocale_unix.cpp2
-rw-r--r--src/corelib/tools/qmap.cpp60
-rw-r--r--src/corelib/tools/qpair.qdoc12
-rw-r--r--src/corelib/tools/qpoint.cpp42
-rw-r--r--src/corelib/tools/qpoint.h52
-rw-r--r--src/corelib/tools/qqueue.cpp2
-rw-r--r--src/corelib/tools/qrect.cpp16
-rw-r--r--src/corelib/tools/qrect.h212
-rw-r--r--src/corelib/tools/qregexp.cpp68
-rw-r--r--src/corelib/tools/qregexp.h6
-rw-r--r--src/corelib/tools/qregularexpression.cpp64
-rw-r--r--src/corelib/tools/qscopedpointer.cpp12
-rw-r--r--src/corelib/tools/qset.qdoc30
-rw-r--r--src/corelib/tools/qshareddata.cpp18
-rw-r--r--src/corelib/tools/qsimd.cpp278
-rw-r--r--src/corelib/tools/qsimd_p.h5
-rw-r--r--src/corelib/tools/qsize.cpp24
-rw-r--r--src/corelib/tools/qsize.h74
-rw-r--r--src/corelib/tools/qstack.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp307
-rw-r--r--src/corelib/tools/qstring.h53
-rw-r--r--src/corelib/tools/qstringbuilder.cpp2
-rw-r--r--src/corelib/tools/qstringlist.cpp38
-rw-r--r--src/corelib/tools/qtimeline.cpp2
-rw-r--r--src/corelib/tools/qunicodetables.cpp60
-rw-r--r--src/corelib/tools/qunicodetables_p.h4
-rw-r--r--src/corelib/tools/qvarlengtharray.h3
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc8
-rw-r--r--src/corelib/tools/qvector.cpp36
-rw-r--r--src/corelib/xml/qxmlstream.cpp12
-rw-r--r--src/corelib/xml/qxmlutils.cpp14
411 files changed, 22192 insertions, 3399 deletions
diff --git a/src/corelib/arch/qatomic_sparc.h b/src/corelib/arch/qatomic_sparc.h
index 63282290c1..f5c0b3ec22 100644
--- a/src/corelib/arch/qatomic_sparc.h
+++ b/src/corelib/arch/qatomic_sparc.h
@@ -129,17 +129,17 @@ extern "C" {
Q_CORE_EXPORT int q_atomic_fetch_and_add_acquire_int(volatile int *ptr, int value);
Q_CORE_EXPORT int q_atomic_fetch_and_add_release_int(volatile int *ptr, int value);
- Q_CORE_EXPORT int q_atomic_test_and_set_ptr(volatile void *ptr, void *expected, void *newval);
+ Q_CORE_EXPORT int q_atomic_test_and_set_ptr(volatile void *ptr, const void *expected, const void *newval);
Q_CORE_EXPORT int q_atomic_test_and_set_acquire_ptr(volatile void *ptr,
- void *expected,
- void *newval);
+ const void *expected,
+ const void *newval);
Q_CORE_EXPORT int q_atomic_test_and_set_release_ptr(volatile void *ptr,
- void *expected,
- void *newval);
+ const void *expected,
+ const void *newval);
- Q_CORE_EXPORT void *q_atomic_set_ptr(volatile void *ptr, void *newval);
- Q_CORE_EXPORT void *q_atomic_fetch_and_store_acquire_ptr(volatile void *ptr, void *newval);
- Q_CORE_EXPORT void *q_atomic_fetch_and_store_release_ptr(volatile void *ptr, void *newval);
+ Q_CORE_EXPORT void *q_atomic_set_ptr(volatile void *ptr, const void *newval);
+ Q_CORE_EXPORT void *q_atomic_fetch_and_store_acquire_ptr(volatile void *ptr, const void *newval);
+ Q_CORE_EXPORT void *q_atomic_fetch_and_store_release_ptr(volatile void *ptr, const void *newval);
Q_CORE_EXPORT void *q_atomic_fetch_and_add_ptr(volatile void *ptr, int value);
Q_CORE_EXPORT void *q_atomic_fetch_and_add_acquire_ptr(volatile void *ptr, int value);
diff --git a/src/corelib/codecs/codecs.qdoc b/src/corelib/codecs/codecs.qdoc
index 669072f789..05714b2253 100644
--- a/src/corelib/codecs/codecs.qdoc
+++ b/src/corelib/codecs/codecs.qdoc
@@ -68,8 +68,8 @@
for Qt.
\legalese
- Copyright (C) 2000 Ming-Che Chuang \BR
- Copyright (C) 2002 James Su, Turbolinux Inc. \BR
+ Copyright (C) 2000 Ming-Che Chuang
+ Copyright (C) 2002 James Su, Turbolinux Inc.
Copyright (C) 2002 Anthony Fok, ThizLinux Laboratory Ltd.
Redistribution and use in source and binary forms, with or without
@@ -137,9 +137,9 @@
for the various Big5 CharMapML tables.
\legalese
- Copyright (C) 2000 Ming-Che Chuang \BR
- Copyright (C) 2001, 2002 James Su, Turbolinux Inc. \BR
- Copyright (C) 2002 WU Yi, HancomLinux Inc. \BR
+ Copyright (C) 2000 Ming-Che Chuang
+ Copyright (C) 2001, 2002 James Su, Turbolinux Inc.
+ Copyright (C) 2002 WU Yi, HancomLinux Inc.
Copyright (C) 2001, 2002 Anthony Fok, ThizLinux Laboratory Ltd.
Redistribution and use in source and binary forms, with or without
@@ -307,8 +307,8 @@
The copyright notice for their code follows:
\legalese
- Copyright (C) 2000 TurboLinux, Inc. Written by Justin Yu and Sean Chen. \BR
- Copyright (C) 2001, 2002 Turbolinux, Inc. Written by James Su. \BR
+ Copyright (C) 2000 TurboLinux, Inc. Written by Justin Yu and Sean Chen.
+ Copyright (C) 2001, 2002 Turbolinux, Inc. Written by James Su.
Copyright (C) 2001, 2002 ThizLinux Laboratory Ltd. Written by Anthony Fok.
Redistribution and use in source and binary forms, with or without
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 784a75bcad..b7939f1f3e 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -818,13 +818,13 @@ QTextCodec::ConverterState::~ConverterState()
KOI8-R encoding, and want to convert it to Unicode. The simple way
to do it is like this:
- \snippet doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp 0
+ \snippet code/src_corelib_codecs_qtextcodec.cpp 0
After this, \c string holds the text converted to Unicode.
Converting a string from Unicode to the local encoding is just as
easy:
- \snippet doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp 1
+ \snippet code/src_corelib_codecs_qtextcodec.cpp 1
To read or write files in various encodings, use QTextStream and
its \l{QTextStream::setCodec()}{setCodec()} function. See the
@@ -841,7 +841,7 @@ QTextCodec::ConverterState::~ConverterState()
object for the codec and use this QTextDecoder for the whole
decoding process, as shown below:
- \snippet doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp 2
+ \snippet code/src_corelib_codecs_qtextcodec.cpp 2
The QTextDecoder object maintains state between chunks and therefore
works correctly even if a multi-byte character is split between
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 40b42f4dbe..d98cebb672 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -30,9 +30,10 @@ include(codecs/codecs.pri)
include(statemachine/statemachine.pri)
include(mimetypes/mimetypes.pri)
include(xml/xml.pri)
+include(doc/doc.pri)
mac|darwin {
- contains(QT_CONFIG, coreservices) {
+ !ios {
LIBS_PRIVATE += -framework ApplicationServices
LIBS_PRIVATE += -framework CoreServices
LIBS_PRIVATE += -framework Foundation
diff --git a/src/corelib/doc/doc.pri b/src/corelib/doc/doc.pri
new file mode 100644
index 0000000000..ed970d7592
--- /dev/null
+++ b/src/corelib/doc/doc.pri
@@ -0,0 +1,3 @@
+qtPrepareTool(QDOC, qdoc)
+docs.commands += $$QDOC $$QT.core.sources/doc/qtcore.qdocconf
+QMAKE_EXTRA_TARGETS += docs
diff --git a/src/corelib/doc/images/abstract-connections.png b/src/corelib/doc/images/abstract-connections.png
new file mode 100644
index 0000000000..18d2f4e3b7
--- /dev/null
+++ b/src/corelib/doc/images/abstract-connections.png
Binary files differ
diff --git a/src/corelib/doc/images/brush-styles.png b/src/corelib/doc/images/brush-styles.png
new file mode 100644
index 0000000000..eecb006af1
--- /dev/null
+++ b/src/corelib/doc/images/brush-styles.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-arrow.png b/src/corelib/doc/images/cursor-arrow.png
new file mode 100644
index 0000000000..a69ef4eb61
--- /dev/null
+++ b/src/corelib/doc/images/cursor-arrow.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-busy.png b/src/corelib/doc/images/cursor-busy.png
new file mode 100644
index 0000000000..53717e4992
--- /dev/null
+++ b/src/corelib/doc/images/cursor-busy.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-closedhand.png b/src/corelib/doc/images/cursor-closedhand.png
new file mode 100644
index 0000000000..b78dd1dac5
--- /dev/null
+++ b/src/corelib/doc/images/cursor-closedhand.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-cross.png b/src/corelib/doc/images/cursor-cross.png
new file mode 100644
index 0000000000..fe38e74480
--- /dev/null
+++ b/src/corelib/doc/images/cursor-cross.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-forbidden.png b/src/corelib/doc/images/cursor-forbidden.png
new file mode 100644
index 0000000000..2b08c4e2a3
--- /dev/null
+++ b/src/corelib/doc/images/cursor-forbidden.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-hand.png b/src/corelib/doc/images/cursor-hand.png
new file mode 100644
index 0000000000..d2004aefa7
--- /dev/null
+++ b/src/corelib/doc/images/cursor-hand.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-hsplit.png b/src/corelib/doc/images/cursor-hsplit.png
new file mode 100644
index 0000000000..a5667e3ffb
--- /dev/null
+++ b/src/corelib/doc/images/cursor-hsplit.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-ibeam.png b/src/corelib/doc/images/cursor-ibeam.png
new file mode 100644
index 0000000000..097fc5fa72
--- /dev/null
+++ b/src/corelib/doc/images/cursor-ibeam.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-openhand.png b/src/corelib/doc/images/cursor-openhand.png
new file mode 100644
index 0000000000..9181c859ed
--- /dev/null
+++ b/src/corelib/doc/images/cursor-openhand.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-sizeall.png b/src/corelib/doc/images/cursor-sizeall.png
new file mode 100644
index 0000000000..69f13eb347
--- /dev/null
+++ b/src/corelib/doc/images/cursor-sizeall.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-sizeb.png b/src/corelib/doc/images/cursor-sizeb.png
new file mode 100644
index 0000000000..f37d7b91e8
--- /dev/null
+++ b/src/corelib/doc/images/cursor-sizeb.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-sizef.png b/src/corelib/doc/images/cursor-sizef.png
new file mode 100644
index 0000000000..3b127a05d3
--- /dev/null
+++ b/src/corelib/doc/images/cursor-sizef.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-sizeh.png b/src/corelib/doc/images/cursor-sizeh.png
new file mode 100644
index 0000000000..a9f40cbc3d
--- /dev/null
+++ b/src/corelib/doc/images/cursor-sizeh.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-sizev.png b/src/corelib/doc/images/cursor-sizev.png
new file mode 100644
index 0000000000..1edbab27a5
--- /dev/null
+++ b/src/corelib/doc/images/cursor-sizev.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-uparrow.png b/src/corelib/doc/images/cursor-uparrow.png
new file mode 100644
index 0000000000..d3e70ef4c2
--- /dev/null
+++ b/src/corelib/doc/images/cursor-uparrow.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-vsplit.png b/src/corelib/doc/images/cursor-vsplit.png
new file mode 100644
index 0000000000..1beda2570e
--- /dev/null
+++ b/src/corelib/doc/images/cursor-vsplit.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-wait.png b/src/corelib/doc/images/cursor-wait.png
new file mode 100644
index 0000000000..69056c479e
--- /dev/null
+++ b/src/corelib/doc/images/cursor-wait.png
Binary files differ
diff --git a/src/corelib/doc/images/cursor-whatsthis.png b/src/corelib/doc/images/cursor-whatsthis.png
new file mode 100644
index 0000000000..b47601c378
--- /dev/null
+++ b/src/corelib/doc/images/cursor-whatsthis.png
Binary files differ
diff --git a/src/corelib/doc/images/javaiterators1.png b/src/corelib/doc/images/javaiterators1.png
new file mode 100644
index 0000000000..7dfcde0188
--- /dev/null
+++ b/src/corelib/doc/images/javaiterators1.png
Binary files differ
diff --git a/src/corelib/doc/images/javaiterators2.png b/src/corelib/doc/images/javaiterators2.png
new file mode 100644
index 0000000000..c04e3ccf88
--- /dev/null
+++ b/src/corelib/doc/images/javaiterators2.png
Binary files differ
diff --git a/src/corelib/doc/images/modelindex-no-parent.png b/src/corelib/doc/images/modelindex-no-parent.png
new file mode 100644
index 0000000000..9c6258e5d1
--- /dev/null
+++ b/src/corelib/doc/images/modelindex-no-parent.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-begin-append-columns.png b/src/corelib/doc/images/modelview-begin-append-columns.png
new file mode 100644
index 0000000000..8d13b178d8
--- /dev/null
+++ b/src/corelib/doc/images/modelview-begin-append-columns.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-begin-append-rows.png b/src/corelib/doc/images/modelview-begin-append-rows.png
new file mode 100644
index 0000000000..50d04c3e67
--- /dev/null
+++ b/src/corelib/doc/images/modelview-begin-append-rows.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-begin-insert-columns.png b/src/corelib/doc/images/modelview-begin-insert-columns.png
new file mode 100644
index 0000000000..30eeb8280e
--- /dev/null
+++ b/src/corelib/doc/images/modelview-begin-insert-columns.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-begin-insert-rows.png b/src/corelib/doc/images/modelview-begin-insert-rows.png
new file mode 100644
index 0000000000..b4d6eda57d
--- /dev/null
+++ b/src/corelib/doc/images/modelview-begin-insert-rows.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-begin-remove-columns.png b/src/corelib/doc/images/modelview-begin-remove-columns.png
new file mode 100644
index 0000000000..aee60e01ec
--- /dev/null
+++ b/src/corelib/doc/images/modelview-begin-remove-columns.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-begin-remove-rows.png b/src/corelib/doc/images/modelview-begin-remove-rows.png
new file mode 100644
index 0000000000..8e9518718e
--- /dev/null
+++ b/src/corelib/doc/images/modelview-begin-remove-rows.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-move-rows-1.png b/src/corelib/doc/images/modelview-move-rows-1.png
new file mode 100644
index 0000000000..b629a72dd4
--- /dev/null
+++ b/src/corelib/doc/images/modelview-move-rows-1.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-move-rows-2.png b/src/corelib/doc/images/modelview-move-rows-2.png
new file mode 100644
index 0000000000..674ca18f78
--- /dev/null
+++ b/src/corelib/doc/images/modelview-move-rows-2.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-move-rows-3.png b/src/corelib/doc/images/modelview-move-rows-3.png
new file mode 100644
index 0000000000..5445dd599c
--- /dev/null
+++ b/src/corelib/doc/images/modelview-move-rows-3.png
Binary files differ
diff --git a/src/corelib/doc/images/modelview-move-rows-4.png b/src/corelib/doc/images/modelview-move-rows-4.png
new file mode 100644
index 0000000000..ecd65bac6c
--- /dev/null
+++ b/src/corelib/doc/images/modelview-move-rows-4.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inback.png b/src/corelib/doc/images/qeasingcurve-inback.png
new file mode 100644
index 0000000000..0064cb341c
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inback.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inbounce.png b/src/corelib/doc/images/qeasingcurve-inbounce.png
new file mode 100644
index 0000000000..eaa64f8c41
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inbounce.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-incirc.png b/src/corelib/doc/images/qeasingcurve-incirc.png
new file mode 100644
index 0000000000..7bd0f09d41
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-incirc.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-incubic.png b/src/corelib/doc/images/qeasingcurve-incubic.png
new file mode 100644
index 0000000000..1ac9eafba5
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-incubic.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inelastic.png b/src/corelib/doc/images/qeasingcurve-inelastic.png
new file mode 100644
index 0000000000..f976b5a576
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inelastic.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inexpo.png b/src/corelib/doc/images/qeasingcurve-inexpo.png
new file mode 100644
index 0000000000..1af3652985
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inexpo.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutback.png b/src/corelib/doc/images/qeasingcurve-inoutback.png
new file mode 100644
index 0000000000..480bc051ef
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutback.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutbounce.png b/src/corelib/doc/images/qeasingcurve-inoutbounce.png
new file mode 100644
index 0000000000..de623091cf
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutbounce.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutcirc.png b/src/corelib/doc/images/qeasingcurve-inoutcirc.png
new file mode 100644
index 0000000000..b4be8ac21e
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutcirc.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutcubic.png b/src/corelib/doc/images/qeasingcurve-inoutcubic.png
new file mode 100644
index 0000000000..49dfbef1b6
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutcubic.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutelastic.png b/src/corelib/doc/images/qeasingcurve-inoutelastic.png
new file mode 100644
index 0000000000..5b0e54a019
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutelastic.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutexpo.png b/src/corelib/doc/images/qeasingcurve-inoutexpo.png
new file mode 100644
index 0000000000..776984a113
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutexpo.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutquad.png b/src/corelib/doc/images/qeasingcurve-inoutquad.png
new file mode 100644
index 0000000000..264333085a
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutquad.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutquart.png b/src/corelib/doc/images/qeasingcurve-inoutquart.png
new file mode 100644
index 0000000000..31fc0c8852
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutquart.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutquint.png b/src/corelib/doc/images/qeasingcurve-inoutquint.png
new file mode 100644
index 0000000000..4d7a745be6
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutquint.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inoutsine.png b/src/corelib/doc/images/qeasingcurve-inoutsine.png
new file mode 100644
index 0000000000..012ff751c9
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inoutsine.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inquad.png b/src/corelib/doc/images/qeasingcurve-inquad.png
new file mode 100644
index 0000000000..e697c208a5
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inquad.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inquart.png b/src/corelib/doc/images/qeasingcurve-inquart.png
new file mode 100644
index 0000000000..6d6517551e
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inquart.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-inquint.png b/src/corelib/doc/images/qeasingcurve-inquint.png
new file mode 100644
index 0000000000..faaaea71fd
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-inquint.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-insine.png b/src/corelib/doc/images/qeasingcurve-insine.png
new file mode 100644
index 0000000000..09449034b5
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-insine.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-linear.png b/src/corelib/doc/images/qeasingcurve-linear.png
new file mode 100644
index 0000000000..fb3aaf3541
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-linear.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outback.png b/src/corelib/doc/images/qeasingcurve-outback.png
new file mode 100644
index 0000000000..83b3fa233f
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outback.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outbounce.png b/src/corelib/doc/images/qeasingcurve-outbounce.png
new file mode 100644
index 0000000000..27ac979642
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outbounce.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outcirc.png b/src/corelib/doc/images/qeasingcurve-outcirc.png
new file mode 100644
index 0000000000..00193700e0
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outcirc.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outcubic.png b/src/corelib/doc/images/qeasingcurve-outcubic.png
new file mode 100644
index 0000000000..45477c045a
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outcubic.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outelastic.png b/src/corelib/doc/images/qeasingcurve-outelastic.png
new file mode 100644
index 0000000000..1d407ed845
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outelastic.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outexpo.png b/src/corelib/doc/images/qeasingcurve-outexpo.png
new file mode 100644
index 0000000000..56851554ed
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outexpo.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outinback.png b/src/corelib/doc/images/qeasingcurve-outinback.png
new file mode 100644
index 0000000000..4700ab02e8
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outinback.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outinbounce.png b/src/corelib/doc/images/qeasingcurve-outinbounce.png
new file mode 100644
index 0000000000..12cc1a8bd4
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outinbounce.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outincirc.png b/src/corelib/doc/images/qeasingcurve-outincirc.png
new file mode 100644
index 0000000000..c8a5c86a23
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outincirc.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outincubic.png b/src/corelib/doc/images/qeasingcurve-outincubic.png
new file mode 100644
index 0000000000..42af870d99
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outincubic.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outinelastic.png b/src/corelib/doc/images/qeasingcurve-outinelastic.png
new file mode 100644
index 0000000000..308be57900
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outinelastic.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outinexpo.png b/src/corelib/doc/images/qeasingcurve-outinexpo.png
new file mode 100644
index 0000000000..0692baa264
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outinexpo.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outinquad.png b/src/corelib/doc/images/qeasingcurve-outinquad.png
new file mode 100644
index 0000000000..9e3cd83896
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outinquad.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outinquart.png b/src/corelib/doc/images/qeasingcurve-outinquart.png
new file mode 100644
index 0000000000..9a3c16f122
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outinquart.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outinquint.png b/src/corelib/doc/images/qeasingcurve-outinquint.png
new file mode 100644
index 0000000000..add9feb26f
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outinquint.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outinsine.png b/src/corelib/doc/images/qeasingcurve-outinsine.png
new file mode 100644
index 0000000000..4bc2aaf9e3
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outinsine.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outquad.png b/src/corelib/doc/images/qeasingcurve-outquad.png
new file mode 100644
index 0000000000..c505ff9e7b
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outquad.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outquart.png b/src/corelib/doc/images/qeasingcurve-outquart.png
new file mode 100644
index 0000000000..6eac058d18
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outquart.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outquint.png b/src/corelib/doc/images/qeasingcurve-outquint.png
new file mode 100644
index 0000000000..77a9ad417f
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outquint.png
Binary files differ
diff --git a/src/corelib/doc/images/qeasingcurve-outsine.png b/src/corelib/doc/images/qeasingcurve-outsine.png
new file mode 100644
index 0000000000..d135b2f98c
--- /dev/null
+++ b/src/corelib/doc/images/qeasingcurve-outsine.png
Binary files differ
diff --git a/src/corelib/doc/images/qimage-scaling.png b/src/corelib/doc/images/qimage-scaling.png
new file mode 100644
index 0000000000..fcd71448f0
--- /dev/null
+++ b/src/corelib/doc/images/qimage-scaling.png
Binary files differ
diff --git a/src/corelib/doc/images/qline-coordinates.png b/src/corelib/doc/images/qline-coordinates.png
new file mode 100644
index 0000000000..ac4fb980ac
--- /dev/null
+++ b/src/corelib/doc/images/qline-coordinates.png
Binary files differ
diff --git a/src/corelib/doc/images/qline-point.png b/src/corelib/doc/images/qline-point.png
new file mode 100644
index 0000000000..3bc3664a20
--- /dev/null
+++ b/src/corelib/doc/images/qline-point.png
Binary files differ
diff --git a/src/corelib/doc/images/qlinef-angle-identicaldirection.png b/src/corelib/doc/images/qlinef-angle-identicaldirection.png
new file mode 100644
index 0000000000..18d632321b
--- /dev/null
+++ b/src/corelib/doc/images/qlinef-angle-identicaldirection.png
Binary files differ
diff --git a/src/corelib/doc/images/qlinef-angle-oppositedirection.png b/src/corelib/doc/images/qlinef-angle-oppositedirection.png
new file mode 100644
index 0000000000..bf52cfe011
--- /dev/null
+++ b/src/corelib/doc/images/qlinef-angle-oppositedirection.png
Binary files differ
diff --git a/src/corelib/doc/images/qlinef-bounded.png b/src/corelib/doc/images/qlinef-bounded.png
new file mode 100644
index 0000000000..136dd50304
--- /dev/null
+++ b/src/corelib/doc/images/qlinef-bounded.png
Binary files differ
diff --git a/src/corelib/doc/images/qlinef-normalvector.png b/src/corelib/doc/images/qlinef-normalvector.png
new file mode 100644
index 0000000000..b7d944f32f
--- /dev/null
+++ b/src/corelib/doc/images/qlinef-normalvector.png
Binary files differ
diff --git a/src/corelib/doc/images/qlinef-unbounded.png b/src/corelib/doc/images/qlinef-unbounded.png
new file mode 100644
index 0000000000..75ead98ff2
--- /dev/null
+++ b/src/corelib/doc/images/qlinef-unbounded.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-bevel.png b/src/corelib/doc/images/qpen-bevel.png
new file mode 100644
index 0000000000..8a30779e3b
--- /dev/null
+++ b/src/corelib/doc/images/qpen-bevel.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-custom.png b/src/corelib/doc/images/qpen-custom.png
new file mode 100644
index 0000000000..a2a038abe0
--- /dev/null
+++ b/src/corelib/doc/images/qpen-custom.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-dash.png b/src/corelib/doc/images/qpen-dash.png
new file mode 100644
index 0000000000..67082c3758
--- /dev/null
+++ b/src/corelib/doc/images/qpen-dash.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-dashdot.png b/src/corelib/doc/images/qpen-dashdot.png
new file mode 100644
index 0000000000..64b384660f
--- /dev/null
+++ b/src/corelib/doc/images/qpen-dashdot.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-dashdotdot.png b/src/corelib/doc/images/qpen-dashdotdot.png
new file mode 100644
index 0000000000..ff1b2e69cd
--- /dev/null
+++ b/src/corelib/doc/images/qpen-dashdotdot.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-dot.png b/src/corelib/doc/images/qpen-dot.png
new file mode 100644
index 0000000000..54e81c9469
--- /dev/null
+++ b/src/corelib/doc/images/qpen-dot.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-flat.png b/src/corelib/doc/images/qpen-flat.png
new file mode 100644
index 0000000000..06e2195f73
--- /dev/null
+++ b/src/corelib/doc/images/qpen-flat.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-miter.png b/src/corelib/doc/images/qpen-miter.png
new file mode 100644
index 0000000000..025e003979
--- /dev/null
+++ b/src/corelib/doc/images/qpen-miter.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-roundcap.png b/src/corelib/doc/images/qpen-roundcap.png
new file mode 100644
index 0000000000..77b22b2bab
--- /dev/null
+++ b/src/corelib/doc/images/qpen-roundcap.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-roundjoin.png b/src/corelib/doc/images/qpen-roundjoin.png
new file mode 100644
index 0000000000..155e2aa8cc
--- /dev/null
+++ b/src/corelib/doc/images/qpen-roundjoin.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-solid.png b/src/corelib/doc/images/qpen-solid.png
new file mode 100644
index 0000000000..e042b18017
--- /dev/null
+++ b/src/corelib/doc/images/qpen-solid.png
Binary files differ
diff --git a/src/corelib/doc/images/qpen-square.png b/src/corelib/doc/images/qpen-square.png
new file mode 100644
index 0000000000..ebc5d1e329
--- /dev/null
+++ b/src/corelib/doc/images/qpen-square.png
Binary files differ
diff --git a/src/corelib/doc/images/qrect-coordinates.png b/src/corelib/doc/images/qrect-coordinates.png
new file mode 100644
index 0000000000..2a2dae2d6c
--- /dev/null
+++ b/src/corelib/doc/images/qrect-coordinates.png
Binary files differ
diff --git a/src/corelib/doc/images/qrect-diagram-one.png b/src/corelib/doc/images/qrect-diagram-one.png
new file mode 100644
index 0000000000..a893be277a
--- /dev/null
+++ b/src/corelib/doc/images/qrect-diagram-one.png
Binary files differ
diff --git a/src/corelib/doc/images/qrect-diagram-three.png b/src/corelib/doc/images/qrect-diagram-three.png
new file mode 100644
index 0000000000..84fb35be6c
--- /dev/null
+++ b/src/corelib/doc/images/qrect-diagram-three.png
Binary files differ
diff --git a/src/corelib/doc/images/qrect-diagram-two.png b/src/corelib/doc/images/qrect-diagram-two.png
new file mode 100644
index 0000000000..e19caacc34
--- /dev/null
+++ b/src/corelib/doc/images/qrect-diagram-two.png
Binary files differ
diff --git a/src/corelib/doc/images/qrect-diagram-zero.png b/src/corelib/doc/images/qrect-diagram-zero.png
new file mode 100644
index 0000000000..90e3db0c41
--- /dev/null
+++ b/src/corelib/doc/images/qrect-diagram-zero.png
Binary files differ
diff --git a/src/corelib/doc/images/qrect-intersect.png b/src/corelib/doc/images/qrect-intersect.png
new file mode 100644
index 0000000000..db68cd53ad
--- /dev/null
+++ b/src/corelib/doc/images/qrect-intersect.png
Binary files differ
diff --git a/src/corelib/doc/images/qrect-unite.png b/src/corelib/doc/images/qrect-unite.png
new file mode 100644
index 0000000000..3f6239f405
--- /dev/null
+++ b/src/corelib/doc/images/qrect-unite.png
Binary files differ
diff --git a/src/corelib/doc/images/qrectf-coordinates.png b/src/corelib/doc/images/qrectf-coordinates.png
new file mode 100644
index 0000000000..ccc6d82063
--- /dev/null
+++ b/src/corelib/doc/images/qrectf-coordinates.png
Binary files differ
diff --git a/src/corelib/doc/images/qrectf-diagram-one.png b/src/corelib/doc/images/qrectf-diagram-one.png
new file mode 100644
index 0000000000..842289ce07
--- /dev/null
+++ b/src/corelib/doc/images/qrectf-diagram-one.png
Binary files differ
diff --git a/src/corelib/doc/images/qrectf-diagram-three.png b/src/corelib/doc/images/qrectf-diagram-three.png
new file mode 100644
index 0000000000..e05106a7e1
--- /dev/null
+++ b/src/corelib/doc/images/qrectf-diagram-three.png
Binary files differ
diff --git a/src/corelib/doc/images/qrectf-diagram-two.png b/src/corelib/doc/images/qrectf-diagram-two.png
new file mode 100644
index 0000000000..192d00df79
--- /dev/null
+++ b/src/corelib/doc/images/qrectf-diagram-two.png
Binary files differ
diff --git a/src/corelib/doc/images/qsortfilterproxymodel-sorting.png b/src/corelib/doc/images/qsortfilterproxymodel-sorting.png
new file mode 100644
index 0000000000..de99d41272
--- /dev/null
+++ b/src/corelib/doc/images/qsortfilterproxymodel-sorting.png
Binary files differ
diff --git a/src/corelib/doc/images/qurl-authority.png b/src/corelib/doc/images/qurl-authority.png
new file mode 100644
index 0000000000..54de2a792e
--- /dev/null
+++ b/src/corelib/doc/images/qurl-authority.png
Binary files differ
diff --git a/src/corelib/doc/images/qurl-authority2.png b/src/corelib/doc/images/qurl-authority2.png
new file mode 100644
index 0000000000..fe8d4d87b2
--- /dev/null
+++ b/src/corelib/doc/images/qurl-authority2.png
Binary files differ
diff --git a/src/corelib/doc/images/qurl-authority3.png b/src/corelib/doc/images/qurl-authority3.png
new file mode 100644
index 0000000000..242063e935
--- /dev/null
+++ b/src/corelib/doc/images/qurl-authority3.png
Binary files differ
diff --git a/src/corelib/doc/images/qurl-fragment.png b/src/corelib/doc/images/qurl-fragment.png
new file mode 100644
index 0000000000..e93a252e7a
--- /dev/null
+++ b/src/corelib/doc/images/qurl-fragment.png
Binary files differ
diff --git a/src/corelib/doc/images/qurl-ftppath.png b/src/corelib/doc/images/qurl-ftppath.png
new file mode 100644
index 0000000000..d88df4922b
--- /dev/null
+++ b/src/corelib/doc/images/qurl-ftppath.png
Binary files differ
diff --git a/src/corelib/doc/images/qurl-mailtopath.png b/src/corelib/doc/images/qurl-mailtopath.png
new file mode 100644
index 0000000000..34ec153b74
--- /dev/null
+++ b/src/corelib/doc/images/qurl-mailtopath.png
Binary files differ
diff --git a/src/corelib/doc/images/qurl-querystring.png b/src/corelib/doc/images/qurl-querystring.png
new file mode 100644
index 0000000000..7c3309a5ac
--- /dev/null
+++ b/src/corelib/doc/images/qurl-querystring.png
Binary files differ
diff --git a/src/corelib/doc/images/stliterators1.png b/src/corelib/doc/images/stliterators1.png
new file mode 100644
index 0000000000..6d71e4712f
--- /dev/null
+++ b/src/corelib/doc/images/stliterators1.png
Binary files differ
diff --git a/src/corelib/doc/images/thread_clock.png b/src/corelib/doc/images/thread_clock.png
new file mode 100644
index 0000000000..b8a8aa0a39
--- /dev/null
+++ b/src/corelib/doc/images/thread_clock.png
Binary files differ
diff --git a/src/corelib/doc/images/threadsandobjects.png b/src/corelib/doc/images/threadsandobjects.png
new file mode 100644
index 0000000000..8357d2532a
--- /dev/null
+++ b/src/corelib/doc/images/threadsandobjects.png
Binary files differ
diff --git a/src/corelib/doc/images/threadvisual-example.png b/src/corelib/doc/images/threadvisual-example.png
new file mode 100644
index 0000000000..2a49874719
--- /dev/null
+++ b/src/corelib/doc/images/threadvisual-example.png
Binary files differ
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
new file mode 100644
index 0000000000..f788b36cdf
--- /dev/null
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -0,0 +1,90 @@
+include(../../../doc/global/qt-cpp-ignore.qdocconf)
+
+project = QtCore
+description = Qt Core Reference Documentation
+url = http://qt-project.org/doc/qt-5.0/qtcore
+version = 5.0.0
+
+sourceencoding = UTF-8
+outputencoding = UTF-8
+naturallanguage = en_US
+qhp.projects = QtCore
+
+qhp.QtCore.file = qtcore.qhp
+qhp.QtCore.namespace = org.qt-project.qtcore.500
+qhp.QtCore.virtualFolder = qdoc
+qhp.QtCore.indexTitle = Qt Core Reference Documentation
+qhp.QtCore.indexRoot =
+
+qhp.QtCore.filterAttributes = qtcore 5.0.0 qtrefdoc
+qhp.QtCore.customFilters.Qt.name = QtCore 5.0.0
+qhp.QtCore.customFilters.Qt.filterAttributes = qtcore 5.0.0
+qhp.QtCore.subprojects = classes overviews examples
+qhp.QtCore.subprojects.classes.title = Classes
+qhp.QtCore.subprojects.classes.indexTitle = Qt Core's Classes
+qhp.QtCore.subprojects.classes.selectors = class fake:headerfile
+qhp.QtCore.subprojects.classes.sortPages = true
+qhp.QtCore.subprojects.overviews.title = Overviews
+qhp.QtCore.subprojects.overviews.indexTitle = All Overviews and HOWTOs
+qhp.QtCore.subprojects.overviews.selectors = fake:page,group,module
+qhp.QtCore.subprojects.examples.title = Qt Core Examples
+qhp.QtCore.subprojects.examples.indexTitle = Qt Core Examples
+qhp.QtCore.subprojects.examples.selectors = fake:example
+
+dita.metadata.default.author = Qt Project
+dita.metadata.default.permissions = all
+dita.metadata.default.publisher = Qt Project
+dita.metadata.default.copyryear = 2012
+dita.metadata.default.copyrholder = Nokia
+dita.metadata.default.audience = programmer
+
+sources.fileextensions = "*.c++ *.cc *.cpp *.cxx *.mm *.qml *.qdoc"
+headers.fileextensions = "*.ch *.h *.h++ *.hh *.hpp *.hxx"
+
+examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml *.css"
+examples.imageextensions = "*.png"
+
+outputdir = ../../../doc/qtcore
+tagfile = ../../../doc/qtcore/qtcore.tags
+
+HTML.generatemacrefs = "true"
+HTML.nobreadcrumbs = "true"
+
+HTML.templatedir = .
+
+HTML.stylesheets = ../../../doc/global/style/offline.css
+
+HTML.headerstyles = \
+ " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n"
+
+HTML.endheader = \
+ "</head>\n" \
+
+defines = Q_QDOC \
+ QT_.*_SUPPORT \
+ QT_.*_LIB \
+ QT_COMPAT \
+ QT_KEYPAD_NAVIGATION \
+ QT_NO_EGL \
+ Q_WS_.* \
+ Q_OS_.* \
+ Q_BYTE_ORDER \
+ QT_DEPRECATED \
+ QT_DEPRECATED_* \
+ Q_NO_USING_KEYWORD \
+ __cplusplus \
+ Q_COMPILER_INITIALIZER_LISTS
+
+versionsym = QT_VERSION_STR
+
+codeindent = 1
+
+headerdirs += ..
+
+sourcedirs += ..
+
+exampledirs += ../../../examples \
+ ../ \
+ snippets
+
+imagedirs += images
diff --git a/src/corelib/doc/snippets/buffer/buffer.cpp b/src/corelib/doc/snippets/buffer/buffer.cpp
new file mode 100644
index 0000000000..681fb56791
--- /dev/null
+++ b/src/corelib/doc/snippets/buffer/buffer.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QBuffer>
+#include <QPalette>
+
+static void main_snippet()
+{
+//! [0]
+ QBuffer buffer;
+ char ch;
+
+ buffer.open(QBuffer::ReadWrite);
+ buffer.write("Qt rocks!");
+ buffer.seek(0);
+ buffer.getChar(&ch); // ch == 'Q'
+ buffer.getChar(&ch); // ch == 't'
+ buffer.getChar(&ch); // ch == ' '
+ buffer.getChar(&ch); // ch == 'r'
+//! [0]
+}
+
+static void write_datastream_snippets()
+{
+//! [1]
+ QByteArray byteArray;
+ QBuffer buffer(&byteArray);
+ buffer.open(QIODevice::WriteOnly);
+
+ QDataStream out(&buffer);
+ out << QApplication::palette();
+//! [1]
+}
+
+static void read_datastream_snippets()
+{
+ QByteArray byteArray;
+
+//! [2]
+ QPalette palette;
+ QBuffer buffer(&byteArray);
+ buffer.open(QIODevice::ReadOnly);
+
+ QDataStream in(&buffer);
+ in >> palette;
+//! [2]
+}
+
+static void bytearray_ptr_ctor_snippet()
+{
+//! [3]
+ QByteArray byteArray("abc");
+ QBuffer buffer(&byteArray);
+ buffer.open(QIODevice::WriteOnly);
+ buffer.seek(3);
+ buffer.write("def", 3);
+ buffer.close();
+ // byteArray == "abcdef"
+//! [3]
+}
+
+static void setBuffer_snippet()
+{
+//! [4]
+ QByteArray byteArray("abc");
+ QBuffer buffer;
+ buffer.setBuffer(&byteArray);
+ buffer.open(QIODevice::WriteOnly);
+ buffer.seek(3);
+ buffer.write("def", 3);
+ buffer.close();
+ // byteArray == "abcdef"
+//! [4]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ main_snippet();
+ bytearray_ptr_ctor_snippet();
+ write_datastream_snippets();
+ read_datastream_snippets();
+ setBuffer_snippet();
+ return 0;
+}
diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp
new file mode 100644
index 0000000000..c74b0f79dc
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class Employee
+{
+public:
+ Employee() {}
+ Employee(const Employee &other);
+
+ Employee &operator=(const Employee &other);
+
+private:
+ QString myName;
+ QDate myDateOfBirth;
+};
+//! [0]
+
+
+//! [1]
+QList<QString> list;
+list << "A" << "B" << "C" << "D";
+
+QListIterator<QString> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [1]
+
+
+//! [2]
+QListIterator<QString> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [2]
+
+
+//! [3]
+QMutableListIterator<int> i(list);
+while (i.hasNext()) {
+ if (i.next() % 2 != 0)
+ i.remove();
+}
+//! [3]
+
+
+//! [4]
+QMutableListIterator<int> i(list);
+i.toBack();
+while (i.hasPrevious()) {
+ if (i.previous() % 2 != 0)
+ i.remove();
+}
+//! [4]
+
+
+//! [5]
+QMutableListIterator<int> i(list);
+while (i.hasNext()) {
+ if (i.next() > 128)
+ i.setValue(128);
+}
+//! [5]
+
+
+//! [6]
+QMutableListIterator<int> i(list);
+while (i.hasNext())
+ i.next() *= 2;
+//! [6]
+
+
+//! [7]
+QMap<QString, QString> map;
+map.insert("Paris", "France");
+map.insert("Guatemala City", "Guatemala");
+map.insert("Mexico City", "Mexico");
+map.insert("Moscow", "Russia");
+...
+
+QMutableMapIterator<QString, QString> i(map);
+while (i.hasNext()) {
+ if (i.next().key().endsWith("City"))
+ i.remove();
+}
+//! [7]
+
+
+//! [8]
+QMap<int, QWidget *> map;
+QHash<int, QWidget *> hash;
+
+QMapIterator<int, QWidget *> i(map);
+while (i.hasNext()) {
+ i.next();
+ hash.insert(i.key(), i.value());
+}
+//! [8]
+
+
+//! [9]
+QMutableMapIterator<int, QWidget *> i(map);
+while (i.findNext(widget))
+ i.remove();
+//! [9]
+
+
+//! [10]
+QList<QString> list;
+list << "A" << "B" << "C" << "D";
+
+QList<QString>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ *i = (*i).toLower();
+//! [10]
+
+
+//! [11]
+QList<QString> list;
+list << "A" << "B" << "C" << "D";
+
+QList<QString>::iterator i = list.end();
+while (i != list.begin()) {
+ --i;
+ *i = (*i).toLower();
+}
+//! [11]
+
+
+//! [12]
+QList<QString>::const_iterator i;
+for (i = list.constBegin(); i != list.constEnd(); ++i)
+ qDebug() << *i;
+//! [12]
+
+
+//! [13]
+QMap<int, int> map;
+...
+QMap<int, int>::const_iterator i;
+for (i = map.constBegin(); i != map.constEnd(); ++i)
+ qDebug() << i.key() << ":" << i.value();
+//! [13]
+
+
+//! [14]
+// RIGHT
+const QList<int> sizes = splitter->sizes();
+QList<int>::const_iterator i;
+for (i = sizes.begin(); i != sizes.end(); ++i)
+ ...
+
+// WRONG
+QList<int>::const_iterator i;
+for (i = splitter->sizes().begin();
+ i != splitter->sizes().end(); ++i)
+ ...
+//! [14]
+
+
+//! [15]
+QLinkedList<QString> list;
+...
+QString str;
+foreach (str, list)
+ qDebug() << str;
+//! [15]
+
+
+//! [16]
+QLinkedList<QString> list;
+...
+QLinkedListIterator<QString> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [16]
+
+
+//! [17]
+QLinkedList<QString> list;
+...
+foreach (const QString &str, list)
+ qDebug() << str;
+//! [17]
+
+
+//! [18]
+QLinkedList<QString> list;
+...
+foreach (const QString &str, list) {
+ if (str.isEmpty())
+ break;
+ qDebug() << str;
+}
+//! [18]
+
+
+//! [19]
+QMap<QString, int> map;
+...
+foreach (const QString &str, map.keys())
+ qDebug() << str << ":" << map.value(str);
+//! [19]
+
+
+//! [20]
+QMultiMap<QString, int> map;
+...
+foreach (const QString &str, map.uniqueKeys()) {
+ foreach (int i, map.values(str))
+ qDebug() << str << ":" << i;
+}
+//! [20]
+
+
+//! [21]
+forever {
+ ...
+}
+//! [21]
+
+
+//! [22]
+CONFIG += no_keywords
+//! [22]
+
+
+//! [23]
+QString onlyLetters(const QString &in)
+{
+ QString out;
+ for (int j = 0; j < in.size(); ++j) {
+ if (in[j].isLetter())
+ out += in[j];
+ }
+ return out;
+}
+//! [23]
diff --git a/src/corelib/doc/snippets/code/doc_src_groups.cpp b/src/corelib/doc/snippets/code/doc_src_groups.cpp
new file mode 100644
index 0000000000..abfbfc59c0
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_groups.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void QPen::setStyle(Qt::PenStyle style)
+{
+ detach(); // detach from common data
+ d->style = style; // set the style member
+}
+
+void QPen::detach()
+{
+ if (d->ref != 1) {
+ ... // perform a deep copy
+ }
+}
+//! [0]
+
+
+//! [1]
+QPixmap p1, p2;
+p1.load("image.bmp");
+p2 = p1; // p1 and p2 share data
+
+QPainter paint;
+paint.begin(&p2); // cuts p2 loose from p1
+paint.drawText(0,50, "Hi");
+paint.end();
+//! [1]
diff --git a/src/corelib/doc/snippets/code/doc_src_objecttrees.cpp b/src/corelib/doc/snippets/code/doc_src_objecttrees.cpp
new file mode 100644
index 0000000000..62d556057b
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_objecttrees.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+int main()
+{
+ QWidget window;
+ QPushButton quit("Quit", &window);
+ ...
+}
+//![0]
+
+
+//![1]
+int main()
+{
+ QPushButton quit("Quit");
+ QWidget window;
+
+ quit.setParent(&window);
+ ...
+}
+//![1]
diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp
new file mode 100644
index 0000000000..b88fc22084
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q_PROPERTY(type name
+ READ getFunction
+ [WRITE setFunction]
+ [RESET resetFunction]
+ [NOTIFY notifySignal]
+ [REVISION int]
+ [DESIGNABLE bool]
+ [SCRIPTABLE bool]
+ [STORED bool]
+ [USER bool]
+ [CONSTANT]
+ [FINAL])
+//! [0]
+
+
+//! [1]
+Q_PROPERTY(bool focus READ hasFocus)
+Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
+Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
+//! [1]
+
+
+//! [2]
+Q_PROPERTY(QDate date READ getDate WRITE setDate)
+//! [2]
+
+
+//! [3]
+QPushButton *button = new QPushButton;
+QObject *object = button;
+
+button->setDown(true);
+object->setProperty("down", true);
+//! [3]
+
+
+//! [4]
+QObject *object = ...
+const QMetaObject *metaobject = object->metaObject();
+int count = metaobject->propertyCount();
+for (int i=0; i<count; ++i) {
+ QMetaProperty metaproperty = metaobject->property(i);
+ const char *name = metaproperty.name();
+ QVariant value = object->property(name);
+ ...
+}
+//! [4]
+
+
+//! [5]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
+ Q_ENUMS(Priority)
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+ enum Priority { High, Low, VeryHigh, VeryLow };
+
+ void setPriority(Priority priority)
+ {
+ m_priority = priority;
+ emit priorityChanged(priority);
+ }
+ Priority priority() const
+ { return m_priority; }
+
+signals:
+ void priorityChanged(Priority);
+
+private:
+ Priority m_priority;
+};
+//! [5]
+
+
+//! [6]
+MyClass *myinstance = new MyClass;
+QObject *object = myinstance;
+
+myinstance->setPriority(MyClass::VeryHigh);
+object->setProperty("priority", "VeryHigh");
+//! [6]
+
+
+//! [7]
+Q_CLASSINFO("Version", "3.0.0")
+//! [7]
diff --git a/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp
new file mode 100644
index 0000000000..20e64b61fa
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp
@@ -0,0 +1,354 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QStringList list;
+list << "one" << "two" << "three";
+
+qFill(list.begin(), list.end(), "eleven");
+// list: [ "eleven", "eleven", "eleven" ]
+//! [0]
+
+
+//! [1]
+qFill(list.begin() + 1, list.end(), "six");
+// list: [ "eleven", "six", "six" ]
+//! [1]
+
+
+//! [2]
+QChar resolveEntity(const QString &entity)
+{
+ static const QLatin1String name_table[] = {
+ "AElig", "Aacute", ..., "zwnj"
+ };
+ static const ushort value_table[] = {
+ 0x0061, 0x00c1, ..., 0x200c
+ };
+ int N = sizeof(name_table) / sizeof(name_table[0]);
+
+ const QLatin1String *name = qBinaryFind(name_table, name_table + N,
+ entity);
+ int index = name - name_table;
+ if (index == N)
+ return QChar();
+
+ return QChar(value_table[index]);
+}
+//! [2]
+
+
+//! [3]
+QChar resolveEntity(const QString &entity)
+{
+ static QMap<QString, int> entityMap;
+
+ if (!entityMap) {
+ entityMap.insert("AElig", 0x0061);
+ entityMap.insert("Aacute", 0x00c1);
+ ...
+ entityMap.insert("zwnj", 0x200c);
+ }
+ return QChar(entityMap.value(entity));
+}
+//! [3]
+
+
+//! [4]
+QStringList list;
+list << "one" << "two" << "three";
+
+QVector<QString> vect1(3);
+qCopy(list.begin(), list.end(), vect1.begin());
+// vect: [ "one", "two", "three" ]
+
+QVector<QString> vect2(8);
+qCopy(list.begin(), list.end(), vect2.begin() + 2);
+// vect: [ "", "", "one", "two", "three", "", "", "" ]
+//! [4]
+
+
+//! [5]
+QStringList list;
+list << "one" << "two" << "three";
+
+QVector<QString> vect(5);
+qCopyBackward(list.begin(), list.end(), vect.end());
+// vect: [ "", "", "one", "two", "three" ]
+//! [5]
+
+
+//! [6]
+QStringList list;
+list << "one" << "two" << "three";
+
+QVector<QString> vect(3);
+vect[0] = "one";
+vect[1] = "two";
+vect[2] = "three";
+
+bool ret1 = qEqual(list.begin(), list.end(), vect.begin());
+// ret1 == true
+
+vect[2] = "seven";
+bool ret2 = qEqual(list.begin(), list.end(), vect.begin());
+// ret2 == false
+//! [6]
+
+
+//! [7]
+QStringList list;
+list << "one" << "two" << "three";
+
+qFill(list.begin(), list.end(), "eleven");
+// list: [ "eleven", "eleven", "eleven" ]
+
+qFill(list.begin() + 1, list.end(), "six");
+// list: [ "eleven", "six", "six" ]
+//! [7]
+
+
+//! [8]
+QStringList list;
+list << "one" << "two" << "three";
+
+QStringList::iterator i1 = qFind(list.begin(), list.end(), "two");
+// i1 == list.begin() + 1
+
+QStringList::iterator i2 = qFind(list.begin(), list.end(), "seventy");
+// i2 == list.end()
+//! [8]
+
+
+//! [9]
+QList<int> list;
+list << 3 << 3 << 6 << 6 << 6 << 8;
+
+int countOf6 = 0;
+qCount(list.begin(), list.end(), 6, countOf6);
+// countOf6 == 3
+
+int countOf7 = 0;
+qCount(list.begin(), list.end(), 7, countOf7);
+// countOf7 == 0
+//! [9]
+
+
+//! [10]
+double pi = 3.14;
+double e = 2.71;
+
+qSwap(pi, e);
+// pi == 2.71, e == 3.14
+//! [10]
+
+
+//! [11]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qSort(list.begin(), list.end());
+// list: [ 6, 12, 12, 33, 68 ]
+//! [11]
+
+
+//! [12]
+bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
+{
+ return s1.toLower() < s2.toLower();
+}
+
+int doSomething()
+{
+ QStringList list;
+ list << "AlPha" << "beTA" << "gamma" << "DELTA";
+ qSort(list.begin(), list.end(), caseInsensitiveLessThan);
+ // list: [ "AlPha", "beTA", "DELTA", "gamma" ]
+}
+//! [12]
+
+
+//! [13]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qSort(list.begin(), list.end(), qGreater<int>());
+// list: [ 68, 33, 12, 12, 6 ]
+//! [13]
+
+
+//! [14]
+QStringList list;
+list << "AlPha" << "beTA" << "gamma" << "DELTA";
+
+QMap<QString, QString> map;
+foreach (const QString &str, list)
+ map.insert(str.toLower(), str);
+
+list = map.values();
+//! [14]
+
+
+//! [15]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qStableSort(list.begin(), list.end());
+// list: [ 6, 12, 12, 33, 68 ]
+//! [15]
+
+
+//! [16]
+bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
+{
+ return s1.toLower() < s2.toLower();
+}
+
+int doSomething()
+{
+ QStringList list;
+ list << "AlPha" << "beTA" << "gamma" << "DELTA";
+ qStableSort(list.begin(), list.end(), caseInsensitiveLessThan);
+ // list: [ "AlPha", "beTA", "DELTA", "gamma" ]
+}
+//! [16]
+
+
+//! [17]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qStableSort(list.begin(), list.end(), qGreater<int>());
+// list: [ 68, 33, 12, 12, 6 ]
+//! [17]
+
+
+//! [18]
+QList<int> list;
+list << 3 << 3 << 6 << 6 << 6 << 8;
+
+QList<int>::iterator i = qLowerBound(list.begin(), list.end(), 5);
+list.insert(i, 5);
+// list: [ 3, 3, 5, 6, 6, 6, 8 ]
+
+i = qLowerBound(list.begin(), list.end(), 12);
+list.insert(i, 12);
+// list: [ 3, 3, 5, 6, 6, 6, 8, 12 ]
+//! [18]
+
+
+//! [19]
+QVector<int> vect;
+vect << 3 << 3 << 6 << 6 << 6 << 8;
+QVector<int>::iterator begin6 =
+ qLowerBound(vect.begin(), vect.end(), 6);
+QVector<int>::iterator end6 =
+ qUpperBound(begin6, vect.end(), 6);
+
+QVector<int>::iterator i = begin6;
+while (i != end6) {
+ *i = 7;
+ ++i;
+}
+// vect: [ 3, 3, 7, 7, 7, 8 ]
+//! [19]
+
+
+//! [20]
+QList<int> list;
+list << 3 << 3 << 6 << 6 << 6 << 8;
+
+QList<int>::iterator i = qUpperBound(list.begin(), list.end(), 5);
+list.insert(i, 5);
+// list: [ 3, 3, 5, 6, 6, 6, 8 ]
+
+i = qUpperBound(list.begin(), list.end(), 12);
+list.insert(i, 12);
+// list: [ 3, 3, 5, 6, 6, 6, 8, 12 ]
+//! [20]
+
+
+//! [21]
+QVector<int> vect;
+vect << 3 << 3 << 6 << 6 << 6 << 8;
+QVector<int>::iterator begin6 =
+ qLowerBound(vect.begin(), vect.end(), 6);
+QVector<int>::iterator end6 =
+ qUpperBound(vect.begin(), vect.end(), 6);
+
+QVector<int>::iterator i = begin6;
+while (i != end6) {
+ *i = 7;
+ ++i;
+}
+// vect: [ 3, 3, 7, 7, 7, 8 ]
+//! [21]
+
+
+//! [22]
+QVector<int> vect;
+vect << 3 << 3 << 6 << 6 << 6 << 8;
+
+QVector<int>::iterator i =
+ qBinaryFind(vect.begin(), vect.end(), 6);
+// i == vect.begin() + 2 (or 3 or 4)
+//! [22]
+
+
+//! [23]
+QList<Employee *> list;
+list.append(new Employee("Blackpool", "Stephen"));
+list.append(new Employee("Twist", "Oliver"));
+
+qDeleteAll(list.begin(), list.end());
+list.clear();
+//! [23]
+
+
+//! [24]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qSort(list.begin(), list.end(), qLess<int>());
+// list: [ 6, 12, 12, 33, 68 ]
+//! [24]
+
+
+//! [25]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qSort(list.begin(), list.end(), qGreater<int>());
+// list: [ 68, 33, 12, 12, 6 ]
+//! [25]
diff --git a/src/corelib/doc/snippets/code/doc_src_qcache.cpp b/src/corelib/doc/snippets/code/doc_src_qcache.cpp
new file mode 100644
index 0000000000..0ba9e65531
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qcache.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QCache<int, Employee> cache;
+//! [0]
+
+
+//! [1]
+Employee *employee = new Employee;
+employee->setId(37);
+employee->setName("Richard Schmit");
+...
+cache.insert(employee->id(), employee);
+//! [1]
+
+
+//! [2]
+QCache<int, MyDataStructure> cache(5000);
+//! [2]
diff --git a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
new file mode 100644
index 0000000000..b96f9065cb
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
@@ -0,0 +1,420 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QList<float> list;
+...
+QListIterator<float> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [0]
+
+
+//! [1]
+QListIterator<float> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [1]
+
+
+//! [2]
+QLinkedList<float> list;
+...
+QLinkedListIterator<float> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [2]
+
+
+//! [3]
+QLinkedListIterator<float> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [3]
+
+
+//! [4]
+QVector<float> vector;
+...
+QVectorIterator<float> i(vector);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [4]
+
+
+//! [5]
+QVectorIterator<float> i(vector);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [5]
+
+
+//! [6]
+QSet<QString> set;
+...
+QSetIterator<QString> i(set);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [6]
+
+
+//! [7]
+QSetIterator<QString> i(set);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [7]
+
+
+//! [8]
+QList<float> list;
+...
+QMutableListIterator<float> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [8]
+
+
+//! [9]
+QMutableListIterator<float> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [9]
+
+
+//! [10]
+QMutableListIterator<int> i(list);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < 0) {
+ i.setValue(-val);
+ } else if (val == 0) {
+ i.remove();
+ }
+}
+//! [10]
+
+
+//! [11]
+QLinkedList<float> list;
+...
+QMutableLinkedListIterator<float> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [11]
+
+
+//! [12]
+QMutableLinkedListIterator<float> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [12]
+
+
+//! [13]
+QMutableLinkedListIterator<int> i(list);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < 0) {
+ i.setValue(-val);
+ } else if (val == 0) {
+ i.remove();
+ }
+}
+//! [13]
+
+
+//! [14]
+QVector<float> vector;
+...
+QMutableVectorIterator<float> i(vector);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [14]
+
+
+//! [15]
+QMutableVectorIterator<float> i(vector);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [15]
+
+
+//! [16]
+QMutableVectorIterator<int> i(vector);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < 0) {
+ i.setValue(-val);
+ } else if (val == 0) {
+ i.remove();
+ }
+}
+//! [16]
+
+
+//! [17]
+QSet<float> set;
+...
+QMutableSetIterator<float> i(set);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [17]
+
+
+//! [18]
+QMutableSetIterator<float> i(set);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [18]
+
+
+//! [19]
+QMutableListIterator<int> i(list);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < -32768 || val > 32767)
+ i.remove();
+}
+//! [19]
+
+
+//! [20]
+QMutableLinkedListIterator<int> i(list);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < -32768 || val > 32767)
+ i.remove();
+}
+//! [20]
+
+
+//! [21]
+QMutableVectorIterator<int> i(vector);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < -32768 || val > 32767)
+ i.remove();
+}
+//! [21]
+
+
+//! [22]
+QMutableSetIterator<int> i(set);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < -32768 || val > 32767)
+ i.remove();
+}
+//! [22]
+
+
+//! [23]
+QMutableListIterator<double> i(list);
+while (i.hasNext()) {
+ double val = i.next();
+ i.setValue(sqrt(val));
+}
+//! [23]
+
+
+//! [24]
+QMutableLinkedListIterator<double> i(list);
+while (i.hasNext()) {
+ double val = i.next();
+ i.setValue(sqrt(val));
+}
+//! [24]
+
+
+//! [25]
+QMutableVectorIterator<double> i(list);
+while (i.hasNext()) {
+ double val = i.next();
+ i.setValue(sqrt(val));
+}
+//! [25]
+
+
+//! [26]
+QMap<int, QWidget *> map;
+...
+QMapIterator<int, QWidget *> i(map);
+while (i.hasNext()) {
+ i.next();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [26]
+
+
+//! [27]
+QMapIterator<int, QWidget *> i(map);
+i.toBack();
+while (i.hasPrevious()) {
+ i.previous();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [27]
+
+
+//! [28]
+QMapIterator<int, QWidget *> i(map);
+while (i.findNext(widget)) {
+ qDebug() << "Found widget " << widget << " under key "
+ << i.key();
+}
+//! [28]
+
+
+//! [29]
+QHash<int, QWidget *> hash;
+...
+QHashIterator<int, QWidget *> i(hash);
+while (i.hasNext()) {
+ i.next();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [29]
+
+
+//! [30]
+QHashIterator<int, QWidget *> i(hash);
+i.toBack();
+while (i.hasPrevious()) {
+ i.previous();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [30]
+
+
+//! [31]
+QHashIterator<int, QWidget *> i(hash);
+while (i.findNext(widget)) {
+ qDebug() << "Found widget " << widget << " under key "
+ << i.key();
+}
+//! [31]
+
+
+//! [32]
+QMap<int, QWidget *> map;
+...
+QMutableMapIterator<int, QWidget *> i(map);
+while (i.hasNext()) {
+ i.next();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [32]
+
+
+//! [33]
+QMutableMapIterator<int, QWidget *> i(map);
+i.toBack();
+while (i.hasPrevious()) {
+ i.previous();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [33]
+
+
+//! [34]
+QMutableMapIterator<int, QWidget *> i(map);
+while (i.findNext(widget)) {
+ qDebug() << "Found widget " << widget << " under key "
+ << i.key();
+}
+//! [34]
+
+
+//! [35]
+QMutableMapIterator<QString, QString> i(map);
+while (i.hasNext()) {
+ i.next();
+ if (i.key() == i.value())
+ i.remove();
+}
+//! [35]
+
+
+//! [36]
+QHash<int, QWidget *> hash;
+...
+QMutableHashIterator<QString, QWidget *> i(hash);
+while (i.hasNext()) {
+ i.next();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [36]
+
+
+//! [37]
+QMutableHashIterator<int, QWidget *> i(hash);
+i.toBack();
+while (i.hasPrevious()) {
+ i.previous();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [37]
+
+
+//! [38]
+QMutableHashIterator<int, QWidget *> i(hash);
+while (i.findNext(widget)) {
+ qDebug() << "Found widget " << widget << " under key "
+ << i.key();
+}
+//! [38]
+
+
+//! [39]
+QMutableHashIterator<QString, QString> i(hash);
+while (i.hasNext()) {
+ i.next();
+ if (i.key() == i.value())
+ i.remove();
+}
+//! [39]
diff --git a/src/corelib/doc/snippets/code/doc_src_qnamespace.cpp b/src/corelib/doc/snippets/code/doc_src_qnamespace.cpp
new file mode 100644
index 0000000000..ec80d011c9
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qnamespace.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [1]
+enum CustomEventPriority
+{
+ // An important event
+ ImportantEventPriority = Qt::HighEventPriority,
+
+ // A more important event
+ MoreImportantEventPriority = ImportantEventPriority + 1,
+
+ // A critical event
+ CriticalEventPriority = 100 * MoreImportantEventPriority,
+
+ // Not that important
+ StatusEventPriority = Qt::LowEventPriority,
+
+ // These are less important than Status events
+ IdleProcessingDoneEventPriority = StatusEventPriority - 1
+};
+//! [1]
diff --git a/src/corelib/doc/snippets/code/doc_src_qnamespace.qdoc b/src/corelib/doc/snippets/code/doc_src_qnamespace.qdoc
new file mode 100644
index 0000000000..e67b83a292
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qnamespace.qdoc
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QObject::connect: Cannot queue arguments of type 'MyType'
+//! [0]
diff --git a/src/corelib/doc/snippets/code/doc_src_qpair.cpp b/src/corelib/doc/snippets/code/doc_src_qpair.cpp
new file mode 100644
index 0000000000..a29b6d02b2
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qpair.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QPair<QString, double> pair;
+//! [0]
+
+
+//! [1]
+pair.first = "pi";
+pair.second = 3.14159265358979323846;
+//! [1]
+
+
+//! [2]
+QList<QPair<int, double> > list;
+list.append(qMakePair(66, 3.14159));
+//! [2]
diff --git a/src/corelib/doc/snippets/code/doc_src_qplugin.cpp b/src/corelib/doc/snippets/code/doc_src_qplugin.cpp
new file mode 100644
index 0000000000..1577b2fa61
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qplugin.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+namespace Foo
+{
+ struct MyInterface { ... };
+}
+
+Q_DECLARE_INTERFACE(Foo::MyInterface, "org.examples.MyInterface")
+//! [0]
+
+
+//! [1]
+Q_EXPORT_PLUGIN2(pnp_extrafilters, ExtraFiltersPlugin)
+//! [1]
+
+
+//! [2]
+Q_IMPORT_PLUGIN(qjpeg)
+//! [2]
+
+
+//! [3]
+TEMPLATE = app
+QTPLUGIN += qjpeg qgif # image formats
+//! [3]
diff --git a/src/corelib/doc/snippets/code/doc_src_qplugin.pro b/src/corelib/doc/snippets/code/doc_src_qplugin.pro
new file mode 100644
index 0000000000..52fb9e3163
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qplugin.pro
@@ -0,0 +1,4 @@
+#! [3]
+TEMPLATE = app
+QTPLUGIN += qjpeg qgif # image formats
+#! [3]
diff --git a/src/corelib/doc/snippets/code/doc_src_qset.cpp b/src/corelib/doc/snippets/code/doc_src_qset.cpp
new file mode 100644
index 0000000000..cfd366f639
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qset.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QSet<QString> set;
+//! [0]
+
+
+//! [1]
+set.insert("one");
+set.insert("three");
+set.insert("seven");
+//! [1]
+
+
+//! [2]
+set << "twelve" << "fifteen" << "nineteen";
+//! [2]
+
+
+//! [3]
+if (!set.contains("ninety-nine"))
+ ...
+//! [3]
+
+
+//! [4]
+QSetIterator<QWidget *> i(set);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [4]
+
+
+//! [5]
+QSet<QWidget *>::const_iterator i = set.constBegin();
+while (i != set.constEnd()) {
+ qDebug() << *i;
+ ++i;
+}
+//! [5]
+
+
+//! [6]
+QSet<QString> set;
+...
+foreach (const QString &value, set)
+ qDebug() << value;
+//! [6]
+
+
+//! [7]
+QSet<QString> set;
+set.reserve(20000);
+for (int i = 0; i < 20000; ++i)
+ set.insert(values[i]);
+//! [7]
+
+
+//! [8]
+QSet<QString> set;
+set << "January" << "February" << ... << "December";
+
+QSet<QString>::iterator i;
+for (i = set.begin(); i != set.end(); ++i)
+ qDebug() << *i;
+//! [8]
+
+
+//! [9]
+QSet<QString> set;
+set << "January" << "February" << ... << "December";
+
+QSet<QString>::iterator i = set.begin();
+while (i != set.end()) {
+ if ((*i).startsWith('J')) {
+ i = set.erase(i);
+ } else {
+ ++i;
+ }
+}
+//! [9]
+
+
+//! [10]
+QSet<QString> set;
+...
+QSet<QString>::iterator it = qFind(set.begin(), set.end(), "Jeanette");
+if (it != set.end())
+ cout << "Found Jeanette" << endl;
+//! [10]
+
+
+//! [11]
+QSet<QString> set;
+set << "January" << "February" << ... << "December";
+
+QSet<QString>::const_iterator i;
+for (i = set.begin(); i != set.end(); ++i)
+ qDebug() << *i;
+//! [11]
+
+
+//! [12]
+QSet<QString> set;
+...
+QSet<QString>::iterator it = qFind(set.begin(), set.end(), "Jeanette");
+if (it != set.constEnd())
+ cout << "Found Jeanette" << endl;
+//! [12]
+
+
+//! [13]
+QSet<QString> set;
+set << "red" << "green" << "blue" << ... << "black";
+
+QList<QString> list = set.toList();
+qSort(list);
+//! [13]
+
+
+//! [14]
+QStringList list;
+list << "Julia" << "Mike" << "Mike" << "Julia" << "Julia";
+
+QSet<QString> set = QSet<QString>::fromList(list);
+set.contains("Julia"); // returns true
+set.contains("Mike"); // returns true
+set.size(); // returns 2
+//! [14]
diff --git a/src/corelib/doc/snippets/code/doc_src_qtcore.cpp b/src/corelib/doc/snippets/code/doc_src_qtcore.cpp
new file mode 100644
index 0000000000..f00c96c6df
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qtcore.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include <QtCore>
+//! [0]
diff --git a/src/corelib/doc/snippets/code/doc_src_qvarlengtharray.cpp b/src/corelib/doc/snippets/code/doc_src_qvarlengtharray.cpp
new file mode 100644
index 0000000000..027faa41dc
--- /dev/null
+++ b/src/corelib/doc/snippets/code/doc_src_qvarlengtharray.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+int myfunc(int n)
+{
+ int table[n + 1]; // WRONG
+ ...
+ return table[n];
+}
+//! [0]
+
+
+//! [1]
+int myfunc(int n)
+{
+ int *table = new int[n + 1];
+ ...
+ int ret = table[n];
+ delete[] table;
+ return ret;
+}
+//! [1]
+
+
+//! [2]
+int myfunc(int n)
+{
+ QVarLengthArray<int, 1024> array(n + 1);
+ ...
+ return array[n];
+}
+//! [2]
+
+
+//! [3]
+QVarLengthArray<int> array(10);
+int *data = array.data();
+for (int i = 0; i < 10; ++i)
+ data[i] = 2 * i;
+//! [3]
diff --git a/src/corelib/doc/snippets/code/qlogging/qlogging.cpp b/src/corelib/doc/snippets/code/qlogging/qlogging.cpp
new file mode 100644
index 0000000000..74892cdfba
--- /dev/null
+++ b/src/corelib/doc/snippets/code/qlogging/qlogging.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtDebug>
+#include <QDeclarativeComponent>
+
+//! [1]
+ void statusChanged(QDeclarativeComponent::Status status) {
+ if (status == QDeclarativeComponent::Error) {
+ foreach (const QDeclarativeError &error, component->errors()) {
+ const QByteArray file = error.url().toEncoded();
+ QMessageLogger(file.constData(), error.line(), 0).debug() << error.description();
+ }
+ }
+ }
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_codecs_qtextcodec.cpp b/src/corelib/doc/snippets/code/src_corelib_codecs_qtextcodec.cpp
new file mode 100644
index 0000000000..78abd5ba28
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_codecs_qtextcodec.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QByteArray encodedString = "...";
+QTextCodec *codec = QTextCodec::codecForName("KOI8-R");
+QString string = codec->toUnicode(encodedString);
+//! [0]
+
+
+//! [1]
+QString string = "...";
+QTextCodec *codec = QTextCodec::codecForName("KOI8-R");
+QByteArray encodedString = codec->fromUnicode(string);
+//! [1]
+
+
+//! [2]
+QTextCodec *codec = QTextCodec::codecForName("Shift-JIS");
+QTextDecoder *decoder = codec->makeDecoder();
+
+QString string;
+while (new_data_available()) {
+ QByteArray chunk = get_new_data();
+ string += decoder->toUnicode(chunk);
+}
+delete decoder;
+//! [2]
+
+
+//! [3]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextCodec::setCodecForTr(QTextCodec::codecForName("eucKR"));
+ ...
+}
+//! [3]
diff --git a/src/corelib/doc/snippets/code/src_corelib_concurrent_qthreadpool.cpp b/src/corelib/doc/snippets/code/src_corelib_concurrent_qthreadpool.cpp
new file mode 100644
index 0000000000..a8f9da3a7c
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_concurrent_qthreadpool.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class HelloWorldTask : public QRunnable
+{
+ void run()
+ {
+ qDebug() << "Hello world from thread" << QThread::currentThread();
+ }
+}
+
+HelloWorldTask *hello = new HelloWorldTask();
+// QThreadPool takes ownership and deletes 'hello' automatically
+QThreadPool::globalInstance()->start(hello);
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
new file mode 100644
index 0000000000..dc6c3aa616
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -0,0 +1,586 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
+//! [0]
+
+
+//! [1]
+class MyClass
+{
+public:
+ enum Option {
+ NoOptions = 0x0,
+ ShowTabs = 0x1,
+ ShowAll = 0x2,
+ SqueezeBlank = 0x4
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+ ...
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyClass::Options)
+//! [1]
+
+//! [meta-object flags]
+Q_FLAGS(Options)
+//! [meta-object flags]
+
+//! [2]
+typedef QFlags<Enum> Flags;
+//! [2]
+
+
+//! [3]
+int myValue = 10;
+int minValue = 2;
+int maxValue = 6;
+
+int boundedValue = qBound(minValue, myValue, maxValue);
+// boundedValue == 6
+//! [3]
+
+
+//! [4]
+if (!driver()->isOpen() || driver()->isOpenError()) {
+ qWarning("QSqlQuery::exec: database not open");
+ return false;
+}
+//! [4]
+
+
+//! [5]
+qint64 value = Q_INT64_C(932838457459459);
+//! [5]
+
+
+//! [6]
+quint64 value = Q_UINT64_C(932838457459459);
+//! [6]
+
+
+//! [7]
+void myMsgHandler(QtMsgType, const char *);
+//! [7]
+
+
+//! [8]
+qint64 value = Q_INT64_C(932838457459459);
+//! [8]
+
+
+//! [9]
+quint64 value = Q_UINT64_C(932838457459459);
+//! [9]
+
+
+//! [10]
+int absoluteValue;
+int myValue = -4;
+
+absoluteValue = qAbs(myValue);
+// absoluteValue == 4
+//! [10]
+
+
+//! [11]
+qreal valueA = 2.3;
+qreal valueB = 2.7;
+
+int roundedValueA = qRound(valueA);
+// roundedValueA = 2
+int roundedValueB = qRound(valueB);
+// roundedValueB = 3
+//! [11]
+
+
+//! [12]
+qreal valueA = 42949672960.3;
+qreal valueB = 42949672960.7;
+
+int roundedValueA = qRound(valueA);
+// roundedValueA = 42949672960
+int roundedValueB = qRound(valueB);
+// roundedValueB = 42949672961
+//! [12]
+
+
+//! [13]
+int myValue = 6;
+int yourValue = 4;
+
+int minValue = qMin(myValue, yourValue);
+// minValue == yourValue
+//! [13]
+
+
+//! [14]
+int myValue = 6;
+int yourValue = 4;
+
+int maxValue = qMax(myValue, yourValue);
+// maxValue == myValue
+//! [14]
+
+
+//! [15]
+int myValue = 10;
+int minValue = 2;
+int maxValue = 6;
+
+int boundedValue = qBound(minValue, myValue, maxValue);
+// boundedValue == 6
+//! [15]
+
+
+//! [16]
+#if QT_VERSION >= 0x040100
+ QIcon icon = style()->standardIcon(QStyle::SP_TrashIcon);
+#else
+ QPixmap pixmap = style()->standardPixmap(QStyle::SP_TrashIcon);
+ QIcon icon(pixmap);
+#endif
+//! [16]
+
+
+//! [17]
+// File: div.cpp
+
+#include <QtGlobal>
+
+int divide(int a, int b)
+{
+ Q_ASSERT(b != 0);
+ return a / b;
+}
+//! [17]
+
+
+//! [18]
+ASSERT: "b == 0" in file div.cpp, line 7
+//! [18]
+
+
+//! [19]
+// File: div.cpp
+
+#include <QtGlobal>
+
+int divide(int a, int b)
+{
+ Q_ASSERT_X(b != 0, "divide", "division by zero");
+ return a / b;
+}
+//! [19]
+
+
+//! [20]
+ASSERT failure in divide: "division by zero", file div.cpp, line 7
+//! [20]
+
+
+//! [21]
+int *a;
+
+Q_CHECK_PTR(a = new int[80]); // WRONG!
+
+a = new (nothrow) int[80]; // Right
+Q_CHECK_PTR(a);
+//! [21]
+
+
+//! [22]
+template<typename TInputType>
+const TInputType &myMin(const TInputType &value1, const TInputType &value2)
+{
+ qDebug() << Q_FUNC_INFO << "was called with value1:" << value1 << "value2:" << value2;
+
+ if(value1 < value2)
+ return value1;
+ else
+ return value2;
+}
+//! [22]
+
+
+//! [23]
+#include <qapplication.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+ QByteArray localMsg = msg.toLocal8Bit();
+ switch (type) {
+ case QtDebugMsg:
+ fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
+ break;
+ case QtWarningMsg:
+ fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
+ break;
+ case QtCriticalMsg:
+ fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
+ break;
+ case QtFatalMsg:
+ fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
+ abort();
+ }
+}
+
+int main(int argc, char **argv)
+{
+ qInstallMessageHandler(myMessageOutput);
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [23]
+
+
+//! [24]
+qDebug("Items in list: %d", myList.size());
+//! [24]
+
+
+//! [25]
+qDebug() << "Brush:" << myQBrush << "Other value:" << i;
+//! [25]
+
+
+//! [26]
+void f(int c)
+{
+ if (c > 200)
+ qWarning("f: bad argument, c == %d", c);
+}
+//! [26]
+
+
+//! [27]
+qWarning() << "Brush:" << myQBrush << "Other value:"
+<< i;
+//! [27]
+
+
+//! [28]
+void load(const QString &fileName)
+{
+ QFile file(fileName);
+ if (!file.exists())
+ qCritical("File '%s' does not exist!", qPrintable(fileName));
+}
+//! [28]
+
+
+//! [29]
+qCritical() << "Brush:" << myQBrush << "Other
+value:" << i;
+//! [29]
+
+
+//! [30]
+int divide(int a, int b)
+{
+ if (b == 0) // program error
+ qFatal("divide: cannot divide by zero");
+ return a / b;
+}
+//! [30]
+
+
+//! [31]
+forever {
+ ...
+}
+//! [31]
+
+
+//! [32]
+CONFIG += no_keywords
+//! [32]
+
+
+//! [33]
+CONFIG += no_keywords
+//! [33]
+
+
+//! [34]
+QString FriendlyConversation::greeting(int type)
+{
+static const char *greeting_strings[] = {
+ QT_TR_NOOP("Hello"),
+ QT_TR_NOOP("Goodbye")
+};
+return tr(greeting_strings[type]);
+}
+//! [34]
+
+
+//! [35]
+static const char *greeting_strings[] = {
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"),
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye")
+};
+
+QString FriendlyConversation::greeting(int type)
+{
+ return tr(greeting_strings[type]);
+}
+
+QString global_greeting(int type)
+{
+ return qApp->translate("FriendlyConversation",
+ greeting_strings[type]);
+}
+//! [35]
+
+
+//! [36]
+
+static { const char *source; const char *comment; } greeting_strings[] =
+{
+ QT_TRANSLATE_NOOP3("FriendlyConversation", "Hello",
+ "A really friendly hello"),
+ QT_TRANSLATE_NOOP3("FriendlyConversation", "Goodbye",
+ "A really friendly goodbye")
+};
+
+QString FriendlyConversation::greeting(int type)
+{
+ return tr(greeting_strings[type].source,
+ greeting_strings[type].comment);
+}
+
+QString global_greeting(int type)
+{
+ return qApp->translate("FriendlyConversation",
+ greeting_strings[type].source,
+ greeting_strings[type].comment);
+}
+//! [36]
+
+
+//! [qttrid]
+ //% "%n fooish bar(s) found.\n"
+ //% "Do you want to continue?"
+ QString text = qtTrId("qtn_foo_bar", n);
+//! [qttrid]
+
+
+//! [qttrid_noop]
+static const char * const ids[] = {
+ //% "This is the first text."
+ QT_TRID_NOOP("qtn_1st_text"),
+ //% "This is the second text."
+ QT_TRID_NOOP("qtn_2nd_text"),
+ 0
+};
+
+void TheClass::addLabels()
+{
+ for (int i = 0; ids[i]; ++i)
+ new QLabel(qtTrId(ids[i]), this);
+}
+//! [qttrid_noop]
+
+
+//! [37]
+qWarning("%s: %s", qPrintable(key), qPrintable(value));
+//! [37]
+
+
+//! [38]
+struct Point2D
+{
+ int x;
+ int y;
+};
+
+Q_DECLARE_TYPEINFO(Point2D, Q_PRIMITIVE_TYPE);
+//! [38]
+
+
+//! [39]
+class Point2D
+{
+public:
+ Point2D() { data = new int[2]; }
+ Point2D(const Point2D &other) { ... }
+ ~Point2D() { delete[] data; }
+
+ Point2D &operator=(const Point2D &other) { ... }
+
+ int x() const { return data[0]; }
+ int y() const { return data[1]; }
+
+private:
+ int *data;
+};
+
+Q_DECLARE_TYPEINFO(Point2D, Q_MOVABLE_TYPE);
+//! [39]
+
+
+//! [40]
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+...
+#endif
+
+or
+
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+...
+#endif
+
+//! [40]
+
+
+//! [41]
+
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+...
+#endif
+
+//! [41]
+
+
+//! [42]
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+...
+#endif
+
+//! [42]
+
+//! [begin namespace macro]
+namespace QT_NAMESPACE {
+//! [begin namespace macro]
+
+//! [end namespace macro]
+}
+//! [end namespace macro]
+
+//! [43]
+class MyClass : public QObject
+{
+
+ private:
+ Q_DISABLE_COPY(MyClass)
+};
+
+//! [43]
+
+//! [44]
+class MyClass : public QObject
+{
+
+ private:
+ MyClass(const MyClass &);
+ MyClass &operator=(const MyClass &);
+};
+//! [44]
+
+//! [45]
+ QWidget w = QWidget();
+//! [45]
+
+//! [46]
+ // Instead of comparing with 0.0
+ qFuzzyCompare(0.0,1.0e-200); // This will return false
+ // Compare adding 1 to both values will fix the problem
+ qFuzzyCompare(1 + 0.0, 1 + 1.0e-200); // This will return true
+//! [46]
+
+//! [47]
+CApaApplication *myApplicationFactory();
+//! [47]
+
+
+//! [49]
+void myMessageHandler(QtMsgType, const QMessageLogContext &, const char *);
+//! [49]
+
+//! [qlikely]
+ // the condition inside the "if" will be successful most of the times
+ for (int i = 1; i <= 365; i++) {
+ if (Q_LIKELY(isWorkingDay(i))) {
+ ...
+ }
+ ...
+ }
+//! [qlikely]
+
+//! [qunlikely]
+bool readConfiguration(const QFile &file)
+{
+ // We expect to be asked to read an existing file
+ if (Q_UNLIKELY(!file.exists())) {
+ qWarning() << "File not found";
+ return false;
+ }
+
+ ...
+ return true;
+}
+//! [qunlikely]
+
+//! [qunreachable-enum]
+ enum Shapes {
+ Rectangle,
+ Triangle,
+ Circle,
+ NumShapes
+ };
+//! [qunreachable-enum]
+
+//! [qunreachable-switch]
+ switch (shape) {
+ case Rectangle:
+ return rectangle();
+ case Triangle:
+ return triangle();
+ case Circle:
+ return circle();
+ case NumShapes:
+ Q_UNREACHABLE();
+ break;
+ }
+//! [qunreachable-switch]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qabstractfileengine.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qabstractfileengine.cpp
new file mode 100644
index 0000000000..8893fbd08c
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qabstractfileengine.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class ZipEngineHandler : public QAbstractFileEngineHandler
+{
+public:
+ QAbstractFileEngine *create(const QString &fileName) const;
+};
+
+QAbstractFileEngine *ZipEngineHandler::create(const QString &fileName) const
+{
+ // ZipEngineHandler returns a ZipEngine for all .zip files
+ return fileName.toLower().endsWith(".zip") ? new ZipEngine(fileName) : 0;
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ ZipEngineHandler engine;
+
+ MainWindow window;
+ window.show();
+
+ return app.exec();
+}
+//! [0]
+
+
+//! [1]
+QAbstractSocketEngine *ZipEngineHandler::create(const QString &fileName) const
+{
+ // ZipEngineHandler returns a ZipEngine for all .zip files
+ return fileName.toLower().endsWith(".zip") ? new ZipEngine(fileName) : 0;
+}
+//! [1]
+
+
+//! [2]
+QAbstractFileEngineIterator *
+CustomFileEngine::beginEntryList(QDir::Filters filters, const QStringList &filterNames)
+{
+ return new CustomFileEngineIterator(filters, filterNames);
+}
+//! [2]
+
+
+//! [3]
+class CustomIterator : public QAbstractFileEngineIterator
+{
+public:
+ CustomIterator(const QStringList &nameFilters, QDir::Filters filters)
+ : QAbstractFileEngineIterator(nameFilters, filters), index(0)
+ {
+ // In a real iterator, these entries are fetched from the
+ // file system based on the value of path().
+ entries << "entry1" << "entry2" << "entry3";
+ }
+
+ bool hasNext() const
+ {
+ return index < entries.size() - 1;
+ }
+
+ QString next()
+ {
+ if (!hasNext())
+ return QString();
+ ++index;
+ return currentFilePath();
+ }
+
+ QString currentFileName()
+ {
+ return entries.at(index);
+ }
+
+private:
+ QStringList entries;
+ int index;
+};
+//! [3]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qdatastream.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qdatastream.cpp
new file mode 100644
index 0000000000..af2d7d24bf
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qdatastream.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+void wrapInFunction()
+{
+
+//! [0]
+QFile file("file.dat");
+file.open(QIODevice::WriteOnly);
+QDataStream out(&file); // we will serialize the data into the file
+out << QString("the answer is"); // serialize a string
+out << (qint32)42; // serialize an integer
+//! [0]
+
+
+//! [1]
+QFile file("file.dat");
+file.open(QIODevice::ReadOnly);
+QDataStream in(&file); // read the data serialized from the file
+QString str;
+qint32 a;
+in >> str >> a; // extract "the answer is" and 42
+//! [1]
+
+
+//! [2]
+stream.setVersion(QDataStream::Qt_4_0);
+//! [2]
+
+
+//! [3]
+QFile file("file.xxx");
+file.open(QIODevice::WriteOnly);
+QDataStream out(&file);
+
+// Write a header with a "magic number" and a version
+out << (quint32)0xA0B0C0D0;
+out << (qint32)123;
+
+out.setVersion(QDataStream::Qt_4_0);
+
+// Write the data
+out << lots_of_interesting_data;
+//! [3]
+
+
+//! [4]
+QFile file("file.xxx");
+file.open(QIODevice::ReadOnly);
+QDataStream in(&file);
+
+// Read and check the header
+quint32 magic;
+in >> magic;
+if (magic != 0xA0B0C0D0)
+ return XXX_BAD_FILE_FORMAT;
+
+// Read the version
+qint32 version;
+in >> version;
+if (version < 100)
+ return XXX_BAD_FILE_TOO_OLD;
+if (version > 123)
+ return XXX_BAD_FILE_TOO_NEW;
+
+if (version <= 110)
+ in.setVersion(QDataStream::Qt_3_2);
+else
+ in.setVersion(QDataStream::Qt_4_0);
+
+// Read the data
+in >> lots_of_interesting_data;
+if (version >= 120)
+ in >> data_new_in_XXX_version_1_2;
+in >> other_interesting_data;
+//! [4]
+
+
+//! [5]
+QDataStream out(file);
+out.setVersion(QDataStream::Qt_4_0);
+//! [5]
+
+}
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qdir.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qdir.cpp
new file mode 100644
index 0000000000..3c333e5642
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qdir.cpp
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+QDir("/home/user/Documents")
+QDir("C:/Documents and Settings")
+//! [0]
+
+
+//! [1]
+QDir("images/landscape.png")
+//! [1]
+
+
+//! [2]
+QDir("Documents/Letters/Applications").dirName() // "Applications"
+QDir().dirName() // "."
+//! [2]
+
+
+//! [3]
+QDir directory("Documents/Letters");
+QString path = directory.filePath("contents.txt");
+QString absolutePath = directory.absoluteFilePath("contents.txt");
+//! [3]
+
+
+//! [4]
+QDir dir("example");
+if (!dir.exists())
+ qWarning("Cannot find the example directory");
+//! [4]
+
+
+//! [5]
+QDir dir = QDir::root(); // "/"
+if (!dir.cd("tmp")) { // "/tmp"
+ qWarning("Cannot find the \"/tmp\" directory");
+} else {
+ QFile file(dir.filePath("ex1.txt")); // "/tmp/ex1.txt"
+ if (!file.open(QIODevice::ReadWrite))
+ qWarning("Cannot create the file %s", file.name());
+}
+//! [5]
+
+
+//! [6]
+QString bin = "/local/bin"; // where /local/bin is a symlink to /usr/bin
+QDir binDir(bin);
+QString canonicalBin = binDir.canonicalPath();
+// canonicalBin now equals "/usr/bin"
+
+QString ls = "/local/bin/ls"; // where ls is the executable "ls"
+QDir lsDir(ls);
+QString canonicalLs = lsDir.canonicalPath();
+// canonicalLS now equals "/usr/bin/ls".
+//! [6]
+
+
+//! [7]
+QDir dir("/home/bob");
+QString s;
+
+s = dir.relativeFilePath("images/file.jpg"); // s is "images/file.jpg"
+s = dir.relativeFilePath("/home/mary/file.txt"); // s is "../mary/file.txt"
+//! [7]
+
+
+//! [8]
+QDir::setSearchPaths("icons", QStringList(QDir::homePath() + "/images"));
+QDir::setSearchPaths("docs", QStringList(":/embeddedDocuments"));
+...
+QPixmap pixmap("icons:undo.png"); // will look for undo.png in QDir::homePath() + "/images"
+QFile file("docs:design.odf"); // will look in the :/embeddedDocuments resource path
+//! [8]
+
+
+//! [9]
+QDir dir("/tmp/root_link");
+dir = dir.canonicalPath();
+if (dir.isRoot())
+ qWarning("It is a root link");
+//! [9]
+
+
+//! [10]
+// The current directory is "/usr/local"
+QDir d1("/usr/local/bin");
+QDir d2("bin");
+if (d1 == d2)
+ qDebug("They're the same");
+//! [10]
+
+
+//! [11]
+// The current directory is "/usr/local"
+QDir d1("/usr/local/bin");
+d1.setFilter(QDir::Executable);
+QDir d2("bin");
+if (d1 != d2)
+ qDebug("They differ");
+//! [11]
+
+
+//! [12]
+C:/Documents and Settings/Username
+//! [12]
+
+
+//! [13]
+Q_INIT_RESOURCE(myapp);
+//! [13]
+
+
+//! [14]
+inline void initMyResource() { Q_INIT_RESOURCE(myapp); }
+
+namespace MyNamespace
+{
+ ...
+
+ void myFunction()
+ {
+ initMyResource();
+ }
+}
+//! [14]
+
+
+//! [15]
+Q_CLEANUP_RESOURCE(myapp);
+//! [15]
+
+}
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qdiriterator.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qdiriterator.cpp
new file mode 100644
index 0000000000..bf38bb1627
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qdiriterator.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QDirIterator it("/etc", QDirIterator::Subdirectories);
+while (it.hasNext()) {
+ qDebug() << it.next();
+
+ // /etc/.
+ // /etc/..
+ // /etc/X11
+ // /etc/X11/fs
+ // ...
+}
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qfile.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qfile.cpp
new file mode 100644
index 0000000000..7ad24b30f1
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qfile.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QFile file;
+QDir::setCurrent("/tmp");
+file.setFileName("readme.txt");
+QDir::setCurrent("/home");
+file.open(QIODevice::ReadOnly); // opens "/home/readme.txt" under Unix
+//! [0]
+
+
+//! [1]
+QByteArray myEncoderFunc(const QString &fileName);
+//! [1]
+
+
+//! [2]
+QString myDecoderFunc(const QByteArray &localFileName);
+//! [2]
+
+
+//! [3]
+#include <stdio.h>
+
+void printError(const char* msg)
+{
+ QFile file;
+ file.open(stderr, QIODevice::WriteOnly);
+ file.write(msg, qstrlen(msg)); // write to stderr
+ file.close();
+}
+//! [3]
+
+
+//! [4]
+CONFIG += console
+//! [4]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qfileinfo.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qfileinfo.cpp
new file mode 100644
index 0000000000..f565786934
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qfileinfo.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+//![newstuff]
+ QFileInfo fi("c:/temp/foo"); => fi.absoluteFilePath() => "C:/temp/foo"
+//![newstuff]
+
+//! [0]
+#ifdef Q_OS_UNIX
+
+QFileInfo info1("/home/bob/bin/untabify");
+info1.isSymLink(); // returns true
+info1.absoluteFilePath(); // returns "/home/bob/bin/untabify"
+info1.size(); // returns 56201
+info1.symLinkTarget(); // returns "/opt/pretty++/bin/untabify"
+
+QFileInfo info2(info1.symLinkTarget());
+info2.isSymLink(); // returns false
+info2.absoluteFilePath(); // returns "/opt/pretty++/bin/untabify"
+info2.size(); // returns 56201
+
+#endif
+//! [0]
+
+
+//! [1]
+#ifdef Q_OS_WIN
+
+QFileInfo info1("C:\\Documents and Settings\\Bob\\untabify.lnk");
+info1.isSymLink(); // returns true
+info1.absoluteFilePath(); // returns "C:/Documents and Settings/Bob/untabify.lnk"
+info1.size(); // returns 743
+info1.symLinkTarget(); // returns "C:/Pretty++/untabify"
+
+QFileInfo info2(info1.symLinkTarget());
+info2.isSymLink(); // returns false
+info2.absoluteFilePath(); // returns "C:/Pretty++/untabify"
+info2.size(); // returns 63942
+
+#endif
+//! [1]
+
+
+//! [2]
+QString absolute = "/local/bin";
+QString relative = "local/bin";
+QFileInfo absFile(absolute);
+QFileInfo relFile(relative);
+
+QDir::setCurrent(QDir::rootPath());
+// absFile and relFile now point to the same file
+
+QDir::setCurrent("/tmp");
+// absFile now points to "/local/bin",
+// while relFile points to "/tmp/local/bin"
+//! [2]
+
+
+//! [3]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString name = fi.fileName(); // name = "archive.tar.gz"
+//! [3]
+
+
+//! [4]
+QFileInfo fi("/Applications/Safari.app");
+QString bundle = fi.bundleName(); // name = "Safari"
+//! [4]
+
+
+//! [5]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString base = fi.baseName(); // base = "archive"
+//! [5]
+
+
+//! [6]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString base = fi.completeBaseName(); // base = "archive.tar"
+//! [6]
+
+
+//! [7]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString ext = fi.completeSuffix(); // ext = "tar.gz"
+//! [7]
+
+
+//! [8]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString ext = fi.suffix(); // ext = "gz"
+//! [8]
+
+
+//! [9]
+QFileInfo info(fileName);
+if (info.isSymLink())
+ fileName = info.symLinkTarget();
+//! [9]
+
+
+//! [10]
+QFileInfo fi("/tmp/archive.tar.gz");
+if (fi.permission(QFile::WriteUser | QFile::ReadGroup))
+ qWarning("I can change the file; my group can read the file");
+if (fi.permission(QFile::WriteGroup | QFile::WriteOther))
+ qWarning("The group or others can change the file");
+//! [10]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qiodevice.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qiodevice.cpp
new file mode 100644
index 0000000000..6018a21f89
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qiodevice.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QProcess gzip;
+gzip.start("gzip", QStringList() << "-c");
+if (!gzip.waitForStarted())
+ return false;
+
+gzip.write("uncompressed data");
+
+QByteArray compressed;
+while (gzip.waitForReadyRead())
+ compressed += gzip.readAll();
+//! [0]
+
+
+//! [1]
+qint64 CustomDevice::bytesAvailable() const
+{
+ return buffer.size() + QIODevice::bytesAvailable();
+}
+//! [1]
+
+
+//! [2]
+QFile file("box.txt");
+if (file.open(QFile::ReadOnly)) {
+ char buf[1024];
+ qint64 lineLength = file.readLine(buf, sizeof(buf));
+ if (lineLength != -1) {
+ // the line is available in buf
+ }
+}
+//! [2]
+
+
+//! [3]
+bool CustomDevice::canReadLine() const
+{
+ return buffer.contains('\n') || QIODevice::canReadLine();
+}
+//! [3]
+
+
+//! [4]
+bool isExeFile(QFile *file)
+{
+ char buf[2];
+ if (file->peek(buf, sizeof(buf)) == sizeof(buf))
+ return (buf[0] == 'M' && buf[1] == 'Z');
+ return false;
+}
+//! [4]
+
+
+//! [5]
+bool isExeFile(QFile *file)
+{
+ return file->peek(2) == "MZ";
+}
+//! [5]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qprocess.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qprocess.cpp
new file mode 100644
index 0000000000..16878f41e1
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qprocess.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+QProcess builder;
+builder.setProcessChannelMode(QProcess::MergedChannels);
+builder.start("make", QStringList() << "-j2");
+
+if (!builder.waitForFinished())
+ qDebug() << "Make failed:" << builder.errorString();
+else
+ qDebug() << "Make output:" << builder.readAll();
+//! [0]
+
+
+//! [1]
+QProcess more;
+more.start("more");
+more.write("Text to display");
+more.closeWriteChannel();
+// QProcess will emit readyRead() once "more" starts printing
+//! [1]
+
+
+//! [2]
+command1 | command2
+//! [2]
+
+
+//! [3]
+QProcess process1;
+QProcess process2;
+
+process1.setStandardOutputProcess(&process2);
+
+process1.start("command1");
+process2.start("command2");
+//! [3]
+
+
+//! [4]
+class SandboxProcess : public QProcess
+{
+ ...
+ protected:
+ void setupChildProcess();
+ ...
+};
+
+void SandboxProcess::setupChildProcess()
+{
+ // Drop all privileges in the child process, and enter
+ // a chroot jail.
+#if defined Q_OS_UNIX
+ ::setgroups(0, 0);
+ ::chroot("/etc/safe");
+ ::chdir("/");
+ ::setgid(safeGid);
+ ::setuid(safeUid);
+ ::umask(0);
+#endif
+}
+
+//! [4]
+
+
+//! [5]
+QProcess process;
+process.start("del /s *.txt");
+// same as process.start("del", QStringList() << "/s" << "*.txt");
+...
+//! [5]
+
+
+//! [6]
+QProcess process;
+process.start("dir \"My Documents\"");
+//! [6]
+
+
+//! [7]
+QProcess process;
+process.start("dir \"\"\"My Documents\"\"\"");
+//! [7]
+
+
+//! [8]
+QStringList environment = QProcess::systemEnvironment();
+// environment = {"PATH=/usr/bin:/usr/local/bin",
+// "USER=greg", "HOME=/home/greg"}
+//! [8]
+
+}
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qsettings.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qsettings.cpp
new file mode 100644
index 0000000000..c9ce7561ff
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qsettings.cpp
@@ -0,0 +1,316 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QSettings settings("MySoft", "Star Runner");
+QColor color = settings.value("DataPump/bgcolor").value<QColor>();
+//! [0]
+
+
+//! [1]
+QSettings settings("MySoft", "Star Runner");
+QColor color = palette().background().color();
+settings.setValue("DataPump/bgcolor", color);
+//! [1]
+
+
+//! [2]
+QSettings settings("/home/petra/misc/myapp.ini",
+ QSettings::IniFormat);
+//! [2]
+
+
+//! [3]
+QSettings settings("/Users/petra/misc/myapp.plist",
+ QSettings::NativeFormat);
+//! [3]
+
+
+//! [4]
+QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Office",
+ QSettings::NativeFormat);
+//! [4]
+
+
+//! [5]
+settings.setValue("11.0/Outlook/Security/DontTrustInstalledFiles", 0);
+//! [5]
+
+
+//! [6]
+settings.setValue("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy", "Milkyway");
+settings.setValue("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Sun", "OurStar");
+settings.value("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Default"); // returns "Milkyway"
+//! [6]
+
+
+//! [7]
+#ifdef Q_WS_MAC
+ QSettings settings("grenoullelogique.fr", "Squash");
+#else
+ QSettings settings("Grenoulle Logique", "Squash");
+#endif
+//! [7]
+
+
+//! [8]
+pos = @Point(100 100)
+//! [8]
+
+
+//! [9]
+windir = C:\Windows
+//! [9]
+
+
+//! [10]
+QSettings settings("Moose Tech", "Facturo-Pro");
+//! [10]
+
+
+//! [11]
+QSettings settings("Moose Soft", "Facturo-Pro");
+//! [11]
+
+
+//! [12]
+QCoreApplication::setOrganizationName("Moose Soft");
+QCoreApplication::setApplicationName("Facturo-Pro");
+QSettings settings;
+//! [12]
+
+
+//! [13]
+settings.beginGroup("mainwindow");
+settings.setValue("size", win->size());
+settings.setValue("fullScreen", win->isFullScreen());
+settings.endGroup();
+
+settings.beginGroup("outputpanel");
+settings.setValue("visible", panel->isVisible());
+settings.endGroup();
+//! [13]
+
+
+//! [14]
+settings.beginGroup("alpha");
+// settings.group() == "alpha"
+
+settings.beginGroup("beta");
+// settings.group() == "alpha/beta"
+
+settings.endGroup();
+// settings.group() == "alpha"
+
+settings.endGroup();
+// settings.group() == ""
+//! [14]
+
+
+//! [15]
+struct Login {
+ QString userName;
+ QString password;
+};
+QList<Login> logins;
+...
+
+QSettings settings;
+int size = settings.beginReadArray("logins");
+for (int i = 0; i < size; ++i) {
+ settings.setArrayIndex(i);
+ Login login;
+ login.userName = settings.value("userName").toString();
+ login.password = settings.value("password").toString();
+ logins.append(login);
+}
+settings.endArray();
+//! [15]
+
+
+//! [16]
+struct Login {
+ QString userName;
+ QString password;
+};
+QList<Login> logins;
+...
+
+QSettings settings;
+settings.beginWriteArray("logins");
+for (int i = 0; i < logins.size(); ++i) {
+ settings.setArrayIndex(i);
+ settings.setValue("userName", list.at(i).userName);
+ settings.setValue("password", list.at(i).password);
+}
+settings.endArray();
+//! [16]
+
+
+//! [17]
+QSettings settings;
+settings.setValue("fridge/color", Qt::white);
+settings.setValue("fridge/size", QSize(32, 96));
+settings.setValue("sofa", true);
+settings.setValue("tv", false);
+
+QStringList keys = settings.allKeys();
+// keys: ["fridge/color", "fridge/size", "sofa", "tv"]
+//! [17]
+
+
+//! [18]
+settings.beginGroup("fridge");
+keys = settings.allKeys();
+// keys: ["color", "size"]
+//! [18]
+
+
+//! [19]
+QSettings settings;
+settings.setValue("fridge/color", Qt::white);
+settings.setValue("fridge/size", QSize(32, 96));
+settings.setValue("sofa", true);
+settings.setValue("tv", false);
+
+QStringList keys = settings.childKeys();
+// keys: ["sofa", "tv"]
+//! [19]
+
+
+//! [20]
+settings.beginGroup("fridge");
+keys = settings.childKeys();
+// keys: ["color", "size"]
+//! [20]
+
+
+//! [21]
+QSettings settings;
+settings.setValue("fridge/color", Qt::white);
+settings.setValue("fridge/size", QSize(32, 96));
+settings.setValue("sofa", true);
+settings.setValue("tv", false);
+
+QStringList groups = settings.childGroups();
+// groups: ["fridge"]
+//! [21]
+
+
+//! [22]
+settings.beginGroup("fridge");
+groups = settings.childGroups();
+// groups: []
+//! [22]
+
+
+//! [23]
+QSettings settings;
+settings.setValue("interval", 30);
+settings.value("interval").toInt(); // returns 30
+
+settings.setValue("interval", 6.55);
+settings.value("interval").toDouble(); // returns 6.55
+//! [23]
+
+
+//! [24]
+QSettings settings;
+settings.setValue("ape");
+settings.setValue("monkey", 1);
+settings.setValue("monkey/sea", 2);
+settings.setValue("monkey/doe", 4);
+
+settings.remove("monkey");
+QStringList keys = settings.allKeys();
+// keys: ["ape"]
+//! [24]
+
+
+//! [25]
+QSettings settings;
+settings.setValue("ape");
+settings.setValue("monkey", 1);
+settings.setValue("monkey/sea", 2);
+settings.setValue("monkey/doe", 4);
+
+settings.beginGroup("monkey");
+settings.remove("");
+settings.endGroup();
+
+QStringList keys = settings.allKeys();
+// keys: ["ape"]
+//! [25]
+
+
+//! [26]
+QSettings settings;
+settings.setValue("animal/snake", 58);
+settings.value("animal/snake", 1024).toInt(); // returns 58
+settings.value("animal/zebra", 1024).toInt(); // returns 1024
+settings.value("animal/zebra").toInt(); // returns 0
+//! [26]
+
+
+//! [27]
+bool myReadFunc(QIODevice &device, QSettings::SettingsMap &map);
+//! [27]
+
+
+//! [28]
+bool myWriteFunc(QIODevice &device, const QSettings::SettingsMap &map);
+//! [28]
+
+
+//! [29]
+bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
+bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);
+
+int main(int argc, char *argv[])
+{
+ const QSettings::Format XmlFormat =
+ QSettings::registerFormat("xml", readXmlFile, writeXmlFile);
+
+ QSettings settings(XmlFormat, QSettings::UserScope, "MySoft",
+ "Star Runner");
+
+ ...
+}
+//! [29]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qtemporarydir.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qtemporarydir.cpp
new file mode 100644
index 0000000000..4e855f72f0
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qtemporarydir.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+{
+//! [0]
+ // Within a function/method...
+
+ QTemporaryDir dir;
+ if (dir.isValid()) {
+ // dir.path() returns the unique directory path
+ }
+
+ // The QTemporaryDir destructor removes the temporary directory
+ // as it goes out of scope.
+//! [0]
+}
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qtemporaryfile.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qtemporaryfile.cpp
new file mode 100644
index 0000000000..2db3aace56
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qtemporaryfile.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+{
+//! [0]
+ // Within a function/method...
+
+ QTemporaryFile file;
+ if (file.open()) {
+ // file.fileName() returns the unique file name
+ }
+
+ // The QTemporaryFile destructor removes the temporary file
+ // as it goes out of scope.
+//! [0]
+}
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp
new file mode 100644
index 0000000000..c46cbb23d3
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QFile data("output.txt");
+if (data.open(QFile::WriteOnly | QFile::Truncate)) {
+ QTextStream out(&data);
+ out << "Result: " << qSetFieldWidth(10) << left << 3.14 << 2.7;
+ // writes "Result: 3.14 2.7 "
+}
+//! [0]
+
+
+//! [1]
+QTextStream stream(stdin);
+QString line;
+do {
+ line = stream.readLine();
+} while (!line.isNull());
+//! [1]
+
+
+//! [2]
+QTextStream in("0x50 0x20");
+int firstNumber, secondNumber;
+
+in >> firstNumber; // firstNumber == 80
+in >> dec >> secondNumber; // secondNumber == 0
+
+char ch;
+in >> ch; // ch == 'x'
+//! [2]
+
+
+//! [3]
+int main(int argc, char *argv[])
+{
+ // read numeric arguments (123, 0x20, 4.5...)
+ for (int i = 1; i < argc; ++i) {
+ int number;
+ QTextStream in(argv[i]);
+ in >> number;
+ ...
+ }
+}
+//! [3]
+
+
+//! [4]
+QString str;
+QTextStream in(stdin);
+in >> str;
+//! [4]
+
+
+//! [5]
+QString s;
+QTextStream out(&s);
+out.setFieldWidth(10);
+out.setFieldAlignment(QTextStream::AlignCenter);
+out.setPadChar('-');
+out << "Qt" << "rocks!";
+//! [5]
+
+
+//! [6]
+----Qt------rocks!--
+//! [6]
+
+
+//! [7]
+QTextStream in(file);
+QChar ch1, ch2, ch3;
+in >> ch1 >> ch2 >> ch3;
+//! [7]
+
+
+//! [8]
+QTextStream out(stdout);
+out << "Qt rocks!" << endl;
+//! [8]
+
+
+//! [9]
+stream << '\n' << flush;
+//! [9]
+
+
+//! [10]
+QTextStream out(&file);
+out.setCodec("UTF-8");
+//! [10]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp
new file mode 100644
index 0000000000..8fd4b8ee9f
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QUrl url("http://www.example.com/List of holidays.xml");
+// url.toEncoded() == "http://www.example.com/List%20of%20holidays.xml"
+//! [0]
+
+
+//! [1]
+QUrl url = QUrl::fromEncoded("http://qt.nokia.com/List%20of%20holidays.xml");
+//! [1]
+
+
+//! [2]
+bool checkUrl(const QUrl &url) {
+ if (!url.isValid()) {
+ qDebug(QString("Invalid URL: %1").arg(url.toString()));
+ return false;
+ }
+
+ return true;
+}
+//! [2]
+
+
+//! [3]
+QTcpSocket sock;
+sock.connectToHost(url.host(), url.port(80));
+//! [3]
+
+
+//! [4]
+http://www.example.com/cgi-bin/drawgraph.cgi?type(pie)color(green)
+//! [4]
+
+
+//! [5]
+QUrl baseUrl("http://qt.nokia.com/support");
+QUrl relativeUrl("../products/solutions");
+qDebug(baseUrl.resolved(relativeUrl).toString());
+// prints "http://qt.nokia.com/products/solutions"
+//! [5]
+
+
+//! [6]
+QByteArray ba = QUrl::toPercentEncoding("{a fishy string?}", "{}", "s");
+qDebug(ba.constData());
+// prints "{a fi%73hy %73tring%3F}"
+//! [6]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp
new file mode 100644
index 0000000000..eba007e947
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+bool myEventFilter(void *message);
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
new file mode 100644
index 0000000000..aa5b23265e
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+beginInsertRows(parent, 2, 4);
+//! [0]
+
+
+//! [1]
+beginInsertRows(parent, 4, 5);
+//! [1]
+
+
+//! [2]
+beginRemoveRows(parent, 2, 3);
+//! [2]
+
+
+//! [3]
+beginInsertColumns(parent, 4, 6);
+//! [3]
+
+
+//! [4]
+beginInsertColumns(parent, 6, 8);
+//! [4]
+
+
+//! [5]
+beginRemoveColumns(parent, 4, 6);
+//! [5]
+
+
+//! [6]
+beginMoveRows(sourceParent, 2, 4, destinationParent, 2);
+//! [6]
+
+
+//! [7]
+beginMoveRows(sourceParent, 2, 4, destinationParent, 6);
+//! [7]
+
+
+//! [8]
+beginMoveRows(parent, 2, 2, parent, 0);
+//! [8]
+
+
+//! [9]
+beginMoveRows(parent, 2, 2, parent, 4);
+//! [9]
+
+//! [10]
+myData.clear();
+reset();
+//! [10]
+
+//! [11]
+beginResetModel();
+myData.clear();
+endResetModel();
+//! [11]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
new file mode 100644
index 0000000000..8023e6a218
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QMouseEvent event(QEvent::MouseButtonPress, pos, 0, 0, 0);
+QApplication::sendEvent(mainWindow, &event);
+//! [0]
+
+
+//! [1]
+QPushButton *quitButton = new QPushButton("Quit");
+connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit()));
+//! [1]
+
+
+//! [2]
+foreach (const QString &path, app.libraryPaths())
+ do_something(path);
+//! [2]
+
+
+//! [3]
+bool myEventFilter(void *message, long *result);
+//! [3]
+
+
+//! [4]
+static int *global_ptr = 0;
+
+static void cleanup_ptr()
+{
+ delete [] global_ptr;
+ global_ptr = 0;
+}
+
+void init_ptr()
+{
+ global_ptr = new int[100]; // allocate data
+ qAddPostRoutine(cleanup_ptr); // delete later
+}
+//! [4]
+
+
+//! [5]
+class MyPrivateInitStuff : public QObject
+{
+public:
+ static MyPrivateInitStuff *initStuff(QObject *parent)
+ {
+ if (!p)
+ p = new MyPrivateInitStuff(parent);
+ return p;
+ }
+
+ ~MyPrivateInitStuff()
+ {
+ // cleanup goes here
+ }
+
+private:
+ MyPrivateInitStuff(QObject *parent)
+ : QObject(parent)
+ {
+ // initialization goes here
+ }
+
+ MyPrivateInitStuff *p;
+};
+//! [5]
+
+
+//! [6]
+static inline QString tr(const char *sourceText,
+ const char *comment = 0);
+static inline QString trUtf8(const char *sourceText,
+ const char *comment = 0);
+//! [6]
+
+
+//! [7]
+class MyMfcView : public CView
+{
+ Q_DECLARE_TR_FUNCTIONS(MyMfcView)
+
+public:
+ MyMfcView();
+ ...
+};
+//! [7]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp
new file mode 100644
index 0000000000..528fdbd329
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("author", "Sabrina Schweinsteiger")
+ Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
+
+public:
+ ...
+};
+//! [0]
+
+
+//! [1]
+QByteArray normType = QMetaObject::normalizedType(" int const *");
+// normType is now "const int*"
+//! [1]
+
+
+//! [2]
+QMetaObject::invokeMethod(pushButton, "animateClick",
+ Qt::QueuedConnection);
+//! [2]
+
+
+//! [3]
+QMetaObject::invokeMethod: Unable to handle unregistered datatype 'MyType'
+//! [3]
+
+
+//! [4]
+QString retVal;
+QMetaObject::invokeMethod(obj, "compute", Qt::DirectConnection,
+ Q_RETURN_ARG(QString, retVal),
+ Q_ARG(QString, "sqrt"),
+ Q_ARG(int, 42),
+ Q_ARG(double, 9.7));
+//! [4]
+
+
+//! [5]
+class MyClass
+{
+ Q_OBJECT
+ Q_CLASSINFO("author", "Sabrina Schweinsteiger")
+ Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
+
+public:
+ ...
+};
+//! [5]
+
+
+//! [propertyCount]
+const QMetaObject* metaObject = obj->metaObject();
+QStringList properties;
+for(int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i)
+ properties << QString::fromLatin1(metaObject->property(i).name());
+//! [propertyCount]
+
+
+//! [methodCount]
+const QMetaObject* metaObject = obj->metaObject();
+QStringList methods;
+for(int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i)
+ methods << QString::fromLatin1(metaObject->method(i).methodSignature());
+//! [methodCount]
+
+//! [6]
+int methodIndex = pushButton->metaObject()->indexOfMethod("animateClick()");
+QMetaMethod method = metaObject->method(methodIndex);
+method.invoke(pushButton, Qt::QueuedConnection);
+//! [6]
+
+//! [7]
+QMetaMethod::invoke: Unable to handle unregistered datatype 'MyType'
+//! [7]
+
+//! [8]
+QString retVal;
+QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QString, int, double)");
+int methodIndex = obj->metaObject()->indexOfMethod(normalizedSignature);
+QMetaMethod method = metaObject->method(methodIndex);
+method.invoke(obj,
+ Qt::DirectConnection,
+ Q_RETURN_ARG(QString, retVal),
+ Q_ARG(QString, "sqrt"),
+ Q_ARG(int, 42),
+ Q_ARG(double, 9.7));
+//! [8]
+
+//! [9]
+QMetaMethod destroyedSignal = QMetaMethod::fromSignal(&QObject::destroyed);
+//! [9]
+
+}
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp
new file mode 100644
index 0000000000..d0a7a69884
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+struct MyStruct
+{
+ int i;
+ ...
+};
+
+Q_DECLARE_METATYPE(MyStruct)
+//! [0]
+
+
+//! [1]
+namespace MyNamespace
+{
+ ...
+}
+
+Q_DECLARE_METATYPE(MyNamespace::MyStruct)
+//! [1]
+
+
+//! [2]
+MyStruct s;
+QVariant var;
+var.setValue(s); // copy s into the variant
+
+...
+
+// retrieve the value
+MyStruct s2 = var.value<MyStruct>();
+//! [2]
+
+
+//! [3]
+int id = QMetaType::type("MyClass");
+if (id != QMetaType::UnknownType) {
+ void *myClassPtr = QMetaType::create(id);
+ ...
+ QMetaType::destroy(id, myClassPtr);
+ myClassPtr = 0;
+}
+//! [3]
+
+
+//! [4]
+qRegisterMetaType<MyClass>("MyClass");
+//! [4]
+
+
+//! [5]
+qRegisterMetaTypeStreamOperators<MyClass>("MyClass");
+//! [5]
+
+
+//! [6]
+QDataStream &operator<<(QDataStream &out, const MyClass &myObj);
+QDataStream &operator>>(QDataStream &in, MyClass &myObj);
+//! [6]
+
+
+//! [7]
+int id = qRegisterMetaType<MyStruct>();
+//! [7]
+
+
+//! [8]
+int id = qMetaTypeId<QString>(); // id is now QMetaType::QString
+id = qMetaTypeId<MyStruct>(); // compile error if MyStruct not declared
+//! [8]
+
+//! [9]
+typedef QString CustomString;
+qRegisterMetaType<CustomString>("CustomString");
+//! [9]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qmimedata.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qmimedata.cpp
new file mode 100644
index 0000000000..de683cf463
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qmimedata.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void MyWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasUrls())
+ event->acceptProposedAction();
+}
+
+void MyWidget::dropEvent(QDropEvent *event)
+{
+ if (event->mimeData()->hasUrls()) {
+ foreach (QUrl url, event->mimeData()->urls()) {
+ ...
+ }
+ }
+}
+//! [0]
+
+
+//! [1]
+QByteArray csvData = ...;
+
+QMimeData *mimeData = new QMimeData;
+mimeData->setData("text/csv", csvData);
+//! [1]
+
+
+//! [2]
+void MyWidget::dropEvent(QDropEvent *event)
+{
+ const MyMimeData *myData =
+ qobject_cast<const MyMimeData *>(event->mimeData());
+ if (myData) {
+ // access myData's data directly (not through QMimeData's API)
+ }
+}
+//! [2]
+
+
+//! [3]
+application/x-qt-windows-mime;value="<custom type>"
+//! [3]
+
+
+//! [4]
+application/x-qt-windows-mime;value="FileGroupDescriptor"
+application/x-qt-windows-mime;value="FileContents"
+//! [4]
+
+
+//! [5]
+if (event->mimeData()->hasImage()) {
+ QImage image = qvariant_cast<QImage>(event->mimeData()->imageData());
+ ...
+}
+//! [5]
+
+
+//! [6]
+mimeData->setImageData(QImage("beautifulfjord.png"));
+//! [6]
+
+
+//! [7]
+if (event->mimeData()->hasColor()) {
+ QColor color = qvariant_cast<QColor>(event->mimeData()->colorData());
+ ...
+}
+//! [7]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
new file mode 100644
index 0000000000..95c54169ce
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
@@ -0,0 +1,501 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLineEdit *lineEdit = static_cast<QLineEdit *>(
+ qt_find_obj_child(myWidget, "QLineEdit", "my line edit"));
+if (lineEdit)
+ lineEdit->setText("Default");
+//! [0]
+
+
+//! [1]
+QObject *obj = new QPushButton;
+obj->metaObject()->className(); // returns "QPushButton"
+
+QPushButton::staticMetaObject.className(); // returns "QPushButton"
+//! [1]
+
+
+//! [2]
+QPushButton::staticMetaObject.className(); // returns "QPushButton"
+
+QObject *obj = new QPushButton;
+obj->metaObject()->className(); // returns "QPushButton"
+//! [2]
+
+
+//! [3]
+QObject *obj = new QTimer; // QTimer inherits QObject
+
+QTimer *timer = qobject_cast<QTimer *>(obj);
+// timer == (QObject *)obj
+
+QAbstractButton *button = qobject_cast<QAbstractButton *>(obj);
+// button == 0
+//! [3]
+
+
+//! [4]
+QTimer *timer = new QTimer; // QTimer inherits QObject
+timer->inherits("QTimer"); // returns true
+timer->inherits("QObject"); // returns true
+timer->inherits("QAbstractButton"); // returns false
+
+// QVBoxLayout inherits QObject and QLayoutItem
+QVBoxLayout *layout = new QVBoxLayout;
+layout->inherits("QObject"); // returns true
+layout->inherits("QLayoutItem"); // returns true (even though QLayoutItem is not a QObject)
+//! [4]
+
+
+//! [5]
+qDebug("MyClass::setPrecision(): (%s) invalid precision %f",
+ qPrintable(objectName()), newPrecision);
+//! [5]
+
+
+//! [6]
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow();
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *ev);
+
+private:
+ QTextEdit *textEdit;
+};
+
+MainWindow::MainWindow()
+{
+ textEdit = new QTextEdit;
+ setCentralWidget(textEdit);
+
+ textEdit->installEventFilter(this);
+}
+
+bool MainWindow::eventFilter(QObject *obj, QEvent *event)
+{
+ if (obj == textEdit) {
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ qDebug() << "Ate key press" << keyEvent->key();
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ // pass the event on to the parent class
+ return QMainWindow::eventFilter(obj, event);
+ }
+}
+//! [6]
+
+
+//! [7]
+myObject->moveToThread(QApplication::instance()->thread());
+//! [7]
+
+
+//! [8]
+class MyObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ MyObject(QObject *parent = 0);
+
+protected:
+ void timerEvent(QTimerEvent *event);
+};
+
+MyObject::MyObject(QObject *parent)
+ : QObject(parent)
+{
+ startTimer(50); // 50-millisecond timer
+ startTimer(1000); // 1-second timer
+ startTimer(60000); // 1-minute timer
+}
+
+void MyObject::timerEvent(QTimerEvent *event)
+{
+ qDebug() << "Timer ID:" << event->timerId();
+}
+//! [8]
+
+
+//! [9]
+QList<QObject *> list = window()->queryList("QAbstractButton"));
+foreach (QObject *obj, list)
+ static_cast<QAbstractButton *>(obj)->setEnabled(false);
+//! [9]
+
+
+//! [10]
+QPushButton *button = parentWidget->findChild<QPushButton *>("button1");
+//! [10]
+
+
+//! [11]
+QListWidget *list = parentWidget->findChild<QListWidget *>();
+//! [11]
+
+
+//! [12]
+QList<QWidget *> widgets = parentWidget.findChildren<QWidget *>("widgetname");
+//! [12]
+
+
+//! [13]
+QList<QPushButton *> allPButtons = parentWidget.findChildren<QPushButton *>();
+//! [13]
+
+
+//! [14]
+monitoredObj->installEventFilter(filterObj);
+//! [14]
+
+
+//! [15]
+class KeyPressEater : public QObject
+{
+ Q_OBJECT
+ ...
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+};
+
+bool KeyPressEater::eventFilter(QObject *obj, QEvent *event)
+{
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ qDebug("Ate key press %d", keyEvent->key());
+ return true;
+ } else {
+ // standard event processing
+ return QObject::eventFilter(obj, event);
+ }
+}
+//! [15]
+
+
+//! [16]
+KeyPressEater *keyPressEater = new KeyPressEater(this);
+QPushButton *pushButton = new QPushButton(this);
+QListView *listView = new QListView(this);
+
+pushButton->installEventFilter(keyPressEater);
+listView->installEventFilter(keyPressEater);
+//! [16]
+
+
+//! [17]
+MyWindow::MyWindow()
+{
+ QLabel *senderLabel = new QLabel(tr("Name:"));
+ QLabel *recipientLabel = new QLabel(tr("Name:", "recipient"));
+//! [17]
+}
+
+
+//! [18]
+int n = messages.count();
+showMessage(tr("%n message(s) saved", "", n));
+//! [18]
+
+
+//! [19]
+n == 1 ? tr("%n message saved") : tr("%n messages saved")
+//! [19]
+
+
+//! [20]
+label->setText(tr("F\374r \310lise"));
+//! [20]
+
+
+//! [21]
+if (receivers(SIGNAL(valueChanged(QByteArray))) > 0) {
+ QByteArray data;
+ get_the_value(&data); // expensive operation
+ emit valueChanged(data);
+}
+//! [21]
+
+
+//! [22]
+QLabel *label = new QLabel;
+QScrollBar *scrollBar = new QScrollBar;
+QObject::connect(scrollBar, SIGNAL(valueChanged(int)),
+ label, SLOT(setNum(int)));
+//! [22]
+
+
+//! [23]
+// WRONG
+QObject::connect(scrollBar, SIGNAL(valueChanged(int value)),
+ label, SLOT(setNum(int value)));
+//! [23]
+
+
+//! [24]
+class MyWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ MyWidget();
+
+signals:
+ void buttonClicked();
+
+private:
+ QPushButton *myButton;
+};
+
+MyWidget::MyWidget()
+{
+ myButton = new QPushButton(this);
+ connect(myButton, SIGNAL(clicked()),
+ this, SIGNAL(buttonClicked()));
+}
+//! [24]
+
+
+//! [25]
+QObject::connect: Cannot queue arguments of type 'MyType'
+(Make sure 'MyType' is registered using qRegisterMetaType().)
+//! [25]
+
+
+//! [26]
+disconnect(myObject, 0, 0, 0);
+//! [26]
+
+
+//! [27]
+myObject->disconnect();
+//! [27]
+
+
+//! [28]
+disconnect(myObject, SIGNAL(mySignal()), 0, 0);
+//! [28]
+
+
+//! [29]
+myObject->disconnect(SIGNAL(mySignal()));
+//! [29]
+
+
+//! [30]
+disconnect(myObject, 0, myReceiver, 0);
+//! [30]
+
+
+//! [31]
+myObject->disconnect(myReceiver);
+//! [31]
+
+
+//! [32]
+if (signal == QMetaMethod::fromSignal(&MyObject::valueChanged)) {
+ // signal is valueChanged
+}
+//! [32]
+
+
+//! [33]
+void on_<object name>_<signal name>(<signal parameters>);
+//! [33]
+
+
+//! [34]
+void on_button1_clicked();
+//! [34]
+
+
+//! [35]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("Author", "Pierre Gendron")
+ Q_CLASSINFO("URL", "http://www.my-organization.qc.ca")
+
+public:
+ ...
+};
+//! [35]
+
+
+//! [36]
+Q_PROPERTY(type name
+ READ getFunction
+ [WRITE setFunction]
+ [RESET resetFunction]
+ [NOTIFY notifySignal]
+ [DESIGNABLE bool]
+ [SCRIPTABLE bool]
+ [STORED bool]
+ [USER bool]
+ [CONSTANT]
+ [FINAL])
+//! [36]
+
+
+//! [37]
+Q_PROPERTY(QString title READ title WRITE setTitle USER true)
+//! [37]
+
+
+//! [38]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(Priority)
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+ enum Priority { High, Low, VeryHigh, VeryLow };
+ void setPriority(Priority priority);
+ Priority priority() const;
+};
+//! [38]
+
+
+//! [39a]
+class QLibrary : public QObject
+{
+ ...
+ Q_FLAGS(LoadHint LoadHints)
+ ...
+//! [39a]
+
+//! [39b]
+ ...
+public:
+ enum LoadHint {
+ ResolveAllSymbolsHint = 0x01,
+ ExportExternalSymbolsHint = 0x02,
+ LoadArchiveMemberHint = 0x04
+ };
+ Q_DECLARE_FLAGS(LoadHints, LoadHint)
+ ...
+//! [39b]
+
+
+//! [40]
+//: This name refers to a host name.
+hostNameLabel->setText(tr("Name:"));
+
+/*: This text refers to a C++ code example. */
+QString example = tr("Example");
+//! [40]
+
+//! [41]
+QPushButton *button = parentWidget->findChild<QPushButton *>("button1", Qt::FindDirectChildOnly);
+//! [41]
+
+
+//! [42]
+QListWidget *list = parentWidget->findChild<QListWidget *>(QString(), Qt::FindDirectChildOnly);
+//! [42]
+
+
+//! [43]
+QList<QPushButton *> childButtons = parentWidget.findChildren<QPushButton *>(QString(), Qt::FindDirectChildOnly);
+//! [43]
+
+//! [44]
+QLabel *label = new QLabel;
+QLineEdit *lineEdit = new QLineEdit;
+QObject::connect(lineEdit, &QLineEdit::textChanged,
+ label, &QLabel::setText);
+//! [44]
+
+//! [45]
+void someFunction();
+QPushButton *button = new QPushButton;
+QObject::connect(button, &QPushButton::clicked, someFunction);
+//! [45]
+
+//! [46]
+QByteArray page = ...;
+QTcpSocket *socket = new QTcpSocket;
+socket->connectToHost("qt-project.org", 80);
+QObject::connect(socket, &QTcpSocket::connected, [=] () {
+ socket->write("GET " + page + "\r\n");
+ });
+//! [46]
+
+//! [47]
+disconnect(myObject, &MyObject::mySignal(), 0, 0);
+//! [47]
+
+//! [48]
+QObject::disconnect(lineEdit, &QLineEdit::textChanged,
+ label, &QLabel::setText);
+//! [48]
+
+//! [49]
+if (isSignalConnected(QMethaMethod::fromSignal(&MyObject::valueChanged))) {
+ QByteArray data;
+ data = get_the_value(); // expensive operation
+ emit valueChanged(data);
+}
+//! [49]
+
+//! [meta data]
+//: This is a comment for the translator.
+//= qtn_foo_bar
+//~ loc-layout_id foo_dialog
+//~ loc-blank False
+//~ magic-stuff This might mean something magic.
+QString text = MyMagicClass::tr("Sim sala bim.");
+//! [meta data]
+
+//! [explicit tr context]
+QString text = QScrollBar::tr("Page up");
+//! [explicit tr context]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
new file mode 100644
index 0000000000..da6e9fca8e
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QSystemSemaphore sem("market", 3, QSystemSemaphore::Create);
+ // resources available == 3
+sem.acquire(); // resources available == 2
+sem.acquire(); // resources available == 1
+sem.acquire(); // resources available == 0
+sem.release(); // resources available == 1
+sem.release(2); // resources available == 3
+//! [0]
+
+
+//! [1]
+QSystemSemaphore sem("market", 5, QSystemSemaphore::Create);
+sem.acquire(5); // acquire all 5 resources
+sem.release(5); // release the 5 resources
+//! [1]
+
+
+//! [2]
+sem.release(10); // "create" 10 new resources
+//! [2]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qtimer.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qtimer.cpp
new file mode 100644
index 0000000000..dfdef73e75
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qtimer.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include <QApplication>
+#include <QTimer>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTimer::singleShot(600000, &app, SLOT(quit()));
+ ...
+ return app.exec();
+}
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp
new file mode 100644
index 0000000000..ae38c8372f
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QDataStream out(...);
+QVariant v(123); // The variant now contains an int
+int x = v.toInt(); // x = 123
+out << v; // Writes a type tag and an int to out
+v = QVariant("hello"); // The variant now contains a QByteArray
+v = QVariant(tr("hello")); // The variant now contains a QString
+int y = v.toInt(); // y = 0 since v cannot be converted to an int
+QString s = v.toString(); // s = tr("hello") (see QObject::tr())
+out << v; // Writes a type tag and a QString to out
+...
+QDataStream in(...); // (opening the previously written stream)
+in >> v; // Reads an Int variant
+int z = v.toInt(); // z = 123
+qDebug("Type is %s", // prints "Type is int"
+ v.typeName());
+v = v.toInt() + 100; // The variant now hold the value 223
+v = QVariant(QStringList());
+//! [0]
+
+
+//! [1]
+QVariant x, y(QString()), z(QString(""));
+x.convert(QVariant::Int);
+// x.isNull() == true
+// y.isNull() == true, z.isNull() == false
+//! [1]
+
+
+//! [2]
+QVariant variant;
+...
+QColor color = variant.value<QColor>();
+//! [2]
+
+
+//! [3]
+QColor color = palette().background().color();
+QVariant variant = color;
+//! [3]
+
+
+//! [4]
+QVariant v;
+
+v.setValue(5);
+int i = v.toInt(); // i is now 5
+QString s = v.toString() // s is now "5"
+
+MyCustomStruct c;
+v.setValue(c);
+
+...
+
+MyCustomStruct c2 = v.value<MyCustomStruct>();
+//! [4]
+
+
+//! [5]
+QVariant v;
+
+MyCustomStruct c;
+if (v.canConvert<MyCustomStruct>())
+ c = v.value<MyCustomStruct>();
+
+v = 7;
+int i = v.value<int>(); // same as v.toInt()
+QString s = v.value<QString>(); // same as v.toString(), s is now "7"
+MyCustomStruct c2 = v.value<MyCustomStruct>(); // conversion failed, c2 is empty
+//! [5]
+
+
+//! [6]
+QVariant v = 42;
+
+v.canConvert<int>(); // returns true
+v.canConvert<QString>(); // returns true
+
+MyCustomStruct s;
+v.setValue(s);
+
+v.canConvert<int>(); // returns false
+v.canConvert<MyCustomStruct>(); // returns true
+//! [6]
+
+
+//! [7]
+MyCustomStruct s;
+return QVariant::fromValue(s);
+//! [7]
+
+
+//! [8]
+QObject *object = getObjectFromSomewhere();
+QVariant data = QVariant::fromValue(object);
+//! [8]
diff --git a/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp b/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp
new file mode 100644
index 0000000000..e59a96b87a
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QMimeDatabase db;
+QMimeType mime = db.mimeTypeForFile(fileName);
+if (mime.inherits("text/plain")) {
+ // The file is plain text, we can display it in a QTextEdit
+}
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_plugin_qlibrary.cpp b/src/corelib/doc/snippets/code/src_corelib_plugin_qlibrary.cpp
new file mode 100644
index 0000000000..9de685a7b5
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_plugin_qlibrary.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLibrary myLib("mylib");
+typedef void (*MyPrototype)();
+MyPrototype myFunction = (MyPrototype) myLib.resolve("mysymbol");
+if (myFunction)
+ myFunction();
+//! [0]
+
+
+//! [1]
+typedef void (*MyPrototype)();
+MyPrototype myFunction =
+ (MyPrototype) QLibrary::resolve("mylib", "mysymbol");
+if (myFunction)
+ myFunction();
+//! [1]
+
+
+//! [2]
+typedef int (*AvgFunction)(int, int);
+
+AvgFunction avg = (AvgFunction) library->resolve("avg");
+if (avg)
+ return avg(5, 8);
+else
+ return -1;
+//! [2]
+
+
+//! [3]
+extern "C" MY_EXPORT int avg(int a, int b)
+{
+ return (a + b) / 2;
+}
+//! [3]
+
+
+//! [4]
+#ifdef Q_OS_WIN
+#define MY_EXPORT __declspec(dllexport)
+#else
+#define MY_EXPORT
+#endif
+//! [4]
diff --git a/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp b/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp
new file mode 100644
index 0000000000..5c8f6ae091
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+// {67C8770B-44F1-410A-AB9A-F9B5446F13EE}
+QUuid IID_MyInterface(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee)
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp
new file mode 100644
index 0000000000..e212470b75
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [simple state machine]
+QPushButton button;
+
+QStateMachine machine;
+QState *s1 = new QState();
+s1->assignProperty(&button, "text", "Click me");
+
+QFinalState *s2 = new QFinalState();
+s1->addTransition(&button, SIGNAL(clicked()), s2);
+
+machine.addState(s1);
+machine.addState(s2);
+machine.setInitialState(s1);
+machine.start();
+//! [simple state machine]
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qatomic.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qatomic.cpp
new file mode 100644
index 0000000000..7e3d7dc7e4
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qatomic.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+MySharedType &MySharedType::operator=(const MySharedType &other)
+{
+ (void) other.data->atomicInt.ref();
+ if (!data->atomicInt.deref()) {
+ // The last reference has been released
+ delete d;
+ }
+ d = other.d;
+ return *this;
+}
+//! [0]
+
+
+//! [1]
+if (currentValue == expectedValue) {
+ currentValue = newValue;
+ return true;
+}
+return false;
+//! [1]
+
+
+//! [2]
+int originalValue = currentValue;
+currentValue = newValue;
+return originalValue;
+//! [2]
+
+
+//! [3]
+int originalValue = currentValue;
+currentValue += valueToAdd;
+return originalValue;
+//! [3]
+
+
+//! [4]
+if (currentValue == expectedValue) {
+ currentValue = newValue;
+ return true;
+}
+return false;
+//! [4]
+
+
+//! [5]
+T *originalValue = currentValue;
+currentValue = newValue;
+return originalValue;
+//! [5]
+
+
+//! [6]
+T *originalValue = currentValue;
+currentValue += valueToAdd;
+return originalValue;
+//! [6]
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qmutex.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qmutex.cpp
new file mode 100644
index 0000000000..f5fbeb8419
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qmutex.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+int number = 6;
+
+void method1()
+{
+ number *= 5;
+ number /= 4;
+}
+
+void method2()
+{
+ number *= 3;
+ number /= 2;
+}
+//! [0]
+
+
+//! [1]
+// method1()
+number *= 5; // number is now 30
+number /= 4; // number is now 7
+
+// method2()
+number *= 3; // number is now 21
+number /= 2; // number is now 10
+//! [1]
+
+
+//! [2]
+// Thread 1 calls method1()
+number *= 5; // number is now 30
+
+// Thread 2 calls method2().
+//
+// Most likely Thread 1 has been put to sleep by the operating
+// system to allow Thread 2 to run.
+number *= 3; // number is now 90
+number /= 2; // number is now 45
+
+// Thread 1 finishes executing.
+number /= 4; // number is now 11, instead of 10
+//! [2]
+
+
+//! [3]
+QMutex mutex;
+int number = 6;
+
+void method1()
+{
+ mutex.lock();
+ number *= 5;
+ number /= 4;
+ mutex.unlock();
+}
+
+void method2()
+{
+ mutex.lock();
+ number *= 3;
+ number /= 2;
+ mutex.unlock();
+}
+//! [3]
+
+
+//! [4]
+int complexFunction(int flag)
+{
+ mutex.lock();
+
+ int retVal = 0;
+
+ switch (flag) {
+ case 0:
+ case 1:
+ retVal = moreComplexFunction(flag);
+ break;
+ case 2:
+ {
+ int status = anotherFunction();
+ if (status < 0) {
+ mutex.unlock();
+ return -2;
+ }
+ retVal = status + flag;
+ }
+ break;
+ default:
+ if (flag > 10) {
+ mutex.unlock();
+ return -1;
+ }
+ break;
+ }
+
+ mutex.unlock();
+ return retVal;
+}
+//! [4]
+
+
+//! [5]
+int complexFunction(int flag)
+{
+ QMutexLocker locker(&mutex);
+
+ int retVal = 0;
+
+ switch (flag) {
+ case 0:
+ case 1:
+ return moreComplexFunction(flag);
+ case 2:
+ {
+ int status = anotherFunction();
+ if (status < 0)
+ return -2;
+ retVal = status + flag;
+ }
+ break;
+ default:
+ if (flag > 10)
+ return -1;
+ break;
+ }
+
+ return retVal;
+}
+//! [5]
+
+
+//! [6]
+class SignalWaiter
+{
+private:
+ QMutexLocker locker;
+
+public:
+ SignalWaiter(QMutex *mutex)
+ : locker(mutex)
+ {
+ }
+
+ void waitForSignal()
+ {
+ ...
+ while (!signalled)
+ waitCondition.wait(locker.mutex());
+ ...
+ }
+};
+//! [6]
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qmutexpool.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qmutexpool.cpp
new file mode 100644
index 0000000000..29076db91c
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qmutexpool.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class Number {
+public:
+ Number(double n) : num (n) { }
+
+ void setNumber(double n) { num = n; }
+ double number() const { return num; }
+
+private:
+ double num;
+};
+//! [0]
+
+
+//! [1]
+void calcSquare(Number *num)
+{
+ QMutexLocker locker(mutexpool.get(num));
+ num.setNumber(num.number() * num.number());
+}
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qreadwritelock.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qreadwritelock.cpp
new file mode 100644
index 0000000000..bd42c01905
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qreadwritelock.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QReadWriteLock lock;
+
+void ReaderThread::run()
+{
+ ...
+ lock.lockForRead();
+ read_file();
+ lock.unlock();
+ ...
+}
+
+void WriterThread::run()
+{
+ ...
+ lock.lockForWrite();
+ write_file();
+ lock.unlock();
+ ...
+}
+//! [0]
+
+
+//! [1]
+QReadWriteLock lock;
+
+QByteArray readData()
+{
+ QReadLocker locker(&lock);
+ ...
+ return data;
+}
+//! [1]
+
+
+//! [2]
+QReadWriteLock lock;
+
+QByteArray readData()
+{
+ lock.lockForRead();
+ ...
+ lock.unlock();
+ return data;
+}
+//! [2]
+
+
+//! [3]
+QReadWriteLock lock;
+
+void writeData(const QByteArray &data)
+{
+ QWriteLocker locker(&lock);
+ ...
+}
+//! [3]
+
+
+//! [4]
+QReadWriteLock lock;
+
+void writeData(const QByteArray &data)
+{
+ lock.lockForWrite();
+ ...
+ lock.unlock();
+}
+//! [4]
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qsemaphore.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qsemaphore.cpp
new file mode 100644
index 0000000000..fd4ff98314
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qsemaphore.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QSemaphore sem(5); // sem.available() == 5
+
+sem.acquire(3); // sem.available() == 2
+sem.acquire(2); // sem.available() == 0
+sem.release(5); // sem.available() == 5
+sem.release(5); // sem.available() == 10
+
+sem.tryAcquire(1); // sem.available() == 9, returns true
+sem.tryAcquire(250); // sem.available() == 9, returns false
+//! [0]
+
+
+//! [1]
+QSemaphore sem(5); // a semaphore that guards 5 resources
+sem.acquire(5); // acquire all 5 resources
+sem.release(5); // release the 5 resources
+sem.release(10); // "create" 10 new resources
+//! [1]
+
+
+//! [2]
+QSemaphore sem(5); // sem.available() == 5
+sem.tryAcquire(250); // sem.available() == 5, returns false
+sem.tryAcquire(3); // sem.available() == 2, returns true
+//! [2]
+
+
+//! [3]
+QSemaphore sem(5); // sem.available() == 5
+sem.tryAcquire(250, 1000); // sem.available() == 5, waits 1000 milliseconds and returns false
+sem.tryAcquire(3, 30000); // sem.available() == 2, returns true without waiting
+//! [3]
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp
new file mode 100644
index 0000000000..681023c91b
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class MyThread : public QThread
+{
+public:
+ void run();
+};
+
+void MyThread::run()
+{
+ QTcpSocket socket;
+ // connect QTcpSocket's signals somewhere meaningful
+ ...
+ socket.connectToHost(hostName, portNumber);
+ exec();
+}
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp
new file mode 100644
index 0000000000..149cae5bf6
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+forever {
+ mutex.lock();
+ keyPressed.wait(&mutex);
+ do_something();
+ mutex.unlock();
+}
+//! [0]
+
+
+//! [1]
+forever {
+ getchar();
+ keyPressed.wakeAll();
+}
+//! [1]
+
+
+//! [2]
+forever {
+ mutex.lock();
+ keyPressed.wait(&mutex);
+ ++count;
+ mutex.unlock();
+
+ do_something();
+
+ mutex.lock();
+ --count;
+ mutex.unlock();
+}
+//! [2]
+
+
+//! [3]
+forever {
+ getchar();
+
+ mutex.lock();
+ // Sleep until there are no busy worker threads
+ while (count > 0) {
+ mutex.unlock();
+ sleep(1);
+ mutex.lock();
+ }
+ keyPressed.wakeAll();
+ mutex.unlock();
+}
+//! [3]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbitarray.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbitarray.cpp
new file mode 100644
index 0000000000..cfaa6ef485
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbitarray.cpp
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QBitArray ba(200);
+//! [0]
+
+
+//! [1]
+QBitArray ba;
+ba.resize(3);
+ba[0] = true;
+ba[1] = false;
+ba[2] = true;
+//! [1]
+
+
+//! [2]
+QBitArray ba(3);
+ba.setBit(0, true);
+ba.setBit(1, false);
+ba.setBit(2, true);
+//! [2]
+
+
+//! [3]
+QBitArray x(5);
+x.setBit(3, true);
+// x: [ 0, 0, 0, 1, 0 ]
+
+QBitArray y(5);
+y.setBit(4, true);
+// y: [ 0, 0, 0, 0, 1 ]
+
+x |= y;
+// x: [ 0, 0, 0, 1, 1 ]
+//! [3]
+
+
+//! [4]
+QBitArray().isNull(); // returns true
+QBitArray().isEmpty(); // returns true
+
+QBitArray(0).isNull(); // returns false
+QBitArray(0).isEmpty(); // returns true
+
+QBitArray(3).isNull(); // returns false
+QBitArray(3).isEmpty(); // returns false
+//! [4]
+
+
+//! [5]
+QBitArray().isNull(); // returns true
+QBitArray(0).isNull(); // returns false
+QBitArray(3).isNull(); // returns false
+//! [5]
+
+
+//! [6]
+QBitArray ba(8);
+ba.fill(true);
+// ba: [ 1, 1, 1, 1, 1, 1, 1, 1 ]
+
+ba.fill(false, 2);
+// ba: [ 0, 0 ]
+//! [6]
+
+
+//! [7]
+QBitArray a(3);
+a[0] = false;
+a[1] = true;
+a[2] = a[0] ^ a[1];
+//! [7]
+
+
+//! [8]
+QBitArray a(3);
+QBitArray b(2);
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+a &= b; // a: [ 1, 0, 0 ]
+//! [8]
+
+
+//! [9]
+QBitArray a(3);
+QBitArray b(2);
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+a |= b; // a: [ 1, 1, 1 ]
+//! [9]
+
+
+//! [10]
+QBitArray a(3);
+QBitArray b(2);
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+a ^= b; // a: [ 0, 1, 1 ]
+//! [10]
+
+
+//! [11]
+QBitArray a(3);
+QBitArray b;
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b = ~a; // b: [ 0, 1, 0 ]
+//! [11]
+
+
+//! [12]
+QBitArray a(3);
+QBitArray b(2);
+QBitArray c;
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+c = a & b; // c: [ 1, 0, 0 ]
+//! [12]
+
+
+//! [13]
+QBitArray a(3);
+QBitArray b(2);
+QBitArray c;
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+c = a | b; // c: [ 1, 1, 1 ]
+//! [13]
+
+
+//! [14]
+QBitArray a(3);
+QBitArray b(2);
+QBitArray c;
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+c = a ^ b; // c: [ 0, 1, 1 ]
+//! [14]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
new file mode 100644
index 0000000000..a232f490b2
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
@@ -0,0 +1,421 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+QByteArray ba("Hello");
+//! [0]
+
+
+//! [1]
+QByteArray ba;
+ba.resize(5);
+ba[0] = 0x3c;
+ba[1] = 0xb8;
+ba[2] = 0x64;
+ba[3] = 0x18;
+ba[4] = 0xca;
+//! [1]
+
+
+//! [2]
+for (int i = 0; i < ba.size(); ++i) {
+ if (ba.at(i) >= 'a' && ba.at(i) <= 'f')
+ cout << "Found character in range [a-f]" << endl;
+}
+//! [2]
+
+
+//! [3]
+QByteArray x("and");
+x.prepend("rock "); // x == "rock and"
+x.append(" roll"); // x == "rock and roll"
+x.replace(5, 3, "&"); // x == "rock & roll"
+//! [3]
+
+
+//! [4]
+QByteArray ba("We must be <b>bold</b>, very <b>bold</b>");
+int j = 0;
+while ((j = ba.indexOf("<b>", j)) != -1) {
+ cout << "Found <b> tag at index position " << j << endl;
+ ++j;
+}
+//! [4]
+
+
+//! [5]
+QByteArray().isNull(); // returns true
+QByteArray().isEmpty(); // returns true
+
+QByteArray("").isNull(); // returns false
+QByteArray("").isEmpty(); // returns true
+
+QByteArray("abc").isNull(); // returns false
+QByteArray("abc").isEmpty(); // returns false
+//! [5]
+
+
+//! [6]
+QByteArray ba("Hello");
+int n = ba.size(); // n == 5
+ba.data()[0]; // returns 'H'
+ba.data()[4]; // returns 'o'
+ba.data()[5]; // returns '\0'
+//! [6]
+
+
+//! [7]
+QByteArray().isEmpty(); // returns true
+QByteArray("").isEmpty(); // returns true
+QByteArray("abc").isEmpty(); // returns false
+//! [7]
+
+
+//! [8]
+QByteArray ba("Hello world");
+char *data = ba.data();
+while (*data) {
+ cout << "[" << *data << "]" << endl;
+ ++data;
+}
+//! [8]
+
+
+//! [9]
+QByteArray ba;
+for (int i = 0; i < 10; ++i)
+ ba[i] = 'A' + i;
+// ba == "ABCDEFGHIJ"
+//! [9]
+
+
+//! [10]
+QByteArray ba("Stockholm");
+ba.truncate(5); // ba == "Stock"
+//! [10]
+
+
+//! [11]
+QByteArray ba("STARTTLS\r\n");
+ba.chop(2); // ba == "STARTTLS"
+//! [11]
+
+
+//! [12]
+QByteArray x("free");
+QByteArray y("dom");
+x += y;
+// x == "freedom"
+//! [12]
+
+
+//! [13]
+QByteArray().isNull(); // returns true
+QByteArray("").isNull(); // returns false
+QByteArray("abc").isNull(); // returns false
+//! [13]
+
+
+//! [14]
+QByteArray ba("Istambul");
+ba.fill('o');
+// ba == "oooooooo"
+
+ba.fill('X', 2);
+// ba == "XX"
+//! [14]
+
+
+//! [15]
+QByteArray x("ship");
+QByteArray y("air");
+x.prepend(y);
+// x == "airship"
+//! [15]
+
+
+//! [16]
+QByteArray x("free");
+QByteArray y("dom");
+x.append(y);
+// x == "freedom"
+//! [16]
+
+
+//! [17]
+QByteArray ba("Meal");
+ba.insert(1, QByteArray("ontr"));
+// ba == "Montreal"
+//! [17]
+
+
+//! [18]
+QByteArray ba("Montreal");
+ba.remove(1, 4);
+// ba == "Meal"
+//! [18]
+
+
+//! [19]
+QByteArray x("Say yes!");
+QByteArray y("no");
+x.replace(4, 3, y);
+// x == "Say no!"
+//! [19]
+
+
+//! [20]
+QByteArray ba("colour behaviour flavour neighbour");
+ba.replace(QByteArray("ou"), QByteArray("o"));
+// ba == "color behavior flavor neighbor"
+//! [20]
+
+
+//! [21]
+QByteArray x("sticky question");
+QByteArray y("sti");
+x.indexOf(y); // returns 0
+x.indexOf(y, 1); // returns 10
+x.indexOf(y, 10); // returns 10
+x.indexOf(y, 11); // returns -1
+//! [21]
+
+
+//! [22]
+QByteArray ba("ABCBA");
+ba.indexOf("B"); // returns 1
+ba.indexOf("B", 1); // returns 1
+ba.indexOf("B", 2); // returns 3
+ba.indexOf("X"); // returns -1
+//! [22]
+
+
+//! [23]
+QByteArray x("crazy azimuths");
+QByteArray y("az");
+x.lastIndexOf(y); // returns 6
+x.lastIndexOf(y, 6); // returns 6
+x.lastIndexOf(y, 5); // returns 2
+x.lastIndexOf(y, 1); // returns -1
+//! [23]
+
+
+//! [24]
+QByteArray ba("ABCBA");
+ba.lastIndexOf("B"); // returns 3
+ba.lastIndexOf("B", 3); // returns 3
+ba.lastIndexOf("B", 2); // returns 1
+ba.lastIndexOf("X"); // returns -1
+//! [24]
+
+
+//! [25]
+QByteArray url("ftp://ftp.qt.nokia.com/");
+if (url.startsWith("ftp:"))
+ ...
+//! [25]
+
+
+//! [26]
+QByteArray url("http://qt.nokia.com/index.html");
+if (url.endsWith(".html"))
+ ...
+//! [26]
+
+
+//! [27]
+QByteArray x("Pineapple");
+QByteArray y = x.left(4);
+// y == "Pine"
+//! [27]
+
+
+//! [28]
+QByteArray x("Pineapple");
+QByteArray y = x.right(5);
+// y == "apple"
+//! [28]
+
+
+//! [29]
+QByteArray x("Five pineapples");
+QByteArray y = x.mid(5, 4); // y == "pine"
+QByteArray z = x.mid(5); // z == "pineapples"
+//! [29]
+
+
+//! [30]
+QByteArray x("Qt by NOKIA");
+QByteArray y = x.toLower();
+// y == "qt by nokia"
+//! [30]
+
+
+//! [31]
+QByteArray x("Qt by NOKIA");
+QByteArray y = x.toUpper();
+// y == "QT BY NOKIA"
+//! [31]
+
+
+//! [32]
+QByteArray ba(" lots\t of\nwhitespace\r\n ");
+ba = ba.simplified();
+// ba == "lots of whitespace";
+//! [32]
+
+
+//! [33]
+QByteArray ba(" lots\t of\nwhitespace\r\n ");
+ba = ba.trimmed();
+// ba == "lots\t of\nwhitespace";
+//! [33]
+
+
+//! [34]
+QByteArray x("apple");
+QByteArray y = x.leftJustified(8, '.'); // y == "apple..."
+//! [34]
+
+
+//! [35]
+QByteArray x("apple");
+QByteArray y = x.rightJustified(8, '.'); // y == "...apple"
+//! [35]
+
+
+//! [36]
+QByteArray str("FF");
+bool ok;
+int hex = str.toInt(&ok, 16); // hex == 255, ok == true
+int dec = str.toInt(&ok, 10); // dec == 0, ok == false
+//! [36]
+
+
+//! [37]
+QByteArray str("FF");
+bool ok;
+long hex = str.toLong(&ok, 16); // hex == 255, ok == true
+long dec = str.toLong(&ok, 10); // dec == 0, ok == false
+//! [37]
+
+
+//! [38]
+QByteArray string("1234.56");
+double a = string.toDouble(); // a == 1234.56
+//! [38]
+
+
+//! [39]
+QByteArray text("Qt is great!");
+text.toBase64(); // returns "UXQgaXMgZ3JlYXQh"
+//! [39]
+
+
+//! [40]
+QByteArray ba;
+int n = 63;
+ba.setNum(n); // ba == "63"
+ba.setNum(n, 16); // ba == "3f"
+//! [40]
+
+
+//! [41]
+int n = 63;
+QByteArray::number(n); // returns "63"
+QByteArray::number(n, 16); // returns "3f"
+QByteArray::number(n, 16).toUpper(); // returns "3F"
+//! [41]
+
+
+//! [42]
+QByteArray ba = QByteArray::number(12.3456, 'E', 3);
+// ba == 1.235E+01
+//! [42]
+
+
+//! [43]
+ static const char mydata[] = {
+ 0x00, 0x00, 0x03, 0x84, 0x78, 0x9c, 0x3b, 0x76,
+ 0xec, 0x18, 0xc3, 0x31, 0x0a, 0xf1, 0xcc, 0x99,
+ ...
+ 0x6d, 0x5b
+};
+
+QByteArray data = QByteArray::fromRawData(mydata, sizeof(mydata));
+QDataStream in(&data, QIODevice::ReadOnly);
+...
+//! [43]
+
+
+//! [44]
+QByteArray text = QByteArray::fromBase64("UXQgaXMgZ3JlYXQh");
+text.data(); // returns "Qt is great!"
+//! [44]
+
+
+//! [45]
+QByteArray text = QByteArray::fromHex("517420697320677265617421");
+text.data(); // returns "Qt is great!"
+//! [45]
+
+//! [46]
+QString tmp = "test";
+QByteArray text = tmp.toLocal8Bit();
+char *data = new char[text.size()]
+strcpy(data, text.data());
+delete [] data;
+//! [46]
+
+//! [47]
+QString tmp = "test";
+QByteArray text = tmp.toLocal8Bit();
+char *data = new char[text.size() + 1]
+strcpy(data, text.data());
+delete [] data;
+//! [47]
+
+}
+
+
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp
new file mode 100644
index 0000000000..59cd67fe6d
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QDate d1(1995, 5, 17); // May 17, 1995
+QDate d2(1995, 5, 20); // May 20, 1995
+d1.daysTo(d2); // returns 3
+d2.daysTo(d1); // returns -3
+//! [0]
+
+
+//! [1]
+QDate date = QDate::fromString("1MM12car2003", "d'MM'MMcaryyyy");
+// date is 1 December 2003
+//! [1]
+
+
+//! [2]
+QDate date = QDate::fromString("130", "Md"); // invalid
+//! [2]
+
+
+//! [3]
+QDate::fromString("1.30", "M.d"); // January 30 1900
+QDate::fromString("20000110", "yyyyMMdd"); // January 10, 2000
+QDate::fromString("20000110", "yyyyMd"); // January 10, 2000
+//! [3]
+
+
+//! [4]
+QDate::isValid(2002, 5, 17); // true
+QDate::isValid(2002, 2, 30); // false (Feb 30 does not exist)
+QDate::isValid(2004, 2, 29); // true (2004 is a leap year)
+QDate::isValid(2000, 2, 29); // true (2000 is a leap year)
+QDate::isValid(2006, 2, 29); // false (2006 is not a leap year)
+QDate::isValid(2100, 2, 29); // false (2100 is not a leap year)
+QDate::isValid(1202, 6, 6); // true (even though 1202 is pre-Gregorian)
+//! [4]
+
+
+//! [5]
+QTime n(14, 0, 0); // n == 14:00:00
+QTime t;
+t = n.addSecs(70); // t == 14:01:10
+t = n.addSecs(-70); // t == 13:58:50
+t = n.addSecs(10 * 60 * 60 + 5); // t == 00:00:05
+t = n.addSecs(-15 * 60 * 60); // t == 23:00:00
+//! [5]
+
+
+//! [6]
+QTime time = QTime::fromString("1mm12car00", "m'mm'hcarss");
+// time is 12:01.00
+//! [6]
+
+
+//! [7]
+QTime time = QTime::fromString("00:710", "hh:ms"); // invalid
+//! [7]
+
+
+//! [8]
+QTime time = QTime::fromString("1.30", "m.s");
+// time is 00:01:30.000
+//! [8]
+
+
+//! [9]
+QTime::isValid(21, 10, 30); // returns true
+QTime::isValid(22, 5, 62); // returns false
+//! [9]
+
+
+//! [10]
+QTime t;
+t.start();
+some_lengthy_task();
+qDebug("Time elapsed: %d ms", t.elapsed());
+//! [10]
+
+
+//! [11]
+QDateTime now = QDateTime::currentDateTime();
+QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0));
+qDebug("There are %d seconds to Christmas", now.secsTo(xmas));
+//! [11]
+
+
+//! [12]
+QTime time1 = QTime::fromString("131", "HHh");
+// time1 is 13:00:00
+QTime time1 = QTime::fromString("1apA", "1amAM");
+// time1 is 01:00:00
+
+QDateTime dateTime2 = QDateTime::fromString("M1d1y9800:01:02",
+ "'M'M'd'd'y'yyhh:mm:ss");
+// dateTime is 1 January 1998 00:01:02
+//! [12]
+
+
+//! [13]
+QDateTime dateTime = QDateTime::fromString("130", "Mm"); // invalid
+//! [13]
+
+
+//! [14]
+QDateTime dateTime = QDateTime::fromString("1.30.1", "M.d.s");
+// dateTime is January 30 in 1900 at 00:00:01.
+//! [14]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qeasingcurve.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qeasingcurve.cpp
new file mode 100644
index 0000000000..3aa0d986af
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qeasingcurve.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+qreal myEasingFunction(qreal progress);
+//! [0]
+
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
new file mode 100644
index 0000000000..2fa73bac46
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
@@ -0,0 +1,299 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QHash<QString, int> hash;
+//! [0]
+
+
+//! [1]
+hash["one"] = 1;
+hash["three"] = 3;
+hash["seven"] = 7;
+//! [1]
+
+
+//! [2]
+hash.insert("twelve", 12);
+//! [2]
+
+
+//! [3]
+int num1 = hash["thirteen"];
+int num2 = hash.value("thirteen");
+//! [3]
+
+
+//! [4]
+int timeout = 30;
+if (hash.contains("TIMEOUT"))
+ timeout = hash.value("TIMEOUT");
+//! [4]
+
+
+//! [5]
+int timeout = hash.value("TIMEOUT", 30);
+//! [5]
+
+
+//! [6]
+// WRONG
+QHash<int, QWidget *> hash;
+...
+for (int i = 0; i < 1000; ++i) {
+ if (hash[i] == okButton)
+ cout << "Found button at index " << i << endl;
+}
+//! [6]
+
+
+//! [7]
+QHashIterator<QString, int> i(hash);
+while (i.hasNext()) {
+ i.next();
+ cout << i.key() << ": " << i.value() << endl;
+}
+//! [7]
+
+
+//! [8]
+QHash<QString, int>::const_iterator i = hash.constBegin();
+while (i != hash.constEnd()) {
+ cout << i.key() << ": " << i.value() << endl;
+ ++i;
+}
+//! [8]
+
+
+//! [9]
+hash.insert("plenty", 100);
+hash.insert("plenty", 2000);
+// hash.value("plenty") == 2000
+//! [9]
+
+
+//! [10]
+QList<int> values = hash.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [10]
+
+
+//! [11]
+QHash<QString, int>::iterator i = hash.find("plenty");
+while (i != hash.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [11]
+
+
+//! [12]
+QHash<QString, int> hash;
+...
+foreach (int value, hash)
+ cout << value << endl;
+//! [12]
+
+
+//! [13]
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+class Employee
+{
+public:
+ Employee() {}
+ Employee(const QString &name, const QDate &dateOfBirth);
+ ...
+
+private:
+ QString myName;
+ QDate myDateOfBirth;
+};
+
+inline bool operator==(const Employee &e1, const Employee &e2)
+{
+ return e1.name() == e2.name()
+ && e1.dateOfBirth() == e2.dateOfBirth();
+}
+
+inline uint qHash(const Employee &key, uint seed)
+{
+ return qHash(key.name(), seed) ^ key.dateOfBirth().day();
+}
+
+#endif // EMPLOYEE_H
+//! [13]
+
+
+//! [14]
+QHash<QString, int> hash;
+hash.reserve(20000);
+for (int i = 0; i < 20000; ++i)
+ hash.insert(keys[i], values[i]);
+//! [14]
+
+
+//! [15]
+QHash<QObject *, int> objectHash;
+...
+QHash<QObject *, int>::iterator i = objectHash.find(obj);
+while (i != objectHash.end() && i.key() == obj) {
+ if (i.value() == 0) {
+ i = objectHash.erase(i);
+ } else {
+ ++i;
+ }
+}
+//! [15]
+
+
+//! [16]
+QHash<QString, int> hash;
+...
+QHash<QString, int>::const_iterator i = hash.find("HDR");
+while (i != hash.end() && i.key() == "HDR") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [16]
+
+
+//! [17]
+QHash<QString, int> hash;
+hash.insert("January", 1);
+hash.insert("February", 2);
+...
+hash.insert("December", 12);
+
+QHash<QString, int>::iterator i;
+for (i = hash.begin(); i != hash.end(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [17]
+
+
+//! [18]
+QHash<QString, int>::iterator i;
+for (i = hash.begin(); i != hash.end(); ++i)
+ i.value() += 2;
+//! [18]
+
+
+//! [19]
+QHash<QString, int>::iterator i = hash.begin();
+while (i != hash.end()) {
+ if (i.key().startsWith("_"))
+ i = hash.erase(i);
+ else
+ ++i;
+}
+//! [19]
+
+
+//! [20]
+QHash<QString, int>::iterator i = hash.begin();
+while (i != hash.end()) {
+ QHash<QString, int>::iterator prev = i;
+ ++i;
+ if (prev.key().startsWith("_"))
+ hash.erase(prev);
+}
+//! [20]
+
+
+//! [21]
+// WRONG
+while (i != hash.end()) {
+ if (i.key().startsWith("_"))
+ hash.erase(i);
+ ++i;
+}
+//! [21]
+
+
+//! [22]
+if (i.key() == "Hello")
+ i.value() = "Bonjour";
+//! [22]
+
+
+//! [23]
+QHash<QString, int> hash;
+hash.insert("January", 1);
+hash.insert("February", 2);
+...
+hash.insert("December", 12);
+
+QHash<QString, int>::const_iterator i;
+for (i = hash.constBegin(); i != hash.constEnd(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [23]
+
+
+//! [24]
+QMultiHash<QString, int> hash1, hash2, hash3;
+
+hash1.insert("plenty", 100);
+hash1.insert("plenty", 2000);
+// hash1.size() == 2
+
+hash2.insert("plenty", 5000);
+// hash2.size() == 1
+
+hash3 = hash1 + hash2;
+// hash3.size() == 3
+//! [24]
+
+
+//! [25]
+QList<int> values = hash.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [25]
+
+
+//! [26]
+QMultiHash<QString, int>::iterator i = hash.find("plenty");
+while (i != hash.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [26]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp
new file mode 100644
index 0000000000..b9861f16c0
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLinkedList<int> integerList;
+QLinkedList<QTime> timeList;
+//! [0]
+
+
+//! [1]
+QLinkedList<QString> list;
+list << "one" << "two" << "three";
+// list: ["one", "two", "three"]
+//! [1]
+
+
+//! [2]
+QLinkedList<QWidget *> list;
+...
+while (!list.isEmpty())
+ delete list.takeFirst();
+//! [2]
+
+
+//! [3]
+QLinkedList<QString> list;
+list.append("one");
+list.append("two");
+list.append("three");
+// list: ["one", "two", "three"]
+//! [3]
+
+
+//! [4]
+QLinkedList<QString> list;
+list.prepend("one");
+list.prepend("two");
+list.prepend("three");
+// list: ["three", "two", "one"]
+//! [4]
+
+
+//! [5]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeAll("sun");
+// list: ["cloud", "rain"]
+//! [5]
+
+
+//! [6]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeOne("sun");
+// list: ["cloud", "sun", "rain"]
+//! [6]
+
+
+//! [7]
+QLinkedList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QLinkedList<QString>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ cout << *i << endl;
+//! [7]
+
+
+//! [8]
+QLinkedList<QString> list;
+...
+QLinkedList<QString>::iterator it = qFind(list.begin(),
+ list.end(), "Joel");
+if (it != list.end())
+ cout << "Found Joel" << endl;
+//! [8]
+
+
+//! [9]
+QLinkedList<int>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ *i += 2;
+//! [9]
+
+
+//! [10]
+QLinkedList<QString> list;
+...
+QLinkedList<QString>::iterator i = list.begin();
+while (i != list.end()) {
+ if ((*i).startsWith("_"))
+ i = list.erase(i);
+ else
+ ++i;
+}
+//! [10]
+
+
+//! [11]
+QLinkedList<QString>::iterator i = list.begin();
+while (i != list.end()) {
+ QLinkedList<QString>::iterator previous = i;
+ ++i;
+ if ((*previous).startsWith("_"))
+ list.erase(previous);
+}
+//! [11]
+
+
+//! [12]
+// WRONG
+while (i != list.end()) {
+ if ((*i).startsWith("_"))
+ list.erase(i);
+ ++i;
+}
+//! [12]
+
+
+//! [13]
+if (*it == "Hello")
+ *it = "Bonjour";
+//! [13]
+
+
+//! [14]
+QLinkedList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QLinkedList<QString>::const_iterator i;
+for (i = list.constBegin(); i != list.constEnd(); ++i)
+ cout << *i << endl;
+//! [14]
+
+
+//! [15]
+QLinkedList<QString> list;
+...
+QLinkedList<QString>::iterator it = qFind(list.constBegin(),
+ list.constEnd(), "Joel");
+if (it != list.constEnd())
+ cout << "Found Joel" << endl;
+//! [15]
+
+
+//! [16]
+std::list<double> stdlist;
+list.push_back(1.2);
+list.push_back(0.5);
+list.push_back(3.14);
+
+QLinkedList<double> list = QLinkedList<double>::fromStdList(stdlist);
+//! [16]
+
+
+//! [17]
+QLinkedList<double> list;
+list << 1.2 << 0.5 << 3.14;
+
+std::list<double> stdlist = list.toStdList();
+//! [17]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
new file mode 100644
index 0000000000..dca5473cd6
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
@@ -0,0 +1,267 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QList<int> integerList;
+QList<QDate> dateList;
+//! [0]
+
+
+//! [1]
+QList<QString> list;
+list << "one" << "two" << "three";
+// list: ["one", "two", "three"]
+//! [1]
+
+
+//! [2]
+if (list[0] == "Bob")
+ list[0] = "Robert";
+//! [2]
+
+
+//! [3]
+for (int i = 0; i < list.size(); ++i) {
+ if (list.at(i) == "Jane")
+ cout << "Found Jane at position " << i << endl;
+}
+//! [3]
+
+
+//! [4]
+QList<QWidget *> list;
+...
+while (!list.isEmpty())
+ delete list.takeFirst();
+//! [4]
+
+
+//! [5]
+int i = list.indexOf("Jane");
+if (i != -1)
+ cout << "First occurrence of Jane is at position " << i << endl;
+//! [5]
+
+
+//! [6]
+QList<QString> list;
+list.append("one");
+list.append("two");
+list.append("three");
+// list: ["one", "two", "three"]
+//! [6]
+
+
+//! [7]
+QList<QString> list;
+list.prepend("one");
+list.prepend("two");
+list.prepend("three");
+// list: ["three", "two", "one"]
+//! [7]
+
+
+//! [8]
+QList<QString> list;
+list << "alpha" << "beta" << "delta";
+list.insert(2, "gamma");
+// list: ["alpha", "beta", "gamma", "delta"]
+//! [8]
+
+
+//! [9]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeAll("sun");
+// list: ["cloud", "rain"]
+//! [9]
+
+
+//! [10]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeOne("sun");
+// list: ["cloud", ,"sun", "rain"]
+//! [10]
+
+
+//! [11]
+QList<QString> list;
+list << "A" << "B" << "C" << "D" << "E" << "F";
+list.move(1, 4);
+// list: ["A", "C", "D", "E", "B", "F"]
+//! [11]
+
+
+//! [12]
+QList<QString> list;
+list << "A" << "B" << "C" << "D" << "E" << "F";
+list.swap(1, 4);
+// list: ["A", "E", "C", "D", "B", "F"]
+//! [12]
+
+
+//! [13]
+QList<QString> list;
+list << "A" << "B" << "C" << "B" << "A";
+list.indexOf("B"); // returns 1
+list.indexOf("B", 1); // returns 1
+list.indexOf("B", 2); // returns 3
+list.indexOf("X"); // returns -1
+//! [13]
+
+
+//! [14]
+QList<QString> list;
+list << "A" << "B" << "C" << "B" << "A";
+list.lastIndexOf("B"); // returns 3
+list.lastIndexOf("B", 3); // returns 3
+list.lastIndexOf("B", 2); // returns 1
+list.lastIndexOf("X"); // returns -1
+//! [14]
+
+
+//! [15]
+QList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QList<QString>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ cout << *i << endl;
+//! [15]
+
+
+//! [16]
+QList<int>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ *i += 2;
+//! [16]
+
+
+//! [17]
+QList<QWidget *> list;
+...
+qDeleteAll(list.begin(), list.end());
+//! [17]
+
+
+//! [18]
+if (*it == "Hello")
+ *it = "Bonjour";
+//! [18]
+
+
+//! [19]
+QList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QList<QString>::const_iterator i;
+for (i = list.constBegin(); i != list.constEnd(); ++i)
+ cout << *i << endl;
+//! [19]
+
+
+//! [20]
+QList<QWidget *> list;
+...
+qDeleteAll(list.constBegin(), list.constEnd());
+//! [20]
+
+
+//! [21]
+QVector<double> vect;
+vect << 20.0 << 30.0 << 40.0 << 50.0;
+
+QList<double> list = QVector<T>::fromVector(vect);
+// list: [20.0, 30.0, 40.0, 50.0]
+//! [21]
+
+
+//! [22]
+QStringList list;
+list << "Sven" << "Kim" << "Ola";
+
+QVector<QString> vect = list.toVector();
+// vect: ["Sven", "Kim", "Ola"]
+//! [22]
+
+
+//! [23]
+QSet<int> set;
+set << 20 << 30 << 40 << ... << 70;
+
+QList<int> list = QList<int>::fromSet(set);
+qSort(list);
+//! [23]
+
+
+//! [24]
+QStringList list;
+list << "Julia" << "Mike" << "Mike" << "Julia" << "Julia";
+
+QSet<QString> set = list.toSet();
+set.contains("Julia"); // returns true
+set.contains("Mike"); // returns true
+set.size(); // returns 2
+//! [24]
+
+
+//! [25]
+std::list<double> stdlist;
+list.push_back(1.2);
+list.push_back(0.5);
+list.push_back(3.14);
+
+QList<double> list = QList<double>::fromStdList(stdlist);
+//! [25]
+
+
+//! [26]
+QList<double> list;
+list << 1.2 << 0.5 << 3.14;
+
+std::list<double> stdlist = list.toStdList();
+//! [26]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlocale.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlocale.cpp
new file mode 100644
index 0000000000..2e3b599910
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlocale.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLocale egyptian(QLocale::Arabic, QLocale::Egypt);
+QString s1 = egyptian.toString(1.571429E+07, 'e');
+QString s2 = egyptian.toString(10);
+
+double d = egyptian.toDouble(s1);
+int i = egyptian.toInt(s2);
+//! [0]
+
+
+//! [1]
+QLocale::setDefault(QLocale(QLocale::Hebrew, QLocale::Israel));
+QLocale hebrew; // Constructs a default QLocale
+QString s1 = hebrew.toString(15714.3, 'e');
+
+bool ok;
+double d;
+
+QLocale::setDefault(QLocale::C);
+d = QString("1234,56").toDouble(&ok); // ok == false
+d = QString("1234.56").toDouble(&ok); // ok == true, d == 1234.56
+
+QLocale::setDefault(QLocale::German);
+d = QString("1234,56").toDouble(&ok); // ok == true, d == 1234.56
+d = QString("1234.56").toDouble(&ok); // ok == true, d == 1234.56
+
+QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
+str = QString("%1 %L2 %L3")
+ .arg(12345).arg(12345).arg(12345, 0, 16);
+// str == "12345 12,345 3039"
+//! [1]
+
+
+//! [2]
+QLocale korean("ko");
+QLocale swiss("de_CH");
+//! [2]
+
+
+//! [3]
+bool ok;
+double d;
+
+QLocale c(QLocale::C);
+d = c.toDouble( "1234.56", &ok ); // ok == true, d == 1234.56
+d = c.toDouble( "1,234.56", &ok ); // ok == true, d == 1234.56
+d = c.toDouble( "1234,56", &ok ); // ok == false
+
+QLocale german(QLocale::German);
+d = german.toDouble( "1234,56", &ok ); // ok == true, d == 1234.56
+d = german.toDouble( "1.234,56", &ok ); // ok == true, d == 1234.56
+d = german.toDouble( "1234.56", &ok ); // ok == false
+
+d = german.toDouble( "1.234", &ok ); // ok == true, d == 1234.0
+//! [3]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp
new file mode 100644
index 0000000000..2b9c1fb73e
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp
@@ -0,0 +1,313 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QMap<QString, int> map;
+//! [0]
+
+
+//! [1]
+map["one"] = 1;
+map["three"] = 3;
+map["seven"] = 7;
+//! [1]
+
+
+//! [2]
+map.insert("twelve", 12);
+//! [2]
+
+
+//! [3]
+int num1 = map["thirteen"];
+int num2 = map.value("thirteen");
+//! [3]
+
+
+//! [4]
+int timeout = 30;
+if (map.contains("TIMEOUT"))
+ timeout = map.value("TIMEOUT");
+//! [4]
+
+
+//! [5]
+int timeout = map.value("TIMEOUT", 30);
+//! [5]
+
+
+//! [6]
+// WRONG
+QMap<int, QWidget *> map;
+...
+for (int i = 0; i < 1000; ++i) {
+ if (map[i] == okButton)
+ cout << "Found button at index " << i << endl;
+}
+//! [6]
+
+
+//! [7]
+QMapIterator<QString, int> i(map);
+while (i.hasNext()) {
+ i.next();
+ cout << i.key() << ": " << i.value() << endl;
+}
+//! [7]
+
+
+//! [8]
+QMap<QString, int>::const_iterator i = map.constBegin();
+while (i != map.constEnd()) {
+ cout << i.key() << ": " << i.value() << endl;
+ ++i;
+}
+//! [8]
+
+
+//! [9]
+map.insert("plenty", 100);
+map.insert("plenty", 2000);
+// map.value("plenty") == 2000
+//! [9]
+
+
+//! [10]
+QList<int> values = map.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [10]
+
+
+//! [11]
+QMap<QString, int>::iterator i = map.find("plenty");
+while (i != map.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [11]
+
+
+//! [12]
+QMap<QString, int> map;
+...
+foreach (int value, map)
+ cout << value << endl;
+//! [12]
+
+
+//! [13]
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+class Employee
+{
+public:
+ Employee() {}
+ Employee(const QString &name, const QDate &dateOfBirth);
+ ...
+
+private:
+ QString myName;
+ QDate myDateOfBirth;
+};
+
+inline bool operator<(const Employee &e1, const Employee &e2)
+{
+ if (e1.name() != e2.name())
+ return e1.name() < e2.name();
+ return e1.dateOfBirth() < e2.dateOfBirth();
+}
+
+#endif // EMPLOYEE_H
+//! [13]
+
+
+//! [14]
+QMap<QString, int> map;
+...
+QMap<QString, int>::const_iterator i = map.find("HDR");
+while (i != map.end() && i.key() == "HDR") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [14]
+
+
+//! [15]
+QMap<int, QString> map;
+map.insert(1, "one");
+map.insert(5, "five");
+map.insert(10, "ten");
+
+map.lowerBound(0); // returns iterator to (1, "one")
+map.lowerBound(1); // returns iterator to (1, "one")
+map.lowerBound(2); // returns iterator to (5, "five")
+map.lowerBound(10); // returns iterator to (10, "ten")
+map.lowerBound(999); // returns end()
+//! [15]
+
+
+//! [16]
+QMap<QString, int> map;
+...
+QMap<QString, int>::const_iterator i = map.lowerBound("HDR");
+QMap<QString, int>::const_iterator upperBound = map.upperBound("HDR");
+while (i != upperBound) {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [16]
+
+
+//! [17]
+QMap<int, QString> map;
+map.insert(1, "one");
+map.insert(5, "five");
+map.insert(10, "ten");
+
+map.upperBound(0); // returns iterator to (1, "one")
+map.upperBound(1); // returns iterator to (5, "five")
+map.upperBound(2); // returns iterator to (5, "five")
+map.upperBound(10); // returns end()
+map.upperBound(999); // returns end()
+//! [17]
+
+
+//! [18]
+QMap<QString, int> map;
+map.insert("January", 1);
+map.insert("February", 2);
+...
+map.insert("December", 12);
+
+QMap<QString, int>::iterator i;
+for (i = map.begin(); i != map.end(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [18]
+
+
+//! [19]
+QMap<QString, int>::iterator i;
+for (i = map.begin(); i != map.end(); ++i)
+ i.value() += 2;
+//! [19]
+
+
+//! [20]
+QMap<QString, int>::iterator i = map.begin();
+while (i != map.end()) {
+ if (i.key().startsWith("_"))
+ i = map.erase(i);
+ else
+ ++i;
+}
+//! [20]
+
+
+//! [21]
+QMap<QString, int>::iterator i = map.begin();
+while (i != map.end()) {
+ QMap<QString, int>::iterator prev = i;
+ ++i;
+ if (prev.key().startsWith("_"))
+ map.erase(prev);
+}
+//! [21]
+
+
+//! [22]
+// WRONG
+while (i != map.end()) {
+ if (i.key().startsWith("_"))
+ map.erase(i);
+ ++i;
+}
+//! [22]
+
+
+//! [23]
+if (i.key() == "Hello")
+ i.value() = "Bonjour";
+//! [23]
+
+
+//! [24]
+QMap<QString, int> map;
+map.insert("January", 1);
+map.insert("February", 2);
+...
+map.insert("December", 12);
+
+QMap<QString, int>::const_iterator i;
+for (i = map.constBegin(); i != map.constEnd(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [24]
+
+
+//! [25]
+QMultiMap<QString, int> map1, map2, map3;
+
+map1.insert("plenty", 100);
+map1.insert("plenty", 2000);
+// map1.size() == 2
+
+map2.insert("plenty", 5000);
+// map2.size() == 1
+
+map3 = map1 + map2;
+// map3.size() == 3
+//! [25]
+
+
+//! [26]
+QList<int> values = map.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [26]
+
+
+//! [27]
+QMultiMap<QString, int>::iterator i = map.find("plenty");
+while (i != map.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [27]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp
new file mode 100644
index 0000000000..4f48fcbcb1
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QPoint p;
+
+p.setX(p.x() + 1);
+p += QPoint(1, 0);
+p.rx()++;
+//! [0]
+
+
+//! [1]
+QPoint p(1, 2);
+p.rx()--; // p becomes (0, 2)
+//! [1]
+
+
+//! [2]
+QPoint p(1, 2);
+p.ry()++; // p becomes (1, 3)
+//! [2]
+
+
+//! [3]
+QPoint p( 3, 7);
+QPoint q(-1, 4);
+p += q; // p becomes (2, 11)
+//! [3]
+
+
+//! [4]
+QPoint p( 3, 7);
+QPoint q(-1, 4);
+p -= q; // p becomes (4, 3)
+//! [4]
+
+
+//! [5]
+QPoint p(-1, 4);
+p *= 2.5; // p becomes (-3, 10)
+//! [5]
+
+
+//! [6]
+QPoint p(-3, 10);
+p /= 2.5; // p becomes (-1, 4)
+//! [6]
+
+
+//! [7]
+QPoint oldPosition;
+
+MyWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ QPoint point = event->pos() - oldPosition;
+ if (point.manhattanLength() > 3)
+ // the mouse has moved more than 3 pixels since the oldPosition
+}
+//! [7]
+
+
+//! [8]
+double trueLength = sqrt(pow(x(), 2) + pow(y(), 2));
+//! [8]
+
+
+//! [9]
+QPointF p;
+
+p.setX(p.x() + 1.0);
+p += QPointF(1.0, 0.0);
+p.rx()++;
+//! [9]
+
+
+//! [10]
+ QPointF p(1.1, 2.5);
+ p.rx()--; // p becomes (0.1, 2.5)
+//! [10]
+
+
+//! [11]
+QPointF p(1.1, 2.5);
+p.ry()++; // p becomes (1.1, 3.5)
+//! [11]
+
+
+//! [12]
+QPointF p( 3.1, 7.1);
+QPointF q(-1.0, 4.1);
+p += q; // p becomes (2.1, 11.2)
+//! [12]
+
+
+//! [13]
+QPointF p( 3.1, 7.1);
+QPointF q(-1.0, 4.1);
+p -= q; // p becomes (4.1, 3.0)
+//! [13]
+
+
+//! [14]
+QPointF p(-1.1, 4.1);
+p *= 2.5; // p becomes (-2.75, 10.25)
+//! [14]
+
+
+//! [15]
+QPointF p(-2.75, 10.25);
+p /= 2.5; // p becomes (-1.1, 4.1)
+//! [15]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qqueue.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qqueue.cpp
new file mode 100644
index 0000000000..3a1cf7c1a1
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qqueue.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QQueue<int> queue;
+queue.enqueue(1);
+queue.enqueue(2);
+queue.enqueue(3);
+while (!queue.isEmpty())
+ cout << queue.dequeue() << endl;
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qrect.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qrect.cpp
new file mode 100644
index 0000000000..ebf9118c20
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qrect.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QRect r1(100, 200, 11, 16);
+QRect r2(QPoint(100, 200), QSize(11, 16));
+//! [0]
+
+
+//! [1]
+QRectF r1(100, 200, 11, 16);
+QRectF r2(QPoint(100, 200), QSize(11, 16));
+//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qregexp.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qregexp.cpp
new file mode 100644
index 0000000000..002ae96f23
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qregexp.cpp
@@ -0,0 +1,224 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QRegExp rx("(\\d+)");
+QString str = "Offsets: 12 14 99 231 7";
+QStringList list;
+int pos = 0;
+
+while ((pos = rx.indexIn(str, pos)) != -1) {
+ list << rx.cap(1);
+ pos += rx.matchedLength();
+}
+// list: ["12", "14", "99", "231", "7"]
+//! [0]
+
+
+//! [1]
+QRegExp rx("*.txt");
+rx.setPatternSyntax(QRegExp::Wildcard);
+rx.exactMatch("README.txt"); // returns true
+rx.exactMatch("welcome.txt.bak"); // returns false
+//! [1]
+
+
+//! [2]
+QRegExp rx("ro+m");
+rx.setMinimal(true);
+//! [2]
+
+
+//! [3]
+QRegExp mark("\\b" // word boundary
+ "[Mm]ark" // the word we want to match
+ );
+//! [3]
+
+
+//! [4]
+QRegExp rx("^\\d\\d?$"); // match integers 0 to 99
+rx.indexIn("123"); // returns -1 (no match)
+rx.indexIn("-6"); // returns -1 (no match)
+rx.indexIn("6"); // returns 0 (matched as position 0)
+//! [4]
+
+
+//! [5]
+QRegExp rx("^\\S+$"); // match strings without whitespace
+rx.indexIn("Hello world"); // returns -1 (no match)
+rx.indexIn("This_is-OK"); // returns 0 (matched at position 0)
+//! [5]
+
+
+//! [6]
+QRegExp rx("\\b(mail|letter|correspondence)\\b");
+rx.indexIn("I sent you an email"); // returns -1 (no match)
+rx.indexIn("Please write the letter"); // returns 17
+//! [6]
+
+
+//! [7]
+QString captured = rx.cap(1); // captured == "letter"
+//! [7]
+
+
+//! [8]
+QRegExp rx("&(?!amp;)"); // match ampersands but not &amp;
+QString line1 = "This & that";
+line1.replace(rx, "&amp;");
+// line1 == "This &amp; that"
+QString line2 = "His &amp; hers & theirs";
+line2.replace(rx, "&amp;");
+// line2 == "His &amp; hers &amp; theirs"
+//! [8]
+
+
+//! [9]
+QString str = "One Eric another Eirik, and an Ericsson. "
+ "How many Eiriks, Eric?";
+QRegExp rx("\\b(Eric|Eirik)\\b"); // match Eric or Eirik
+int pos = 0; // where we are in the string
+int count = 0; // how many Eric and Eirik's we've counted
+while (pos >= 0) {
+ pos = rx.indexIn(str, pos);
+ if (pos >= 0) {
+ ++pos; // move along in str
+ ++count; // count our Eric or Eirik
+ }
+}
+//! [9]
+
+
+//! [10]
+str = "Nokia Corporation\tqt.nokia.com\tNorway";
+QString company, web, country;
+rx.setPattern("^([^\t]+)\t([^\t]+)\t([^\t]+)$");
+if (rx.indexIn(str) != -1) {
+ company = rx.cap(1);
+ web = rx.cap(2);
+ country = rx.cap(3);
+}
+//! [10]
+
+
+//! [11]
+QStringList field = str.split("\t");
+//! [11]
+
+
+//! [12]
+QRegExp rx("*.html");
+rx.setPatternSyntax(QRegExp::Wildcard);
+rx.exactMatch("index.html"); // returns true
+rx.exactMatch("default.htm"); // returns false
+rx.exactMatch("readme.txt"); // returns false
+//! [12]
+
+
+//! [13]
+QString str = "offsets: 1.23 .50 71.00 6.00";
+QRegExp rx("\\d*\\.\\d+"); // primitive floating point matching
+int count = 0;
+int pos = 0;
+while ((pos = rx.indexIn(str, pos)) != -1) {
+ ++count;
+ pos += rx.matchedLength();
+}
+// pos will be 9, 14, 18 and finally 24; count will end up as 4
+//! [13]
+
+
+//! [14]
+QRegExp rx("(\\d+)(\\s*)(cm|inch(es)?)");
+int pos = rx.indexIn("Length: 36 inches");
+QStringList list = rx.capturedTexts();
+// list is now ("36 inches", "36", " ", "inches", "es")
+//! [14]
+
+
+//! [15]
+QRegExp rx("(\\d+)(?:\\s*)(cm|inch(?:es)?)");
+int pos = rx.indexIn("Length: 36 inches");
+QStringList list = rx.capturedTexts();
+// list is now ("36 inches", "36", "inches")
+//! [15]
+
+
+//! [16]
+QStringList list = rx.capturedTexts();
+QStringList::iterator it = list.begin();
+while (it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [16]
+
+
+//! [17]
+QRegExp rxlen("(\\d+)(?:\\s*)(cm|inch)");
+int pos = rxlen.indexIn("Length: 189cm");
+if (pos > -1) {
+ QString value = rxlen.cap(1); // "189"
+ QString unit = rxlen.cap(2); // "cm"
+ // ...
+}
+//! [17]
+
+
+//! [18]
+QRegExp rx("/([a-z]+)/([a-z]+)");
+rx.indexIn("Output /dev/null"); // returns 7 (position of /dev/null)
+rx.pos(0); // returns 7 (position of /dev/null)
+rx.pos(1); // returns 8 (position of dev)
+rx.pos(2); // returns 12 (position of null)
+//! [18]
+
+
+//! [19]
+s1 = QRegExp::escape("bingo"); // s1 == "bingo"
+s2 = QRegExp::escape("f(x)"); // s2 == "f\\(x\\)"
+//! [19]
+
+
+//! [20]
+QRegExp rx("(" + QRegExp::escape(name) +
+ "|" + QRegExp::escape(alias) + ")");
+//! [20]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp
new file mode 100644
index 0000000000..cab89d9c9e
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp
@@ -0,0 +1,289 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>.
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QRegularExpression re("a pattern");
+//! [0]
+
+
+//! [1]
+QRegularExpression re;
+re.setPattern("another pattern");
+//! [1]
+
+
+//! [2]
+// matches two digits followed by a space and a word
+QRegularExpression re("\\d\\d \\w+");
+
+// matches a backslash
+QRegularExpression re2("\\\\");
+//! [2]
+
+
+//! [3]
+QRegularExpression re("a third pattern");
+QString pattern = re.pattern(); // pattern == "a third pattern"
+//! [3]
+
+
+//! [4]
+// matches "Qt rocks", but also "QT rocks", "QT ROCKS", "qT rOcKs", etc.
+QRegularExpression re("Qt rocks", QRegularExpression::CaseInsensitiveOption);
+//! [4]
+
+
+//! [5]
+QRegularExpression re("^\\d+$");
+re.setPatternOptions(QRegularExpression::MultilineOption);
+// re matches any line in the subject string that contains only digits (but at least one)
+//! [5]
+
+
+//! [6]
+QRegularExpression re = QRegularExpression("^two.*words$", QRegularExpression::MultilineOption
+ | QRegularExpression::DotMatchesEverythingOption);
+
+QRegularExpression::PatternOptions options = re.patternOptions();
+// options == QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption
+//! [6]
+
+
+//! [7]
+// match two digits followed by a space and a word
+QRegularExpression re("\\d\\d \\w+");
+QRegularExpressionMatch match = re.match("abc123 def");
+bool hasMatch = match.hasMatch(); // true
+//! [7]
+
+
+//! [8]
+QRegularExpression re("\\d\\d \\w+");
+QRegularExpressionMatch match = re.match("abc123 def");
+if (match.hasMatch()) {
+ QString matched = match.captured(0); // matched == "23 def"
+ // ...
+}
+//! [8]
+
+
+//! [9]
+QRegularExpression re("\\d\\d \\w+");
+QRegularExpressionMatch match = re.match("12 abc 45 def", 1);
+if (match.hasMatch()) {
+ QString matched = match.captured(0); // matched == "45 def"
+ // ...
+}
+//! [9]
+
+
+//! [10]
+QRegularExpression re("^(\\d\\d)/(\\d\\d)/(\\d\\d\\d\\d)$");
+QRegularExpressionMatch match = re.match("08/12/1985");
+if (match.hasMatch()) {
+ QString day = re.captured(1); // day == "08"
+ QString month = re.captured(2); // month == "12"
+ QString year = re.captured(3); // year == "1985"
+ // ...
+}
+//! [10]
+
+
+//! [11]
+QRegularExpression re("abc(\\d+)def");
+QRegularExpressionMatch match = re.match("XYZabc123defXYZ");
+if (match.hasMatch()) {
+ int startOffset = re.capturedStart(1); // startOffset == 6
+ int endOffset = re.capturedEnd(1); // endOffset == 9
+ // ...
+}
+//! [11]
+
+
+//! [12]
+QRegularExpression re("^(?<date>\\d\\d)/(?<month>\\d\\d)/(?<year>\\d\\d\\d\\d)$");
+QRegularExpressionMatch match = re.match("08/12/1985");
+if (match.hasMatch()) {
+ QString date = match.captured("date"); // date == "08"
+ QString month = match.captured("month"); // month == "12"
+ QString year = match.captured("year"); // year == 1985
+}
+//! [12]
+
+
+//! [13]
+QRegularExpression re("(\\w+)");
+QRegularExpressionMatchIterator i = re.globalMatch("the quick fox");
+//! [13]
+
+
+//! [14]
+QStringList words;
+while (i.hasNext()) {
+ QRegularExpressionMatch match = i.next();
+ QString word = match.captured(1);
+ words << word;
+}
+// words contains "the", "quick", "fox"
+//! [14]
+
+
+//! [15]
+QString pattern("^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \\d\\d?, \\d\\d\\d\\d$");
+QRegularExpression re(pattern);
+
+QString input("Jan 21,");
+QRegularExpressionMatch match = re.match(input, 0, QRegularExpressionMatch::PartialPreferCompleteMatch);
+bool hasMatch = match.hasMatch(); // false
+bool hasPartialMatch = match.hasPartialMatch(); // true
+//! [15]
+
+
+//! [16]
+QString input("Dec 8, 1985");
+QRegularExpressionMatch match = re.match(input, 0, QRegularExpressionMatch::PartialPreferCompleteMatch);
+bool hasMatch = match.hasMatch(); // true
+bool hasPartialMatch = match.hasPartialMatch(); // false
+//! [16]
+
+
+//! [17]
+QRegularExpression re("abc\\w+X|def");
+QRegularExpressionMatch match = re.match("abcdef", 0, QRegularExpressionMatch::PartialPreferCompleteMatch);
+bool hasMatch = match.hasMatch(); // true
+bool hasPartialMatch = match.hasPartialMatch(); // false
+QString captured = match.captured(0); // captured == "def"
+//! [17]
+
+
+//! [18]
+QRegularExpression re("abc\\w+X|defY");
+QRegularExpressionMatch match = re.match("abcdef", 0, QRegularExpressionMatch::PartialPreferCompleteMatch);
+bool hasMatch = match.hasMatch(); // false
+bool hasPartialMatch = match.hasPartialMatch(); // true
+QString captured = match.captured(0); // captured == "abcdef"
+//! [18]
+
+
+//! [19]
+QRegularExpression re("abc|ab");
+QRegularExpressionMatch match = re.match("ab", 0, QRegularExpressionMatch::PartialPreferFirstMatch);
+bool hasMatch = match.hasMatch(); // false
+bool hasPartialMatch = match.hasPartialMatch(); // true
+//! [19]
+
+
+//! [20]
+QRegularExpression re("abc(def)?");
+QRegularExpressionMatch match = re.match("abc", 0, QRegularExpressionMatch::PartialPreferFirstMatch);
+bool hasMatch = match.hasMatch(); // false
+bool hasPartialMatch = match.hasPartialMatch(); // true
+//! [20]
+
+//! [21]
+QRegularExpression re("(abc)*");
+QRegularExpressionMatch match = re.match("abc", 0, QRegularExpressionMatch::PartialPreferFirstMatch);
+bool hasMatch = match.hasMatch(); // false
+bool hasPartialMatch = match.hasPartialMatch(); // true
+//! [21]
+
+//! [22]
+QRegularExpression invalidRe("(unmatched|parenthesis");
+bool isValid = invalidRe.isValid(); // false
+//! [22]
+
+//! [23]
+QRegularExpression invalidRe("(unmatched|parenthesis");
+if (!invalidRe.isValid()) {
+ QString errorString = invalidRe.errorString(); // errorString == "missing )"
+ int errorOffset = invalidRe.patternErrorOffset(); // errorOffset == 22
+ // ...
+}
+//! [23]
+
+//! [24]
+QRegularExpression re("^this pattern must match exactly$");
+//! [24]
+
+//! [25]
+QString p("a .*|pattern");
+QRegularExpression re("\\A(?:" + p + ")\\z"); // re matches exactly the pattern string p
+//! [25]
+
+//! [26]
+QString escaped = QRegularExpression::escape("a(x) = f(x) + g(x)");
+// escaped == "a\\(x\\)\\ \\=\\ f\\(x\\)\\ \\+\\ g\\(x\\)"
+//! [26]
+
+//! [27]
+QString pattern = "(" + QRegularExpression::escape(name) +
+ "|" + QRegularExpression::escape(nickname) + ")";
+QRegularExpression re(pattern);
+//! [27]
+
+//! [28]
+QRegularExpressionMatch match = re.match(...);
+for (int i = 0; i <= match.lastCapturedIndex(); ++i) {
+ QString captured = match.captured(i);
+ // ...
+}
+//! [28]
+
+//! [29]
+QRegularExpression("(\d\d) (?<name>\w+)");
+QRegularExpressionMatch match = re.match("23 Jordan");
+if (match.hasMatch()) {
+ QString number = match.captured(1); // first == "23"
+ QString name = match.captured("name"); // name == "Jordan"
+}
+//! [29]
+
+//! [30]
+// extracts the words
+QRegularExpression re("(\w+)");
+QString subject("the quick fox");
+QRegularExpressionMatchIterator i = re.globalMatch(subject);
+while (i.hasNext()) {
+ QRegularExpressionMatch match = i.next();
+ // ...
+}
+//! [30]
+
+
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qscopedpointer.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qscopedpointer.cpp
new file mode 100644
index 0000000000..fd9cd3e4b0
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qscopedpointer.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void myFunction(bool useSubClass)
+{
+ MyClass *p = useSubClass ? new MyClass() : new MySubClass;
+ QIODevice *device = handsOverOwnership();
+
+ if (m_value > 3) {
+ delete p;
+ delete device;
+ return;
+ }
+
+ try {
+ process(device);
+ }
+ catch (...) {
+ delete p;
+ delete device;
+ throw;
+ }
+
+ delete p;
+ delete device;
+}
+//! [0]
+
+//! [1]
+void myFunction(bool useSubClass)
+{
+ // assuming that MyClass has a virtual destructor
+ QScopedPointer<MyClass> p(useSubClass ? new MyClass() : new MySubClass);
+ QScopedPointer<QIODevice> device(handsOverOwnership());
+
+ if (m_value > 3)
+ return;
+
+ process(device);
+}
+//! [1]
+
+//! [2]
+ const QWidget *const p = new QWidget();
+ // is equivalent to:
+ const QScopedPointer<const QWidget> p(new QWidget());
+
+ QWidget *const p = new QWidget();
+ // is equivalent to:
+ const QScopedPointer<QWidget> p(new QWidget());
+
+ const QWidget *p = new QWidget();
+ // is equivalent to:
+ QScopedPointer<const QWidget> p(new QWidget());
+//! [2]
+
+//! [3]
+if (scopedPointer) {
+ ...
+}
+//! [3]
+
+//! [4]
+class MyPrivateClass; // forward declare MyPrivateClass
+
+class MyClass
+{
+private:
+ QScopedPointer<MyPrivateClass> privatePtr; // QScopedPointer to forward declared class
+
+public:
+ MyClass(); // OK
+ inline ~MyClass() {} // VIOLATION - Destructor must not be inline
+
+private:
+ Q_DISABLE_COPY(MyClass) // OK - copy constructor and assignment operators
+ // are now disabled, so the compiler won't implicitely
+ // generate them.
+};
+//! [4]
+
+//! [5]
+// this QScopedPointer deletes its data using the delete[] operator:
+QScopedPointer<int, QScopedPointerArrayDeleter<int> > arrayPointer(new int[42]);
+
+// this QScopedPointer frees its data using free():
+QScopedPointer<int, QScopedPointerPodDeleter> podPointer(reinterpret_cast<int *>(malloc(42)));
+
+// this struct calls "myCustomDeallocator" to delete the pointer
+struct ScopedPointerCustomDeleter
+{
+ static inline void cleanup(MyCustomClass *pointer)
+ {
+ myCustomDeallocator(pointer);
+ }
+};
+
+// QScopedPointer using a custom deleter:
+QScopedPointer<MyCustomClass, ScopedPointerCustomDeleter> customPointer(new MyCustomClass);
+//! [5]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qsize.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qsize.cpp
new file mode 100644
index 0000000000..8772152ad6
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qsize.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QSize t1(10, 12);
+t1.scale(60, 60, Qt::IgnoreAspectRatio);
+// t1 is (60, 60)
+
+QSize t2(10, 12);
+t2.scale(60, 60, Qt::KeepAspectRatio);
+// t2 is (50, 60)
+
+QSize t3(10, 12);
+t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
+// t3 is (60, 72)
+//! [0]
+
+
+//! [1]
+QSize size(100, 10);
+size.rwidth() += 20;
+
+// size becomes (120,10)
+//! [1]
+
+
+//! [2]
+QSize size(100, 10);
+size.rheight() += 5;
+
+// size becomes (100,15)
+//! [2]
+
+
+//! [3]
+QSize s( 3, 7);
+QSize r(-1, 4);
+s += r;
+
+// s becomes (2,11)
+//! [3]
+
+
+//! [4]
+QSize s( 3, 7);
+QSize r(-1, 4);
+s -= r;
+
+// s becomes (4,3)
+//! [4]
+
+
+//! [5]
+QSizeF t1(10, 12);
+t1.scale(60, 60, Qt::IgnoreAspectRatio);
+// t1 is (60, 60)
+
+QSizeF t2(10, 12);
+t2.scale(60, 60, Qt::KeepAspectRatio);
+// t2 is (50, 60)
+
+QSizeF t3(10, 12);
+t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
+// t3 is (60, 72)
+//! [5]
+
+
+//! [6]
+QSizeF size(100.3, 10);
+size.rwidth() += 20.5;
+
+ // size becomes (120.8,10)
+//! [6]
+
+
+//! [7]
+QSizeF size(100, 10.2);
+size.rheight() += 5.5;
+
+// size becomes (100,15.7)
+//! [7]
+
+
+//! [8]
+QSizeF s( 3, 7);
+QSizeF r(-1, 4);
+s += r;
+
+// s becomes (2,11)
+//! [8]
+
+
+//! [9]
+QSizeF s( 3, 7);
+QSizeF r(-1, 4);
+s -= r;
+
+// s becomes (4,3)
+//! [9]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qstring.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qstring.cpp
new file mode 100644
index 0000000000..507e929f47
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qstring.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+DEFINES += QT_NO_CAST_FROM_ASCII \
+ QT_NO_CAST_TO_ASCII
+//! [0]
+
+
+//! [1]
+QString url = QLatin1String("http://www.unicode.org/");
+//! [1]
+
+
+//! [2]
+double d = 12.34;
+QString str = QString("delta: %1").arg(d, 0, 'E', 3);
+// str == "delta: 1.234E+01"
+//! [2]
+
+
+//! [3]
+if (str == "auto" || str == "extern"
+ || str == "static" || str == "register") {
+ ...
+}
+//! [3]
+
+
+//! [4]
+if (str == QString("auto") || str == QString("extern")
+ || str == QString("static") || str == QString("register")) {
+ ...
+}
+//! [4]
+
+
+//! [5]
+if (str == QLatin1String("auto")
+ || str == QLatin1String("extern")
+ || str == QLatin1String("static")
+ || str == QLatin1String("register") {
+ ...
+}
+//! [5]
+
+
+//! [6]
+QLabel *label = new QLabel(QLatin1String("MOD"), this);
+//! [6]
+
+
+//! [7]
+QString plain = "#include <QtCore>"
+QString html = plain.toHtmlEscaped();
+// html == "#include &lt;QtCore&gt;"
+//! [7]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp
new file mode 100644
index 0000000000..e33c94efda
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+...
+progressBar = new QProgressBar(this);
+progressBar->setRange(0, 100);
+
+// Construct a 1-second timeline with a frame range of 0 - 100
+QTimeLine *timeLine = new QTimeLine(1000, this);
+timeLine->setFrameRange(0, 100);
+connect(timeLine, SIGNAL(frameChanged(int)), progressBar, SLOT(setValue(int)));
+
+// Clicking the push button will start the progress bar animation
+pushButton = new QPushButton(tr("Start animation"), this);
+connect(pushButton, SIGNAL(clicked()), timeLine, SLOT(start()));
+...
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp
new file mode 100644
index 0000000000..b3f9a7e675
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QVector<int> integerVector;
+QVector<QString> stringVector;
+//! [0]
+
+
+//! [1]
+QVector<QString> vector(200);
+//! [1]
+
+
+//! [2]
+QVector<QString> vector(200, "Pass");
+//! [2]
+
+
+//! [3]
+if (vector[0] == "Liz")
+ vector[0] = "Elizabeth";
+//! [3]
+
+
+//! [4]
+for (int i = 0; i < vector.size(); ++i) {
+ if (vector.at(i) == "Alfonso")
+ cout << "Found Alfonso at position " << i << endl;
+}
+//! [4]
+
+
+//! [5]
+int i = vector.indexOf("Harumi");
+if (i != -1)
+ cout << "First occurrence of Harumi is at position " << i << endl;
+//! [5]
+
+
+//! [6]
+QVector<int> vector(10);
+int *data = vector.data();
+for (int i = 0; i < 10; ++i)
+ data[i] = 2 * i;
+//! [6]
+
+
+//! [7]
+QVector<QString> vector(0);
+vector.append("one");
+vector.append("two");
+vector.append("three");
+// vector: ["one", "two", "three"]
+//! [7]
+
+
+//! [8]
+QVector<QString> vector;
+vector.prepend("one");
+vector.prepend("two");
+vector.prepend("three");
+// vector: ["three", "two", "one"]
+//! [8]
+
+
+//! [9]
+QVector<QString> vector;
+vector << "alpha" << "beta" << "delta";
+vector.insert(2, "gamma");
+// vector: ["alpha", "beta", "gamma", "delta"]
+//! [9]
+
+
+//! [10]
+QVector<double> vector;
+vector << 2.718 << 1.442 << 0.4342;
+vector.insert(1, 3, 9.9);
+// vector: [2.718, 9.9, 9.9, 9.9, 1.442, 0.4342]
+//! [10]
+
+
+//! [11]
+QVector<QString> vector(3);
+vector.fill("Yes");
+// vector: ["Yes", "Yes", "Yes"]
+
+vector.fill("oh", 5);
+// vector: ["oh", "oh", "oh", "oh", "oh"]
+//! [11]
+
+
+//! [12]
+QVector<QString> vector;
+vector << "A" << "B" << "C" << "B" << "A";
+vector.indexOf("B"); // returns 1
+vector.indexOf("B", 1); // returns 1
+vector.indexOf("B", 2); // returns 3
+vector.indexOf("X"); // returns -1
+//! [12]
+
+
+//! [13]
+QList<QString> vector;
+vector << "A" << "B" << "C" << "B" << "A";
+vector.lastIndexOf("B"); // returns 3
+vector.lastIndexOf("B", 3); // returns 3
+vector.lastIndexOf("B", 2); // returns 1
+vector.lastIndexOf("X"); // returns -1
+//! [13]
+
+
+//! [14]
+QVector<double> vect;
+vect << "red" << "green" << "blue" << "black";
+
+QList<double> list = vect.toList();
+// list: ["red", "green", "blue", "black"]
+//! [14]
+
+
+//! [15]
+QStringList list;
+list << "Sven" << "Kim" << "Ola";
+
+QVector<QString> vect = QVector<QString>::fromList(list);
+// vect: ["Sven", "Kim", "Ola"]
+//! [15]
+
+
+//! [16]
+std::vector<double> stdvector;
+vector.push_back(1.2);
+vector.push_back(0.5);
+vector.push_back(3.14);
+
+QVector<double> vector = QVector<double>::fromStdVector(stdvector);
+//! [16]
+
+
+//! [17]
+QVector<double> vector;
+vector << 1.2 << 0.5 << 3.14;
+
+std::vector<double> stdvector = vector.toStdVector();
+//! [17]
diff --git a/src/corelib/doc/snippets/code/src_corelib_xml_qxmlstream.cpp b/src/corelib/doc/snippets/code/src_corelib_xml_qxmlstream.cpp
new file mode 100644
index 0000000000..9f40777df1
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_xml_qxmlstream.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+ QXmlStreamReader xml;
+ ...
+ while (!xml.atEnd()) {
+ xml.readNext();
+ ... // do processing
+ }
+ if (xml.hasError()) {
+ ... // do error handling
+ }
+//! [0]
+
+
+//! [1]
+ writeStartElement(qualifiedName);
+ writeCharacters(text);
+ writeEndElement();
+//! [1]
+
+
+//! [2]
+ writeStartElement(namespaceUri, name);
+ writeCharacters(text);
+ writeEndElement();
+//! [2]
+
+
diff --git a/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp b/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp
new file mode 100644
index 0000000000..90bc2e9b0a
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+int ret = QMessageBox::warning(this, tr("My Application"),
+ tr("The document has been modified.\n"
+ "Do you want to save your changes?"),
+ QMessageBox::Save | QMessageBox::Discard
+ | QMessageBox::Cancel,
+ QMessageBox::Save);
+//! [0]
+
+
+//! [1]
+QMessageBox msgBox;
+msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+switch (msgBox.exec()) {
+case QMessageBox::Yes:
+ // yes was clicked
+ break;
+case QMessageBox::No:
+ // no was clicked
+ break;
+default:
+ // should never be reached
+ break;
+}
+//! [1]
+
+
+//! [2]
+QMessageBox msgBox;
+QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
+QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
+
+msgBox.exec();
+
+if (msgBox.clickedButton() == connectButton) {
+ // connect
+} else if (msgBox.clickedButton() == abortButton) {
+ // abort
+}
+//! [2]
+
+
+//! [3]
+QMessageBox messageBox(this);
+QAbstractButton *disconnectButton =
+ messageBox.addButton(tr("Disconnect"), QMessageBox::ActionRole);
+...
+messageBox.exec();
+if (messageBox.clickedButton() == disconnectButton) {
+ ...
+}
+//! [3]
+
+
+//! [4]
+#include <QApplication>
+#include <QMessageBox>
+
+int main(int argc, char *argv[])
+{
+ QT_REQUIRE_VERSION(argc, argv, "4.0.2")
+
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [4]
+
+//! [5]
+QMessageBox msgBox;
+msgBox.setText("The document has been modified.");
+msgBox.exec();
+//! [5]
+
+//! [6]
+QMessageBox msgBox;
+msgBox.setText("The document has been modified.");
+msgBox.setInformativeText("Do you want to save your changes?");
+msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+msgBox.setDefaultButton(QMessageBox::Save);
+int ret = msgBox.exec();
+//! [6]
+
+//! [7]
+switch (ret) {
+ case QMessageBox::Save:
+ // Save was clicked
+ break;
+ case QMessageBox::Discard:
+ // Don't Save was clicked
+ break;
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ default:
+ // should never be reached
+ break;
+}
+//! [7]
+
+//! [9]
+QMessageBox msgBox(this);
+msgBox.setText(tr("The document has been modified.\n"
+ "Do you want to save your changes?"));
+msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard
+ | QMessageBox::Cancel);
+msgBox.setDefaultButton(QMessageBox::Save);
+//! [9]
diff --git a/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
new file mode 100644
index 0000000000..cf4707cbeb
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class DateFormatProxyModel : public QIdentityProxyModel
+{
+ // ...
+
+ void setDateFormatString(const QString &formatString)
+ {
+ m_formatString = formatString;
+ }
+
+ QVariant data(const QModelIndex &index, int role)
+ {
+ if (role != Qt::DisplayRole)
+ return QIdentityProxyModel::data(index, role);
+
+ const QDateTime dateTime = sourceModel()->data(SourceClass::DateRole).toDateTime();
+
+ return dateTime.toString(m_formatString);
+ }
+
+private:
+ QString m_formatString;
+};
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp b/src/corelib/doc/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp
new file mode 100644
index 0000000000..ba81221e9c
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QItemSelection *selection = new QItemSelection(topLeft, bottomRight);
+//! [0]
+
+
+//! [1]
+QItemSelection *selection = new QItemSelection();
+...
+selection->select(topLeft, bottomRight);
+//! [1]
diff --git a/src/corelib/doc/snippets/file/file.cpp b/src/corelib/doc/snippets/file/file.cpp
new file mode 100644
index 0000000000..f03c6e6847
--- /dev/null
+++ b/src/corelib/doc/snippets/file/file.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QFile>
+#include <QTextStream>
+
+static void process_line(const QByteArray &)
+{
+}
+
+static void process_line(const QString &)
+{
+}
+
+static void noStream_snippet()
+{
+//! [0]
+ QFile file("in.txt");
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+
+ while (!file.atEnd()) {
+ QByteArray line = file.readLine();
+ process_line(line);
+ }
+//! [0]
+}
+
+static void readTextStream_snippet()
+{
+//! [1]
+ QFile file("in.txt");
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+
+ QTextStream in(&file);
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ process_line(line);
+ }
+//! [1]
+}
+
+static void writeTextStream_snippet()
+{
+//! [2]
+ QFile file("out.txt");
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ return;
+
+ QTextStream out(&file);
+ out << "The magic number is: " << 49 << "\n";
+//! [2]
+}
+
+static void writeTextStream_snippet()
+{
+ QFile file("out.dat");
+ if (!file.open(QIODevice::WriteOnly))
+ return;
+
+ QDataStream out(&file);
+ out << "The magic number is: " << 49 << "\n";
+}
+
+static void readRegularEmptyFile_snippet()
+{
+//! [3]
+ QFile file("/proc/modules");
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+
+ QTextStream in(&file);
+ QString line = in.readLine();
+ while (!line.isNull()) {
+ process_line(line);
+ line = in.readLine();
+ }
+//! [3]
+}
+
+int main()
+{
+ lineByLine_snippet();
+ writeStream_snippet();
+}
diff --git a/src/corelib/doc/snippets/fileinfo/main.cpp b/src/corelib/doc/snippets/fileinfo/main.cpp
new file mode 100644
index 0000000000..48d8223d79
--- /dev/null
+++ b/src/corelib/doc/snippets/fileinfo/main.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QPushButton>
+#include <QFileInfo>
+#include <QDir>
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QDebug>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QFileInfo fileInfo1("~/examples/191697/.");
+ QFileInfo fileInfo2("~/examples/191697/..");
+ QFileInfo fileInfo3("~/examples/191697/main.cpp");
+//! [0]
+//! [1]
+ QFileInfo fileInfo4(".");
+ QFileInfo fileInfo5("..");
+ QFileInfo fileInfo6("main.cpp");
+//! [1]
+
+ qDebug() << fileInfo1.fileName();
+ qDebug() << fileInfo2.fileName();
+ qDebug() << fileInfo3.fileName();
+ qDebug() << fileInfo4.fileName();
+ qDebug() << fileInfo5.fileName();
+ qDebug() << fileInfo6.fileName();
+
+ QPushButton* button1 = new QPushButton(fileInfo1.dir().path());
+ QPushButton* button2 = new QPushButton(fileInfo2.dir().path());
+ QPushButton* button3 = new QPushButton(fileInfo3.dir().path());
+ QPushButton* button4 = new QPushButton(fileInfo4.dir().path());
+ QPushButton* button5 = new QPushButton(fileInfo5.dir().path());
+ QPushButton* button6 = new QPushButton(fileInfo6.dir().path());
+
+ QVBoxLayout* vbox = new QVBoxLayout;
+ vbox->addWidget(button1);
+ vbox->addWidget(button2);
+ vbox->addWidget(button3);
+ vbox->addWidget(button4);
+ vbox->addWidget(button5);
+ vbox->addWidget(button6);
+ vbox->addStretch(1);
+
+ QGroupBox *groupBox = new QGroupBox("QFileInfo::dir() test");
+ groupBox->setLayout(vbox);
+ groupBox->show();
+
+ return app.exec();
+}
diff --git a/src/corelib/doc/snippets/ntfsp.cpp b/src/corelib/doc/snippets/ntfsp.cpp
new file mode 100644
index 0000000000..8f2ff1fc98
--- /dev/null
+++ b/src/corelib/doc/snippets/ntfsp.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+//! [0]
+extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
+//! [0]
+
+//! [1]
+qt_ntfs_permission_lookup++; // turn checking on
+qt_ntfs_permission_lookup--; // turn it off again
+//! [1]
+
diff --git a/src/corelib/doc/snippets/pointer/pointer.cpp b/src/corelib/doc/snippets/pointer/pointer.cpp
new file mode 100644
index 0000000000..dd2bc82102
--- /dev/null
+++ b/src/corelib/doc/snippets/pointer/pointer.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QLabel>
+#include <QPointer>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QPointer<QLabel> label = new QLabel;
+ label->setText("&Status:");
+//! [0]
+
+//! [1]
+ if (label)
+//! [1] //! [2]
+ label->show();
+//! [2]
+ return 0;
+}
diff --git a/src/corelib/doc/snippets/process/process.cpp b/src/corelib/doc/snippets/process/process.cpp
new file mode 100644
index 0000000000..19f241a695
--- /dev/null
+++ b/src/corelib/doc/snippets/process/process.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QProcess>
+
+bool zip()
+{
+//! [0]
+ QProcess gzip;
+ gzip.start("gzip", QStringList() << "-c");
+ if (!gzip.waitForStarted())
+ return false;
+
+ gzip.write("Qt rocks!");
+ gzip.closeWriteChannel();
+
+ if (!gzip.waitForFinished())
+ return false;
+
+ QByteArray result = gzip.readAll();
+//! [0]
+
+ gzip.start("gzip", QStringList() << "-d" << "-c");
+ gzip.write(result);
+ gzip.closeWriteChannel();
+
+ if (!gzip.waitForFinished())
+ return false;
+
+ qDebug("Result: %s", gzip.readAll().data());
+ return true;
+}
+
+
+int main()
+{
+ zip();
+ return 0;
+}
diff --git a/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp b/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp
new file mode 100644
index 0000000000..2dbfe49c7d
--- /dev/null
+++ b/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtDebug>
+
+class Coordinate : public QObject
+{
+public:
+ int myX, myY;
+
+ int x() const { return myX; };
+ int y() const { return myY; };
+};
+
+//! [0]
+QDebug operator<<(QDebug dbg, const Coordinate &c)
+{
+ dbg.nospace() << "(" << c.x() << ", " << c.y() << ")";
+
+ return dbg.space();
+}
+//! [0]
+
+int main(int argv, char **args)
+{
+ Coordinate coordinate;
+ coordinate.myX = 10;
+ coordinate.myY = 44;
+
+//! [1]
+ qDebug() << "Date:" << QDate::currentDate();
+ qDebug() << "Types:" << QString("String") << QChar('x') << QRect(0, 10, 50, 40);
+ qDebug() << "Custom coordinate type:" << coordinate;
+//! [1]
+}
diff --git a/src/corelib/doc/snippets/qdir-listfiles/main.cpp b/src/corelib/doc/snippets/qdir-listfiles/main.cpp
new file mode 100644
index 0000000000..599046aabd
--- /dev/null
+++ b/src/corelib/doc/snippets/qdir-listfiles/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include <QDir>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ QDir dir;
+ dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
+ dir.setSorting(QDir::Size | QDir::Reversed);
+
+ QFileInfoList list = dir.entryInfoList();
+ std::cout << " Bytes Filename" << std::endl;
+ for (int i = 0; i < list.size(); ++i) {
+ QFileInfo fileInfo = list.at(i);
+ std::cout << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10)
+ .arg(fileInfo.fileName()));
+ std::cout << std::endl;
+ }
+ return 0;
+}
+//! [0]
diff --git a/src/corelib/doc/snippets/qdir-namefilters/main.cpp b/src/corelib/doc/snippets/qdir-namefilters/main.cpp
new file mode 100644
index 0000000000..7b48f7eaf7
--- /dev/null
+++ b/src/corelib/doc/snippets/qdir-namefilters/main.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDir>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+ QDir dir;
+ dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
+ dir.setSorting(QDir::Size | QDir::Reversed);
+
+//! [0]
+ QStringList filters;
+ filters << "*.cpp" << "*.cxx" << "*.cc";
+ dir.setNameFilters(filters);
+//! [0]
+
+ QFileInfoList list = dir.entryInfoList();
+ std::cout << " Bytes Filename" << std::endl;
+ for (int i = 0; i < list.size(); ++i) {
+ QFileInfo fileInfo = list.at(i);
+ std::cout << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10)
+ .arg(fileInfo.fileName()));
+ std::cout << std::endl;
+ }
+ return 0;
+}
diff --git a/src/corelib/doc/snippets/qelapsedtimer/main.cpp b/src/corelib/doc/snippets/qelapsedtimer/main.cpp
new file mode 100644
index 0000000000..7b4b6529e7
--- /dev/null
+++ b/src/corelib/doc/snippets/qelapsedtimer/main.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore>
+
+void slowOperation1()
+{
+ static char buf[256];
+ for (int i = 0; i < (1<<20); ++i)
+ buf[i % sizeof buf] = i;
+}
+
+void slowOperation2(int) { slowOperation1(); }
+
+void startExample()
+{
+//![0]
+ QElapsedTimer timer;
+ timer.start();
+
+ slowOperation1();
+
+ qDebug() << "The slow operation took" << timer.elapsed() << "milliseconds";
+//![0]
+}
+
+//![1]
+void executeSlowOperations(int timeout)
+{
+ QElapsedTimer timer;
+ timer.start();
+ slowOperation1();
+
+ int remainingTime = timeout - timer.elapsed();
+ if (remainingTime > 0)
+ slowOperation2(remainingTime);
+}
+//![1]
+
+//![2]
+void executeOperationsForTime(int ms)
+{
+ QElapsedTimer timer;
+ timer.start();
+
+ while (!timer.hasExpired(ms))
+ slowOperation1();
+}
+//![2]
+
+int restartExample()
+{
+//![3]
+ QElapsedTimer timer;
+
+ int count = 1;
+ timer.start();
+ do {
+ count *= 2;
+ slowOperation2(count);
+ } while (timer.restart() < 250);
+
+ return count;
+//![3]
+}
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ startExample();
+ restartExample();
+ executeSlowOperations(5);
+ executeOperationsForTime(5);
+}
diff --git a/src/corelib/doc/snippets/qmetaobject-invokable/main.cpp b/src/corelib/doc/snippets/qmetaobject-invokable/main.cpp
new file mode 100644
index 0000000000..b22df1ea15
--- /dev/null
+++ b/src/corelib/doc/snippets/qmetaobject-invokable/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QDebug>
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window window;
+ qDebug() << window.metaObject()->methodCount();
+ window.show();
+ return app.exec();
+}
diff --git a/src/corelib/doc/snippets/qmetaobject-invokable/qmetaobject-invokable.pro b/src/corelib/doc/snippets/qmetaobject-invokable/qmetaobject-invokable.pro
new file mode 100644
index 0000000000..4df19215f0
--- /dev/null
+++ b/src/corelib/doc/snippets/qmetaobject-invokable/qmetaobject-invokable.pro
@@ -0,0 +1,3 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
diff --git a/src/corelib/doc/snippets/qmetaobject-invokable/window.cpp b/src/corelib/doc/snippets/qmetaobject-invokable/window.cpp
new file mode 100644
index 0000000000..5ab8d83f63
--- /dev/null
+++ b/src/corelib/doc/snippets/qmetaobject-invokable/window.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "window.h"
+
+Window::Window()
+{
+}
+
+void Window::normalMethod()
+{
+ // Cannot be called by the meta-object system.
+ show();
+}
+
+void Window::invokableMethod()
+{
+ // Can be called by the meta-object system.
+ show();
+}
diff --git a/src/corelib/doc/snippets/qmetaobject-invokable/window.h b/src/corelib/doc/snippets/qmetaobject-invokable/window.h
new file mode 100644
index 0000000000..f2f34792e5
--- /dev/null
+++ b/src/corelib/doc/snippets/qmetaobject-invokable/window.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QWidget>
+
+//! [Window class with invokable method]
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window();
+ void normalMethod();
+ Q_INVOKABLE void invokableMethod();
+};
+//! [Window class with invokable method]
+
+#endif
diff --git a/src/corelib/doc/snippets/qprocess-environment/main.cpp b/src/corelib/doc/snippets/qprocess-environment/main.cpp
new file mode 100644
index 0000000000..124668a544
--- /dev/null
+++ b/src/corelib/doc/snippets/qprocess-environment/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore>
+
+void startProcess()
+{
+ {
+//! [0]
+QProcess process;
+QStringList env = QProcess::systemEnvironment();
+env << "TMPDIR=C:\\MyApp\\temp"; // Add an environment variable
+env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=\\1;C:\\Bin");
+process.setEnvironment(env);
+process.start("myapp");
+//! [0]
+ }
+
+ {
+//! [1]
+QProcess process;
+QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+env.insert("TMPDIR", "C:\\MyApp\\temp"); // Add an environment variable
+env.insert("PATH", env.value("Path") + ";C:\\Bin");
+process.setProcessEnvironment(env);
+process.start("myapp");
+//! [1]
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ startProcess();
+ return app.exec();
+}
diff --git a/src/corelib/doc/snippets/qprocess/qprocess-simpleexecution.cpp b/src/corelib/doc/snippets/qprocess/qprocess-simpleexecution.cpp
new file mode 100644
index 0000000000..ea1892078e
--- /dev/null
+++ b/src/corelib/doc/snippets/qprocess/qprocess-simpleexecution.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [0]
+ QObject *parent;
+//! [0]
+ parent = &app;
+
+//! [1]
+ QString program = "./path/to/Qt/examples/widgets/analogclock";
+//! [1]
+ program = "./../../../../examples/widgets/analogclock/analogclock";
+
+//! [2]
+ QStringList arguments;
+ arguments << "-style" << "motif";
+
+ QProcess *myProcess = new QProcess(parent);
+ myProcess->start(program, arguments);
+//! [2]
+
+ return app.exec();
+}
diff --git a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
new file mode 100644
index 0000000000..cda905e3a2
--- /dev/null
+++ b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "buttonwidget.h"
+
+//! [0]
+ButtonWidget::ButtonWidget(QStringList texts, QWidget *parent)
+ : QWidget(parent)
+{
+ signalMapper = new QSignalMapper(this);
+
+ QGridLayout *gridLayout = new QGridLayout;
+ for (int i = 0; i < texts.size(); ++i) {
+ QPushButton *button = new QPushButton(texts[i]);
+ connect(button, SIGNAL(clicked()), signalMapper, SLOT(map()));
+//! [0] //! [1]
+ signalMapper->setMapping(button, texts[i]);
+ gridLayout->addWidget(button, i / 3, i % 3);
+ }
+
+ connect(signalMapper, SIGNAL(mapped(const QString &)),
+//! [1] //! [2]
+ this, SIGNAL(clicked(const QString &)));
+
+ setLayout(gridLayout);
+}
+//! [2]
diff --git a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h
new file mode 100644
index 0000000000..9204de935a
--- /dev/null
+++ b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BUTTONWIDGET_H
+#define BUTTONWIDGET_H
+
+#include <qwidget.h>
+
+class QSignalMapper;
+class QString;
+class QStringList;
+
+//! [0]
+class ButtonWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ButtonWidget(QStringList texts, QWidget *parent = 0);
+
+signals:
+ void clicked(const QString &text);
+
+private:
+ QSignalMapper *signalMapper;
+//! [0] //! [1]
+};
+//! [1]
+
+#endif
diff --git a/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp b/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp
new file mode 100644
index 0000000000..549d24b249
--- /dev/null
+++ b/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+#include <QSortFilterProxyModel>
+
+class MyItemModel : public QStandardItemModel
+{
+public:
+ MyItemModel(QWidget *parent = 0);
+};
+
+MyItemModel::MyItemModel(QWidget *parent)
+ : QStandardItemModel(parent)
+{};
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0] //! [1]
+ QTreeView *treeView = new QTreeView;
+//! [0]
+ MyItemModel *model = new MyItemModel(this);
+
+ treeView->setModel(model);
+//! [1]
+
+//! [2]
+ MyItemModel *sourceModel = new MyItemModel(this);
+ QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
+
+ proxyModel->setSourceModel(sourceModel);
+ treeView->setModel(proxyModel);
+//! [2]
+
+//! [3]
+ treeView->setSortingEnabled(true);
+//! [3]
+
+//! [4]
+ proxyModel->sort(2, Qt::AscendingOrder);
+//! [4] //! [5]
+ proxyModel->setFilterRegExp(QRegExp(".png", Qt::CaseInsensitive,
+ QRegExp::FixedString));
+ proxyModel->setFilterKeyColumn(1);
+//! [5]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/src/corelib/doc/snippets/qstack/main.cpp b/src/corelib/doc/snippets/qstack/main.cpp
new file mode 100644
index 0000000000..cc96f8c55d
--- /dev/null
+++ b/src/corelib/doc/snippets/qstack/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <iostream>
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+//! [0]
+ QStack<int> stack;
+ stack.push(1);
+ stack.push(2);
+ stack.push(3);
+ while (!stack.isEmpty())
+ cout << stack.pop() << endl;
+//! [0]
+}
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
new file mode 100644
index 0000000000..d7299e80d5
--- /dev/null
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -0,0 +1,997 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+#include <stdio.h>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+
+ void constCharPointer();
+ void constCharArray();
+ void characterReference();
+ void atFunction();
+ void stringLiteral();
+ void modify();
+ void index();
+ QString boolToString(bool b);
+ void nullVsEmpty();
+
+ void appendFunction();
+ void argFunction();
+ void chopFunction();
+ void compareFunction();
+ void compareSensitiveFunction();
+ void containsFunction();
+ void countFunction();
+ void dataFunction();
+ void endsWithFunction();
+ void fillFunction();
+ void fromRawDataFunction();
+
+ void indexOfFunction();
+ void firstIndexOfFunction();
+ void insertFunction();
+ void isNullFunction();
+ void isEmptyFunction();
+ void lastIndexOfFunction();
+ void leftFunction();
+ void leftJustifiedFunction();
+ void leftRefFunction();
+ void midFunction();
+ void midRefFunction();
+ void numberFunction();
+
+ void prependFunction();
+ void removeFunction();
+ void replaceFunction();
+ void reserveFunction();
+ void resizeFunction();
+ void rightFunction();
+ void rightJustifiedFunction();
+ void rightRefFunction();
+ void sectionFunction();
+ void setNumFunction();
+ void simplifiedFunction();
+
+ void sizeFunction();
+ void splitFunction();
+ void splitCaseSensitiveFunction();
+ void sprintfFunction();
+ void startsWithFunction();
+ void toDoubleFunction();
+ void toFloatFunction();
+ void toIntFunction();
+ void toLongFunction();
+ void toLongLongFunction();
+
+ void toLowerFunction();
+ void toShortFunction();
+ void toUIntFunction();
+ void toULongFunction();
+ void toULongLongFunction();
+ void toUShortFunction();
+ void toUpperFunction();
+ void trimmedFunction();
+ void truncateFunction();
+
+ void plusEqualOperator();
+ void arrayOperator();
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+}
+
+void Widget::constCharPointer()
+{
+ //! [0]
+ QString str = "Hello";
+ //! [0]
+}
+
+void Widget::constCharArray()
+{
+ //! [1]
+ static const QChar data[4] = { 0x0055, 0x006e, 0x10e3, 0x03a3 };
+ QString str(data, 4);
+ //! [1]
+}
+
+void Widget::characterReference()
+{
+ //! [2]
+ QString str;
+ str.resize(4);
+
+ str[0] = QChar('U');
+ str[1] = QChar('n');
+ str[2] = QChar(0x10e3);
+ str[3] = QChar(0x03a3);
+ //! [2]
+}
+
+void Widget::atFunction()
+{
+ //! [3]
+ QString str;
+
+ for (int i = 0; i < str.size(); ++i) {
+ if (str.at(i) >= QChar('a') && str.at(i) <= QChar('f'))
+ qDebug() << "Found character in range [a-f]";
+ }
+ //! [3]
+}
+
+void Widget::stringLiteral()
+{
+ //! [4]
+ QString str;
+
+ if (str == "auto" || str == "extern"
+ || str == "static" || str == "register") {
+ // ...
+ }
+ //! [4]
+}
+
+void Widget::modify()
+{
+ //! [5]
+ QString str = "and";
+ str.prepend("rock "); // str == "rock and"
+ str.append(" roll"); // str == "rock and roll"
+ str.replace(5, 3, "&"); // str == "rock & roll"
+ //! [5]
+}
+
+void Widget::index()
+{
+ //! [6]
+ QString str = "We must be <b>bold</b>, very <b>bold</b>";
+ int j = 0;
+
+ while ((j = str.indexOf("<b>", j)) != -1) {
+ qDebug() << "Found <b> tag at index position" << j;
+ ++j;
+ }
+ //! [6]
+}
+
+//! [7]
+QString Widget::boolToString(bool b)
+{
+ QString result;
+ if (b)
+ result = "True";
+ else
+ result = "False";
+ return result;
+}
+//! [7]
+
+
+void Widget::nullVsEmpty()
+{
+ //! [8]
+ QString().isNull(); // returns true
+ QString().isEmpty(); // returns true
+
+ QString("").isNull(); // returns false
+ QString("").isEmpty(); // returns true
+
+ QString("abc").isNull(); // returns false
+ QString("abc").isEmpty(); // returns false
+ //! [8]
+}
+
+void Widget::appendFunction()
+{
+ //! [9]
+ QString x = "free";
+ QString y = "dom";
+
+ x.append(y);
+ // x == "freedom"
+ //! [9]
+
+ //! [10]
+ x.insert(x.size(), y);
+ //! [10]
+}
+
+void Widget::argFunction()
+{
+ //! [11]
+ QString i; // current file's number
+ QString total; // number of files to process
+ QString fileName; // current file's name
+
+ QString status = QString("Processing file %1 of %2: %3")
+ .arg(i).arg(total).arg(fileName);
+ //! [11]
+
+ //! [12] //! [13]
+ QString str;
+ //! [12]
+ str = "%1 %2";
+
+ str.arg("%1f", "Hello"); // returns "%1f Hello"
+ str.arg("%1f").arg("Hello"); // returns "Hellof %2"
+ //! [13]
+
+ //! [14]
+ str = QString("Decimal 63 is %1 in hexadecimal")
+ .arg(63, 0, 16);
+ // str == "Decimal 63 is 3f in hexadecimal"
+
+ QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
+ str = QString("%1 %L2 %L3")
+ .arg(12345)
+ .arg(12345)
+ .arg(12345, 0, 16);
+ // str == "12345 12,345 3039"
+ //! [14]
+}
+
+void Widget::chopFunction()
+{
+ //! [15]
+ QString str("LOGOUT\r\n");
+ str.chop(2);
+ // str == "LOGOUT"
+ //! [15]
+}
+
+void Widget::compareFunction()
+{
+ int x = QString::compare("auto", "auto"); // x == 0
+ int y = QString::compare("auto", "car"); // y < 0
+ int z = QString::compare("car", "auto"); // z > 0
+}
+
+void Widget::compareSensitiveFunction()
+{
+ //! [16]
+ int x = QString::compare("aUtO", "AuTo", Qt::CaseInsensitive); // x == 0
+ int y = QString::compare("auto", "Car", Qt::CaseSensitive); // y > 0
+ int z = QString::compare("auto", "Car", Qt::CaseInsensitive); // z < 0
+ //! [16]
+}
+
+void Widget::containsFunction()
+{
+ //! [17]
+ QString str = "Peter Pan";
+ str.contains("peter", Qt::CaseInsensitive); // returns true
+ //! [17]
+}
+
+void Widget::countFunction()
+{
+ //! [18]
+ QString str = "banana and panama";
+ str.count(QRegExp("a[nm]a")); // returns 4
+ //! [18]
+
+ //! [95]
+ QString str = "banana and panama";
+ str.count(QRegularExpression("a[nm]a")); // returns 4
+ //! [95]
+}
+
+void Widget::dataFunction()
+{
+ //! [19]
+ QString str = "Hello world";
+ QChar *data = str.data();
+ while (!data->isNull()) {
+ qDebug() << data->unicode();
+ ++data;
+ }
+ //! [19]
+}
+
+void Widget::endsWithFunction()
+{
+ //! [20]
+ QString str = "Bananas";
+ str.endsWith("anas"); // returns true
+ str.endsWith("pple"); // returns false
+ //! [20]
+}
+
+void Widget::fillFunction()
+{
+ //! [21]
+ QString str = "Berlin";
+ str.fill('z');
+ // str == "zzzzzz"
+
+ str.fill('A', 2);
+ // str == "AA"
+ //! [21]
+}
+
+void Widget::fromRawDataFunction()
+{
+ //! [22]
+ QRegExp pattern;
+ static const QChar unicode[] = {
+ 0x005A, 0x007F, 0x00A4, 0x0060,
+ 0x1009, 0x0020, 0x0020};
+ int size = sizeof(unicode) / sizeof(QChar);
+
+ QString str = QString::fromRawData(unicode, size);
+ if (str.contains(QRegExp(pattern))) {
+ // ...
+ //! [22] //! [23]
+ }
+ //! [23]
+}
+
+void Widget::indexOfFunction()
+{
+ //! [24]
+ QString x = "sticky question";
+ QString y = "sti";
+ x.indexOf(y); // returns 0
+ x.indexOf(y, 1); // returns 10
+ x.indexOf(y, 10); // returns 10
+ x.indexOf(y, 11); // returns -1
+ //! [24]
+}
+
+void Widget::firstIndexOfFunction()
+{
+ //! [25]
+ QString str = "the minimum";
+ str.indexOf(QRegExp("m[aeiou]"), 0); // returns 4
+ //! [25]
+
+ //! [93]
+ QString str = "the minimum";
+ str.indexOf(QRegularExpression("m[aeiou]"), 0); // returns 4
+ //! [93]
+}
+
+void Widget::insertFunction()
+{
+ //! [26]
+ QString str = "Meal";
+ str.insert(1, QString("ontr"));
+ // str == "Montreal"
+ //! [26]
+}
+
+void Widget::isEmptyFunction()
+{
+ //! [27]
+ QString().isEmpty(); // returns true
+ QString("").isEmpty(); // returns true
+ QString("x").isEmpty(); // returns false
+ QString("abc").isEmpty(); // returns false
+ //! [27]
+}
+
+void Widget::isNullFunction()
+{
+ //! [28]
+ QString().isNull(); // returns true
+ QString("").isNull(); // returns false
+ QString("abc").isNull(); // returns false
+ //! [28]
+}
+
+void Widget::lastIndexOfFunction()
+{
+ //! [29]
+ QString x = "crazy azimuths";
+ QString y = "az";
+ x.lastIndexOf(y); // returns 6
+ x.lastIndexOf(y, 6); // returns 6
+ x.lastIndexOf(y, 5); // returns 2
+ x.lastIndexOf(y, 1); // returns -1
+ //! [29]
+
+ //! [30]
+ QString str = "the minimum";
+ str.lastIndexOf(QRegExp("m[aeiou]")); // returns 8
+ //! [30]
+
+ //! [94]
+ QString str = "the minimum";
+ str.lastIndexOf(QRegularExpression("m[aeiou]")); // returns 8
+ //! [94]
+}
+
+void Widget::leftFunction()
+{
+ //! [31]
+ QString x = "Pineapple";
+ QString y = x.left(4); // y == "Pine"
+ //! [31]
+}
+
+void Widget::leftJustifiedFunction()
+{
+ //! [32]
+ QString s = "apple";
+ QString t = s.leftJustified(8, '.'); // t == "apple..."
+ //! [32]
+
+ //! [33]
+ QString str = "Pineapple";
+ str = str.leftJustified(5, '.', true); // str == "Pinea"
+ //! [33]
+}
+
+void Widget::midFunction()
+{
+ //! [34]
+ QString x = "Nine pineapples";
+ QString y = x.mid(5, 4); // y == "pine"
+ QString z = x.mid(5); // z == "pineapples"
+ //! [34]
+}
+
+void Widget::numberFunction()
+{
+ //! [35]
+ long a = 63;
+ QString s = QString::number(a, 16); // s == "3f"
+ QString t = QString::number(a, 16).toUpper(); // t == "3F"
+ //! [35]
+}
+
+void Widget::prependFunction()
+{
+ //! [36]
+ QString x = "ship";
+ QString y = "air";
+ x.prepend(y);
+ // x == "airship"
+ //! [36]
+}
+
+void Widget::removeFunction()
+{
+ //! [37]
+ QString s = "Montreal";
+ s.remove(1, 4);
+ // s == "Meal"
+ //! [37]
+
+ //! [38]
+ QString t = "Ali Baba";
+ t.remove(QChar('a'), Qt::CaseInsensitive);
+ // t == "li Bb"
+ //! [38]
+
+ //! [39]
+ QString r = "Telephone";
+ r.remove(QRegExp("[aeiou]."));
+ // r == "The"
+ //! [39]
+
+ //! [96]
+ QString r = "Telephone";
+ r.remove(QRegularExpression("[aeiou]."));
+ // r == "The"
+ //! [96]
+}
+
+void Widget::replaceFunction()
+{
+ //! [40]
+ QString x = "Say yes!";
+ QString y = "no";
+ x.replace(4, 3, y);
+ // x == "Say no!"
+ //! [40]
+
+ //! [41]
+ QString str = "colour behaviour flavour neighbour";
+ str.replace(QString("ou"), QString("o"));
+ // str == "color behavior flavor neighbor"
+ //! [41]
+
+ //! [42]
+ QString s = "Banana";
+ s.replace(QRegExp("a[mn]"), "ox");
+ // s == "Boxoxa"
+ //! [42]
+
+ //! [43]
+ QString t = "A <i>bon mot</i>.";
+ t.replace(QRegExp("<i>([^<]*)</i>"), "\\emph{\\1}");
+ // t == "A \\emph{bon mot}."
+ //! [43]
+
+ //! [86]
+ QString equis = "xxxxxx";
+ equis.replace("xx", "x");
+ // equis == "xxx"
+ //! [86]
+
+ //! [87]
+ QString s = "Banana";
+ s.replace(QRegularExpression("a[mn]"), "ox");
+ // s == "Boxoxa"
+ //! [87]
+
+ //! [88]
+ QString t = "A <i>bon mot</i>.";
+ t.replace(QRegularExpression("<i>([^<]*)</i>"), "\\emph{\\1}");
+ // t == "A \\emph{bon mot}."
+ //! [88]
+}
+
+void Widget::reserveFunction()
+{
+ //! [44]
+ QString result;
+ int maxSize;
+ bool condition;
+ QChar nextChar;
+
+ result.reserve(maxSize);
+
+ while (condition)
+ result.append(nextChar);
+
+ result.squeeze();
+ //! [44]
+}
+
+void Widget::resizeFunction()
+{
+ //! [45]
+ QString s = "Hello world";
+ s.resize(5);
+ // s == "Hello"
+
+ s.resize(8);
+ // s == "Hello???" (where ? stands for any character)
+ //! [45]
+
+ //! [46]
+ QString t = "Hello";
+ t += QString(10, 'X');
+ // t == "HelloXXXXXXXXXX"
+ //! [46]
+
+ //! [47]
+ QString r = "Hello";
+ r = r.leftJustified(10, ' ');
+ // r == "Hello "
+ //! [47]
+}
+
+void Widget::rightFunction()
+{
+ //! [48]
+ QString x = "Pineapple";
+ QString y = x.right(5); // y == "apple"
+ //! [48]
+}
+
+void Widget::rightJustifiedFunction()
+{
+ //! [49]
+ QString s = "apple";
+ QString t = s.rightJustified(8, '.'); // t == "...apple"
+ //! [49]
+
+ //! [50]
+ QString str = "Pineapple";
+ str = str.rightJustified(5, '.', true); // str == "Pinea"
+ //! [50]
+}
+
+void Widget::sectionFunction()
+{
+ //! [51] //! [52]
+ QString str;
+ //! [51]
+ QString csv = "forename,middlename,surname,phone";
+ QString path = "/usr/local/bin/myapp"; // First field is empty
+ QString::SectionFlag flag = QString::SectionSkipEmpty;
+
+
+ str = csv.section(',', 2, 2); // str == "surname"
+ str = path.section('/', 3, 4); // str == "bin/myapp"
+ str = path.section('/', 3, 3, flag); // str == "myapp"
+ //! [52]
+
+ //! [53]
+ str = csv.section(',', -3, -2); // str == "middlename,surname"
+ str = path.section('/', -1); // str == "myapp"
+ //! [53]
+
+ //! [54]
+ QString data = "forename**middlename**surname**phone";
+
+ str = data.section("**", 2, 2); // str == "surname"
+ str = data.section("**", -3, -2); // str == "middlename**surname"
+ //! [54]
+
+ //! [55]
+ QString line = "forename\tmiddlename surname \t \t phone";
+ QRegExp sep("\\s+");
+ str = line.section(sep, 2, 2); // str == "surname"
+ str = line.section(sep, -3, -2); // str == "middlename surname"
+ //! [55]
+
+ //! [89]
+ QString line = "forename\tmiddlename surname \t \t phone";
+ QRegularExpression sep("\\s+");
+ str = line.section(sep, 2, 2); // str == "surname"
+ str = line.section(sep, -3, -2); // str == "middlename surname"
+ //! [89]
+}
+
+void Widget::setNumFunction()
+{
+ //! [56]
+ QString str;
+ str.setNum(1234); // str == "1234"
+ //! [56]
+}
+
+void Widget::simplifiedFunction()
+{
+ //! [57]
+ QString str = " lots\t of\nwhitespace\r\n ";
+ str = str.simplified();
+ // str == "lots of whitespace";
+ //! [57]
+}
+
+void Widget::sizeFunction()
+{
+ //! [58]
+ QString str = "World";
+ int n = str.size(); // n == 5
+ str.data()[0]; // returns 'W'
+ str.data()[4]; // returns 'd'
+ str.data()[5]; // returns '\0'
+ //! [58]
+}
+
+void Widget::splitFunction()
+{
+ //! [59]
+ QString str;
+ QStringList list;
+
+ str = "Some text\n\twith strange whitespace.";
+ list = str.split(QRegExp("\\s+"));
+ // list: [ "Some", "text", "with", "strange", "whitespace." ]
+ //! [59]
+
+ //! [60]
+ str = "This time, a normal English sentence.";
+ list = str.split(QRegExp("\\W+"), QString::SkipEmptyParts);
+ // list: [ "This", "time", "a", "normal", "English", "sentence" ]
+ //! [60]
+
+ //! [61]
+ str = "Now: this sentence fragment.";
+ list = str.split(QRegExp("\\b"));
+ // list: [ "", "Now", ": ", "this", " ", "sentence", " ", "fragment", "." ]
+ //! [61]
+
+ //! [90]
+ QString str;
+ QStringList list;
+
+ str = "Some text\n\twith strange whitespace.";
+ list = str.split(QRegularExpression("\\s+"));
+ // list: [ "Some", "text", "with", "strange", "whitespace." ]
+ //! [90]
+
+ //! [91]
+ str = "This time, a normal English sentence.";
+ list = str.split(QRegularExpression("\\W+"), QString::SkipEmptyParts);
+ // list: [ "This", "time", "a", "normal", "English", "sentence" ]
+ //! [91]
+
+ //! [92]
+ str = "Now: this sentence fragment.";
+ list = str.split(QRegularExpression("\\b"));
+ // list: [ "", "Now", ": ", "this", " ", "sentence", " ", "fragment", "." ]
+ //! [92]
+}
+
+void Widget::splitCaseSensitiveFunction()
+{
+ //! [62]
+ QString str = "a,,b,c";
+
+ QStringList list1 = str.split(",");
+ // list1: [ "a", "", "b", "c" ]
+
+ QStringList list2 = str.split(",", QString::SkipEmptyParts);
+ // list2: [ "a", "b", "c" ]
+ //! [62]
+}
+
+void Widget::sprintfFunction()
+{
+ //! [63]
+ size_t BufSize;
+ char buf[BufSize];
+
+ ::snprintf(buf, BufSize, "%lld", 123456789LL);
+ QString str = QString::fromAscii(buf);
+ //! [63]
+
+ //! [64]
+ QString result;
+ QTextStream(&result) << "pi = " << 3.14;
+ // result == "pi = 3.14"
+ //! [64]
+}
+
+void Widget::startsWithFunction()
+{
+ //! [65]
+ QString str = "Bananas";
+ str.startsWith("Ban"); // returns true
+ str.startsWith("Car"); // returns false
+ //! [65]
+}
+
+void Widget::toDoubleFunction()
+{
+ //! [66]
+ QString str = "1234.56";
+ double val = str.toDouble(); // val == 1234.56
+ //! [66]
+
+ //! [67]
+ bool ok;
+ double d;
+
+ d = QString( "1234.56e-02" ).toDouble(&ok); // ok == true, d == 12.3456
+ //! [67]
+
+ //! [68]
+ d = QString( "1234,56" ).toDouble(&ok); // ok == false
+ d = QString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56
+ //! [68]
+
+ //! [69]
+ d = QString( "1,234,567.89" ).toDouble(&ok); // ok == false
+ d = QString( "1234567.89" ).toDouble(&ok); // ok == true
+ //! [69]
+}
+
+void Widget::toFloatFunction()
+{
+ //! [71]
+ QString str1 = "1234.56";
+ str1.toFloat(); // returns 1234.56
+
+ bool ok;
+ QString str2 = "R2D2";
+ str2.toFloat(&ok); // returns 0.0, sets ok to false
+ //! [71]
+}
+
+void Widget::toIntFunction()
+{
+ //! [72]
+ QString str = "FF";
+ bool ok;
+ int hex = str.toInt(&ok, 16); // hex == 255, ok == true
+ int dec = str.toInt(&ok, 10); // dec == 0, ok == false
+ //! [72]
+}
+
+void Widget::toLongFunction()
+{
+ //! [73]
+ QString str = "FF";
+ bool ok;
+
+ long hex = str.toLong(&ok, 16); // hex == 255, ok == true
+ long dec = str.toLong(&ok, 10); // dec == 0, ok == false
+ //! [73]
+}
+
+void Widget::toLongLongFunction()
+{
+ //! [74]
+ QString str = "FF";
+ bool ok;
+
+ qint64 hex = str.toLongLong(&ok, 16); // hex == 255, ok == true
+ qint64 dec = str.toLongLong(&ok, 10); // dec == 0, ok == false
+ //! [74]
+}
+
+void Widget::toLowerFunction()
+{
+ //! [75]
+ QString str = "Qt by NOKIA";
+ str = str.toLower(); // str == "qt by nokia"
+ //! [75]
+}
+
+void Widget::toShortFunction()
+{
+ //! [76]
+ QString str = "FF";
+ bool ok;
+
+ short hex = str.toShort(&ok, 16); // hex == 255, ok == true
+ short dec = str.toShort(&ok, 10); // dec == 0, ok == false
+ //! [76]
+}
+
+void Widget::toUIntFunction()
+{
+ //! [77]
+ QString str = "FF";
+ bool ok;
+
+ uint hex = str.toUInt(&ok, 16); // hex == 255, ok == true
+ uint dec = str.toUInt(&ok, 10); // dec == 0, ok == false
+ //! [77]
+}
+
+void Widget::toULongFunction()
+{
+ //! [78]
+ QString str = "FF";
+ bool ok;
+
+ ulong hex = str.toULong(&ok, 16); // hex == 255, ok == true
+ ulong dec = str.toULong(&ok, 10); // dec == 0, ok == false
+ //! [78]
+}
+
+void Widget::toULongLongFunction()
+{
+ //! [79]
+ QString str = "FF";
+ bool ok;
+
+ quint64 hex = str.toULongLong(&ok, 16); // hex == 255, ok == true
+ quint64 dec = str.toULongLong(&ok, 10); // dec == 0, ok == false
+ //! [79]
+}
+
+void Widget::toUShortFunction()
+{
+ //! [80]
+ QString str = "FF";
+ bool ok;
+
+ ushort hex = str.toUShort(&ok, 16); // hex == 255, ok == true
+ ushort dec = str.toUShort(&ok, 10); // dec == 0, ok == false
+ //! [80]
+}
+
+void Widget::toUpperFunction()
+{
+ //! [81]
+ QString str = "TeXt";
+ str = str.toUpper(); // str == "TEXT"
+ //! [81]
+}
+
+void Widget::trimmedFunction()
+{
+ //! [82]
+ QString str = " lots\t of\nwhitespace\r\n ";
+ str = str.trimmed();
+ // str == "lots\t of\nwhitespace"
+ //! [82]
+}
+
+void Widget::truncateFunction()
+{
+ //! [83]
+ QString str = "Vladivostok";
+ str.truncate(4);
+ // str == "Vlad"
+ //! [83]
+}
+
+void Widget::plusEqualOperator()
+{
+ //! [84]
+ QString x = "free";
+ QString y = "dom";
+ x += y;
+ // x == "freedom"
+ //! [84]
+}
+
+void Widget::arrayOperator()
+{
+ //! [85]
+ QString str;
+
+ if (str[0] == QChar('?'))
+ str[0] = QChar('_');
+ //! [85]
+}
+
+void Widget::midRefFunction()
+{
+ //! [midRef]
+ QString x = "Nine pineapples";
+ QStringRef y = x.midRef(5, 4); // y == "pine"
+ QStringRef z = x.midRef(5); // z == "pineapples"
+ //! [midRef]
+}
+
+void Widget::leftRefFunction()
+{
+ //! [leftRef]
+ QString x = "Pineapple";
+ QStringRef y = x.leftRef(4); // y == "Pine"
+ //! [leftRef]
+}
+
+void Widget::rightRefFunction()
+{
+ //! [rightRef]
+ QString x = "Pineapple";
+ QStringRef y = x.rightRef(5); // y == "apple"
+ //! [rightRef]
+}
+
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/src/corelib/doc/snippets/qstring/stringbuilder.cpp b/src/corelib/doc/snippets/qstring/stringbuilder.cpp
new file mode 100644
index 0000000000..53cf0b7be0
--- /dev/null
+++ b/src/corelib/doc/snippets/qstring/stringbuilder.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+ QString foo;
+ QString type = "long";
+
+ foo->setText(QLatin1String("vector<") + type + QLatin1String(">::iterator"));
+
+ if (foo.startsWith("(" + type + ") 0x"))
+ ...
+//! [0]
+
+//! [3]
+ DEFINES *= QT_USE_QSTRINGBUILDER
+//! [3]
+
+//! [5]
+ #include <QStringBuilder>
+
+ QString hello("hello");
+ QStringRef el(&hello, 2, 3);
+ QLatin1String world("world");
+ QString message = hello % el % world % QChar('!');
+//! [5]
diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp
new file mode 100644
index 0000000000..8ca463371e
--- /dev/null
+++ b/src/corelib/doc/snippets/qstringlist/main.cpp
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <iostream>
+using namespace std;
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QStringList fonts;
+ fonts << "Arial" << "Helvetica" << "Times" << "Courier";
+//! [0]
+
+//! [1]
+ for (int i = 0; i < fonts.size(); ++i)
+ cout << fonts.at(i).toLocal8Bit().constData() << endl;
+//! [1]
+
+//! [2]
+ QStringListIterator javaStyleIterator(fonts);
+ while (javaStyleIterator.hasNext())
+ cout << javaStyleIterator.next().toLocal8Bit().constData() << endl;
+//! [2]
+
+//! [3]
+ QStringList::const_iterator constIterator;
+ for (constIterator = fonts.constBegin(); constIterator != fonts.constEnd();
+ ++constIterator)
+ cout << (*constIterator).toLocal8Bit().constData() << endl;
+//! [3]
+
+//! [4]
+ QString str = fonts.join(",");
+ // str == "Arial,Helvetica,Times,Courier"
+//! [4]
+
+//! [5] //! [6]
+ QStringList list;
+//! [5]
+ list = str.split(",");
+ // list: ["Arial", "Helvetica", "Times", "Courier"]
+//! [6]
+
+//! [7]
+ QStringList monospacedFonts = fonts.filter(QRegExp("Courier|Fixed"));
+//! [7]
+
+//! [8]
+ QStringList files;
+ files << "$QTDIR/src/moc/moc.y"
+ << "$QTDIR/src/moc/moc.l"
+ << "$QTDIR/include/qconfig.h";
+
+ files.replaceInStrings("$QTDIR", "/usr/lib/qt");
+ // files: [ "/usr/lib/qt/src/moc/moc.y", ...]
+//! [8]
+
+ QString str1, str2, str3;
+//! [9]
+ QStringList longerList = (QStringList() << str1 << str2 << str3);
+//! [9]
+
+ list.clear();
+//! [10]
+ list << "Bill Murray" << "John Doe" << "Bill Clinton";
+
+//! [11]
+ QStringList result;
+//! [11]
+ result = list.filter("Bill");
+ // result: ["Bill Murray", "Bill Clinton"]
+//! [10]
+
+ result.clear();
+//! [12]
+ foreach (const QString &str, list) {
+ if (str.contains("Bill"))
+ result += str;
+ }
+//! [12]
+
+ list.clear();
+//! [13]
+ list << "alpha" << "beta" << "gamma" << "epsilon";
+ list.replaceInStrings("a", "o");
+ // list == ["olpho", "beto", "gommo", "epsilon"]
+//! [13]
+
+ list.clear();
+//! [14]
+ list << "alpha" << "beta" << "gamma" << "epsilon";
+ list.replaceInStrings(QRegExp("^a"), "o");
+ // list == ["olpha", "beta", "gamma", "epsilon"]
+//! [14]
+
+ list.clear();
+//! [15]
+ list << "Bill Clinton" << "Murray, Bill";
+ list.replaceInStrings(QRegExp("^(.*), (.*)$"), "\\2 \\1");
+ // list == ["Bill Clinton", "Bill Murray"]
+//! [15]
+
+ list.clear();
+//! [16]
+ list << "alpha" << "beta" << "gamma" << "epsilon";
+ list.replaceInStrings(QRegularExpression("^a"), "o");
+ // list == ["olpha", "beta", "gamma", "epsilon"]
+//! [16]
+
+ list.clear();
+//! [17]
+ list << "Bill Clinton" << "Murray, Bill";
+ list.replaceInStrings(QRegularExpression("^(.*), (.*)$"), "\\2 \\1");
+ // list == ["Bill Clinton", "Bill Murray"]
+//! [17]
+
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/src/corelib/doc/snippets/qstringlistmodel/main.cpp b/src/corelib/doc/snippets/qstringlistmodel/main.cpp
new file mode 100644
index 0000000000..24de0fd0ae
--- /dev/null
+++ b/src/corelib/doc/snippets/qstringlistmodel/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QStringListModel *model = new QStringListModel();
+ QStringList list;
+ list << "a" << "b" << "c";
+ model->setStringList(list);
+//! [0]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/src/corelib/doc/snippets/qtcast/qtcast.cpp b/src/corelib/doc/snippets/qtcast/qtcast.cpp
new file mode 100644
index 0000000000..f0c3834bf0
--- /dev/null
+++ b/src/corelib/doc/snippets/qtcast/qtcast.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QLabel>
+#include <QPushButton>
+
+#include "qtcast.h"
+
+MyWidget::MyWidget()
+{
+//! [0]
+ QObject *obj = new MyWidget;
+//! [0]
+
+//! [1]
+ QWidget *widget = qobject_cast<QWidget *>(obj);
+//! [1]
+
+//! [2]
+ MyWidget *myWidget = qobject_cast<MyWidget *>(obj);
+//! [2]
+
+//! [3]
+ QLabel *label = qobject_cast<QLabel *>(obj);
+//! [3] //! [4]
+ // label is 0
+//! [4]
+
+//! [5]
+ if (QLabel *label = qobject_cast<QLabel *>(obj)) {
+//! [5] //! [6]
+ label->setText(tr("Ping"));
+ } else if (QPushButton *button = qobject_cast<QPushButton *>(obj)) {
+ button->setText(tr("Pong!"));
+ }
+//! [6]
+}
+
+int main()
+{
+ return 0;
+}
diff --git a/src/corelib/doc/snippets/qxmlstreamwriter/main.cpp b/src/corelib/doc/snippets/qxmlstreamwriter/main.cpp
new file mode 100644
index 0000000000..907d779357
--- /dev/null
+++ b/src/corelib/doc/snippets/qxmlstreamwriter/main.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QCoreApplication>
+#include <QFile>
+#include <QXmlStreamWriter>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ QFile output;
+ output.open(stdout, QIODevice::WriteOnly);
+//! [write output]
+//! [start stream]
+ QXmlStreamWriter stream(&output);
+ stream.setAutoFormatting(true);
+ stream.writeStartDocument();
+//! [start stream]
+ stream.writeDTD("<!DOCTYPE xbel>");
+ stream.writeStartElement("xbel");
+ stream.writeAttribute("version", "1.0");
+ stream.writeStartElement("folder");
+ stream.writeAttribute("folded", "no");
+//! [write element]
+ stream.writeStartElement("bookmark");
+ stream.writeAttribute("href", "http://qt.nokia.com/");
+ stream.writeTextElement("title", "Qt Home");
+ stream.writeEndElement(); // bookmark
+//! [write element]
+ stream.writeEndElement(); // folder
+ stream.writeEndElement(); // xbel
+//! [finish stream]
+ stream.writeEndDocument();
+//! [finish stream]
+//! [write output]
+ output.close();
+ return 0;
+}
diff --git a/src/corelib/doc/snippets/settings/settings.cpp b/src/corelib/doc/snippets/settings/settings.cpp
new file mode 100644
index 0000000000..8648843d43
--- /dev/null
+++ b/src/corelib/doc/snippets/settings/settings.cpp
@@ -0,0 +1,184 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QWidget *win;
+QWidget *panel;
+
+void snippet_ctor1()
+{
+//! [0]
+ QSettings settings("MySoft", "Star Runner");
+//! [0]
+}
+
+void snippet_ctor2()
+{
+//! [1]
+ QCoreApplication::setOrganizationName("MySoft");
+//! [1] //! [2]
+ QCoreApplication::setOrganizationDomain("mysoft.com");
+//! [2] //! [3]
+ QCoreApplication::setApplicationName("Star Runner");
+//! [3]
+
+//! [4]
+ QSettings settings;
+//! [4]
+
+//! [5]
+ settings.setValue("editor/wrapMargin", 68);
+//! [5] //! [6]
+ int margin = settings.value("editor/wrapMargin").toInt();
+//! [6]
+ {
+//! [7]
+ int margin = settings.value("editor/wrapMargin", 80).toInt();
+//! [7]
+ }
+
+//! [8]
+ settings.setValue("mainwindow/size", win->size());
+//! [8] //! [9]
+ settings.setValue("mainwindow/fullScreen", win->isFullScreen());
+//! [9] //! [10]
+ settings.setValue("outputpanel/visible", panel->isVisible());
+//! [10]
+
+//! [11]
+ settings.beginGroup("mainwindow");
+ settings.setValue("size", win->size());
+ settings.setValue("fullScreen", win->isFullScreen());
+ settings.endGroup();
+//! [11]
+
+//! [12]
+ settings.beginGroup("outputpanel");
+ settings.setValue("visible", panel->isVisible());
+ settings.endGroup();
+//! [12]
+}
+
+void snippet_locations()
+{
+//! [13]
+ QSettings obj1("MySoft", "Star Runner");
+//! [13] //! [14]
+ QSettings obj2("MySoft");
+ QSettings obj3(QSettings::SystemScope, "MySoft", "Star Runner");
+ QSettings obj4(QSettings::SystemScope, "MySoft");
+//! [14]
+
+ {
+//! [15]
+ QSettings settings(QSettings::IniFormat, QSettings::UserScope,
+ "MySoft", "Star Runner");
+//! [15]
+ }
+
+ {
+ QSettings settings("starrunner.ini", QSettings::IniFormat);
+ }
+
+ {
+ QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft",
+ QSettings::NativeFormat);
+ }
+}
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow();
+
+ void writeSettings();
+ void readSettings();
+
+protected:
+ void closeEvent(QCloseEvent *event);
+};
+
+//! [16]
+void MainWindow::writeSettings()
+{
+ QSettings settings("Moose Soft", "Clipper");
+
+ settings.beginGroup("MainWindow");
+ settings.setValue("size", size());
+ settings.setValue("pos", pos());
+ settings.endGroup();
+}
+//! [16]
+
+//! [17]
+void MainWindow::readSettings()
+{
+ QSettings settings("Moose Soft", "Clipper");
+
+ settings.beginGroup("MainWindow");
+ resize(settings.value("size", QSize(400, 400)).toSize());
+ move(settings.value("pos", QPoint(200, 200)).toPoint());
+ settings.endGroup();
+}
+//! [17]
+
+//! [18]
+MainWindow::MainWindow()
+{
+//! [18] //! [19]
+ readSettings();
+//! [19] //! [20]
+}
+//! [20]
+
+bool userReallyWantsToQuit() { return true; }
+
+//! [21]
+void MainWindow::closeEvent(QCloseEvent *event)
+{
+ if (userReallyWantsToQuit()) {
+ writeSettings();
+ event->accept();
+ } else {
+ event->ignore();
+ }
+}
+//! [21]
diff --git a/src/corelib/doc/snippets/sharedemployee/employee.h b/src/corelib/doc/snippets/sharedemployee/employee.h
new file mode 100644
index 0000000000..efb1d32000
--- /dev/null
+++ b/src/corelib/doc/snippets/sharedemployee/employee.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+//! [0]
+#include <QSharedData>
+#include <QString>
+
+class EmployeeData : public QSharedData
+{
+ public:
+ EmployeeData() : id(-1) { }
+ EmployeeData(const EmployeeData &other)
+ : QSharedData(other), id(other.id), name(other.name) { }
+ ~EmployeeData() { }
+
+ int id;
+ QString name;
+};
+
+class Employee
+{
+ public:
+//! [1]
+ Employee() { d = new EmployeeData; }
+//! [1] //! [2]
+ Employee(int id, QString name) {
+ d = new EmployeeData;
+ setId(id);
+ setName(name);
+ }
+//! [2] //! [7]
+ Employee(const Employee &other)
+ : d (other.d)
+ {
+ }
+//! [7]
+//! [3]
+ void setId(int id) { d->id = id; }
+//! [3] //! [4]
+ void setName(QString name) { d->name = name; }
+//! [4]
+
+//! [5]
+ int id() const { return d->id; }
+//! [5] //! [6]
+ QString name() const { return d->name; }
+//! [6]
+
+ private:
+ QSharedDataPointer<EmployeeData> d;
+};
+//! [0]
+
+#endif
diff --git a/src/corelib/doc/snippets/sharedemployee/main.cpp b/src/corelib/doc/snippets/sharedemployee/main.cpp
new file mode 100644
index 0000000000..6e840ab5e6
--- /dev/null
+++ b/src/corelib/doc/snippets/sharedemployee/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include "employee.h"
+
+int main()
+{
+ Employee e1(1001, "Albrecht Durer");
+ Employee e2 = e1;
+ e1.setName("Hans Holbein");
+}
+//! [0]
diff --git a/src/corelib/doc/snippets/signalmapper/filereader.cpp b/src/corelib/doc/snippets/signalmapper/filereader.cpp
new file mode 100644
index 0000000000..067ba8280e
--- /dev/null
+++ b/src/corelib/doc/snippets/signalmapper/filereader.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "filereader.h"
+
+
+FileReader::FileReader(QWidget *parent)
+ : QWidget(parent)
+{
+ textEdit = new QTextEdit;
+
+ taxFileButton = new QPushButton("Tax File");
+ accountFileButton = new QPushButton("Accounts File");
+ reportFileButton = new QPushButton("Report File");
+
+//! [0]
+ signalMapper = new QSignalMapper(this);
+ signalMapper->setMapping(taxFileButton, QString("taxfile.txt"));
+ signalMapper->setMapping(accountFileButton, QString("accountsfile.txt"));
+ signalMapper->setMapping(reportFileButton, QString("reportfile.txt"));
+
+ connect(taxFileButton, &QPushButton::clicked,
+ signalMapper, &QSignalMapper::map);
+ connect(accountFileButton, &QPushButton::clicked,
+ signalMapper, &QSignalMapper::map);
+ connect(reportFileButton, &QPushButton::clicked,
+ signalMapper, &QSignalMapper::map);
+//! [0]
+
+//! [1]
+ connect(signalMapper, SIGNAL(mapped(QString)),
+ this, SLOT(readFile(QString)));
+//! [1]
+
+/*
+//! [2]
+ //slower due to signature normalization at runtime
+
+ connect(signalMapper, SIGNAL(mapped(const QString &)),
+ this, SLOT(readFile(const QString &)));
+//! [2]
+*/
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
+ buttonLayout->addWidget(taxFileButton);
+ buttonLayout->addWidget(accountFileButton);
+ buttonLayout->addWidget(reportFileButton);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(textEdit);
+ mainLayout->addLayout(buttonLayout);
+
+ setLayout(mainLayout);
+}
+
+void FileReader::readFile(const QString &filename)
+{
+ QFile file(filename);
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ QMessageBox::information(this, tr("Unable to open file"),
+ file.errorString());
+ return;
+ }
+
+
+ QTextStream in(&file);
+ textEdit->setPlainText(in.readAll());
+}
+
diff --git a/src/corelib/doc/snippets/signalsandslots/lcdnumber.h b/src/corelib/doc/snippets/signalsandslots/lcdnumber.h
new file mode 100644
index 0000000000..7056254f9f
--- /dev/null
+++ b/src/corelib/doc/snippets/signalsandslots/lcdnumber.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#ifndef LCDNUMBER_H
+//! [0] //! [1]
+#define LCDNUMBER_H
+//! [1]
+
+//! [2]
+#include <QFrame>
+//! [2]
+
+//! [3]
+class LcdNumber : public QFrame
+//! [3] //! [4]
+{
+//! [4] //! [5]
+ Q_OBJECT
+//! [5]
+
+//! [6]
+public:
+//! [6] //! [7]
+ LcdNumber(QWidget *parent = 0);
+//! [7]
+
+//! [8]
+signals:
+//! [8] //! [9]
+ void overflow();
+//! [9]
+
+//! [10]
+public slots:
+//! [10] //! [11]
+ void display(int num);
+ void display(double num);
+ void display(const QString &str);
+ void setHexMode();
+ void setDecMode();
+ void setOctMode();
+ void setBinMode();
+ void setSmallDecimalPoint(bool point);
+//! [11] //! [12]
+};
+//! [12]
+
+//! [13]
+#endif
+//! [13]
diff --git a/src/corelib/doc/snippets/signalsandslots/signalsandslots.cpp b/src/corelib/doc/snippets/signalsandslots/signalsandslots.cpp
new file mode 100644
index 0000000000..3072650585
--- /dev/null
+++ b/src/corelib/doc/snippets/signalsandslots/signalsandslots.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QAbstractButton>
+
+#include "signalsandslots.h"
+
+//! [0]
+void Counter::setValue(int value)
+{
+ if (value != m_value) {
+ m_value = value;
+ emit valueChanged(value);
+ }
+}
+//! [0]
+
+int main()
+{
+//! [1]
+ Counter a, b;
+//! [1] //! [2]
+ QObject::connect(&a, &Counter::valueChanged,
+ &b, &Counter::setValue);
+//! [2]
+
+//! [3]
+ a.setValue(12); // a.value() == 12, b.value() == 12
+//! [3] //! [4]
+ b.setValue(48); // a.value() == 12, b.value() == 48
+//! [4]
+
+
+ QWidget *widget = reinterpret_cast<QWidget *>(new QObject(0));
+//! [5]
+ if (widget->inherits("QAbstractButton")) {
+ QAbstractButton *button = static_cast<QAbstractButton *>(widget);
+ button->toggle();
+//! [5] //! [6]
+ }
+//! [6]
+
+//! [7]
+ if (QAbstractButton *button = qobject_cast<QAbstractButton *>(widget))
+ button->toggle();
+//! [7]
+}
diff --git a/src/corelib/doc/snippets/signalsandslots/signalsandslots.h b/src/corelib/doc/snippets/signalsandslots/signalsandslots.h
new file mode 100644
index 0000000000..e18f955a41
--- /dev/null
+++ b/src/corelib/doc/snippets/signalsandslots/signalsandslots.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIGNALSANDSLOTS_H
+#define SIGNALSANDSLOTS_H
+
+#define Counter PlainCounter
+
+//! [0]
+class Counter
+{
+public:
+ Counter() { m_value = 0; }
+
+ int value() const { return m_value; }
+ void setValue(int value);
+
+private:
+ int m_value;
+};
+//! [0]
+
+#undef Counter
+#define Counter ObjectCounter
+
+//! [1]
+#include <QObject>
+//! [1]
+
+//! [2]
+class Counter : public QObject
+//! [2] //! [3]
+{
+ Q_OBJECT
+
+public:
+ Counter() { m_value = 0; }
+
+ int value() const { return m_value; }
+
+public slots:
+ void setValue(int value);
+
+signals:
+ void valueChanged(int newValue);
+
+private:
+ int m_value;
+};
+//! [3]
+
+#endif
diff --git a/src/corelib/doc/snippets/streaming/main.cpp b/src/corelib/doc/snippets/streaming/main.cpp
new file mode 100644
index 0000000000..7c992345c2
--- /dev/null
+++ b/src/corelib/doc/snippets/streaming/main.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore>
+#include <QByteArray>
+#include <QDataStream>
+
+//! [0]
+struct Movie
+{
+ int id;
+ QString title;
+ QDate releaseDate;
+};
+//! [0]
+
+//! [1]
+QDataStream &operator<<(QDataStream &out, const Movie &movie)
+{
+ out << (quint32)movie.id << movie.title
+ << movie.releaseDate;
+ return out;
+}
+//! [1]
+
+//! [2]
+QDataStream &operator>>(QDataStream &in, Movie &movie)
+{
+ quint32 id;
+ QDate date;
+
+ in >> id >> movie.title >> date;
+ movie.id = (int)id;
+ movie.releaseDate = date;
+ return in;
+}
+//! [2]
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+
+ Movie m;
+ m.id = 0001;
+ m.title = "Happy Meal";
+ m.releaseDate = QDate(1995, 5, 17);
+
+ QByteArray byteArray;
+ QDataStream stream(&byteArray, QIODevice::WriteOnly);
+ stream << m;
+
+ // display
+ qDebug() << m.id << m.releaseDate << m.title;
+
+ Movie m2;
+
+ int id2;
+ QString title2;
+ QDate date2;
+
+ QDataStream stream2(byteArray);
+ stream2 >> id2 >> title2 >> date2;
+
+ m2.id = id2;
+ m2.title = title2;
+ m2.releaseDate = date2;
+
+ qDebug() << id2 << " " << date2 << " " << title2;
+
+ return 0;
+}
diff --git a/src/corelib/doc/snippets/streaming/streaming.pro b/src/corelib/doc/snippets/streaming/streaming.pro
new file mode 100644
index 0000000000..8c5eb91f05
--- /dev/null
+++ b/src/corelib/doc/snippets/streaming/streaming.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+CONFIG += CONSOLE \ No newline at end of file
diff --git a/src/corelib/doc/snippets/threads/threads.cpp b/src/corelib/doc/snippets/threads/threads.cpp
new file mode 100644
index 0000000000..9ef716705a
--- /dev/null
+++ b/src/corelib/doc/snippets/threads/threads.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QCache>
+#include <QMutex>
+#include <QThreadStorage>
+
+#include "threads.h"
+
+//! [0]
+void MyThread::run()
+//! [0] //! [1]
+{
+//! [1] //! [2]
+}
+//! [2]
+
+#define Counter ReentrantCounter
+
+//! [3]
+class Counter
+//! [3] //! [4]
+{
+public:
+ Counter() { n = 0; }
+
+ void increment() { ++n; }
+ void decrement() { --n; }
+ int value() const { return n; }
+
+private:
+ int n;
+};
+//! [4]
+
+#undef Counter
+#define Counter ThreadSafeCounter
+
+//! [5]
+class Counter
+//! [5] //! [6]
+{
+public:
+ Counter() { n = 0; }
+
+ void increment() { QMutexLocker locker(&mutex); ++n; }
+ void decrement() { QMutexLocker locker(&mutex); --n; }
+ int value() const { QMutexLocker locker(&mutex); return n; }
+
+private:
+ mutable QMutex mutex;
+ int n;
+};
+//! [6]
+
+typedef int SomeClass;
+
+//! [7]
+QThreadStorage<QCache<QString, SomeClass> > caches;
+
+void cacheObject(const QString &key, SomeClass *object)
+//! [7] //! [8]
+{
+ caches.localData().insert(key, object);
+}
+
+void removeFromCache(const QString &key)
+//! [8] //! [9]
+{
+ if (!caches.hasLocalData())
+ return;
+
+ caches.localData().remove(key);
+}
+//! [9]
+
+int main()
+{
+ return 0;
+}
diff --git a/src/corelib/doc/snippets/threads/threads.h b/src/corelib/doc/snippets/threads/threads.h
new file mode 100644
index 0000000000..a45a2c92da
--- /dev/null
+++ b/src/corelib/doc/snippets/threads/threads.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QThread>
+
+//! [0]
+class MyThread : public QThread
+{
+ Q_OBJECT
+
+protected:
+ void run();
+};
+//! [0]
diff --git a/src/corelib/doc/snippets/timers/timers.cpp b/src/corelib/doc/snippets/timers/timers.cpp
new file mode 100644
index 0000000000..65b1c0d146
--- /dev/null
+++ b/src/corelib/doc/snippets/timers/timers.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTimer>
+
+class Foo : public QObject
+{
+public:
+ Foo();
+};
+
+Foo::Foo()
+{
+//! [0]
+ QTimer *timer = new QTimer(this);
+//! [0] //! [1]
+ connect(timer, SIGNAL(timeout()), this, SLOT(updateCaption()));
+//! [1] //! [2]
+ timer->start(1000);
+//! [2]
+
+//! [3]
+ QTimer::singleShot(200, this, SLOT(updateCaption()));
+//! [3]
+
+ {
+ // ZERO-CASE
+//! [4]
+ QTimer *timer = new QTimer(this);
+//! [4] //! [5]
+ connect(timer, SIGNAL(timeout()), this, SLOT(processOneThing()));
+//! [5] //! [6]
+ timer->start();
+//! [6]
+ }
+}
+
+int main()
+{
+
+}
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc
new file mode 100644
index 0000000000..8419a92dcf
--- /dev/null
+++ b/src/corelib/doc/src/containers.qdoc
@@ -0,0 +1,803 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \group tools
+ \title Non-GUI Classes
+ \ingroup groups
+
+ \brief Collection classes such as list, queue, stack and string, along
+ with other classes that can be used without needing QApplication.
+
+ The non-GUI classes are general-purpose collection and string classes
+ that may be used independently of the GUI classes.
+
+ In particular, these classes do not depend on QApplication at all,
+ and so can be used in non-GUI programs.
+
+*/
+
+/*!
+ \page containers.html
+ \title Container Classes
+ \ingroup technology-apis
+ \ingroup groups
+ \ingroup qt-basic-concepts
+ \keyword container class
+ \keyword container classes
+
+ \brief Qt's template-based container classes.
+
+ \tableofcontents
+
+ \section1 Introduction
+
+ The Qt library provides a set of general purpose template-based
+ container classes. These classes can be used to store items of a
+ specified type. For example, if you need a resizable array of
+ \l{QString}s, use QVector<QString>.
+
+ These container classes are designed to be lighter, safer, and
+ easier to use than the STL containers. If you are unfamiliar with
+ the STL, or prefer to do things the "Qt way", you can use these
+ classes instead of the STL classes.
+
+ The container classes are \l{implicitly shared}, they are
+ \l{reentrant}, and they are optimized for speed, low memory
+ consumption, and minimal inline code expansion, resulting in
+ smaller executables. In addition, they are \l{thread-safe}
+ in situations where they are used as read-only containers
+ by all threads used to access them.
+
+ For traversing the items stored in a container, you can use one
+ of two types of iterators: \l{Java-style iterators} and
+ \l{STL-style iterators}. The Java-style iterators are easier to
+ use and provide high-level functionality, whereas the STL-style
+ iterators are slightly more efficient and can be used together
+ with Qt's and STL's \l{generic algorithms}.
+
+ Qt also offers a \l{foreach} keyword that make it very
+ easy to iterate over all the items stored in a container.
+
+ \section1 The Container Classes
+
+ Qt provides the following sequential containers: QList,
+ QLinkedList, QVector, QStack, and QQueue. For most
+ applications, QList is the best type to use. Although it is
+ implemented as an array-list, it provides very fast prepends and
+ appends. If you really need a linked-list, use QLinkedList; if you
+ want your items to occupy consecutive memory locations, use QVector.
+ QStack and QQueue are convenience classes that provide LIFO and
+ FIFO semantics.
+
+ Qt also provides these associative containers: QMap,
+ QMultiMap, QHash, QMultiHash, and QSet. The "Multi" containers
+ conveniently support multiple values associated with a single
+ key. The "Hash" containers provide faster lookup by using a hash
+ function instead of a binary search on a sorted set.
+
+ As special cases, the QCache and QContiguousCache classes provide
+ efficient hash-lookup of objects in a limited cache storage.
+
+ \table
+ \header \li Class \li Summary
+
+ \row \li \l{QList}<T>
+ \li This is by far the most commonly used container class. It
+ stores a list of values of a given type (T) that can be accessed
+ by index. Internally, the QList is implemented using an array,
+ ensuring that index-based access is very fast.
+
+ Items can be added at either end of the list using
+ QList::append() and QList::prepend(), or they can be inserted in
+ the middle using QList::insert(). More than any other container
+ class, QList is highly optimized to expand to as little code as
+ possible in the executable. QStringList inherits from
+ QList<QString>.
+
+ \row \li \l{QLinkedList}<T>
+ \li This is similar to QList, except that it uses
+ iterators rather than integer indexes to access items. It also
+ provides better performance than QList when inserting in the
+ middle of a huge list, and it has nicer iterator semantics.
+ (Iterators pointing to an item in a QLinkedList remain valid as
+ long as the item exists, whereas iterators to a QList can become
+ invalid after any insertion or removal.)
+
+ \row \li \l{QVector}<T>
+ \li This stores an array of values of a given type at adjacent
+ positions in memory. Inserting at the front or in the middle of
+ a vector can be quite slow, because it can lead to large numbers
+ of items having to be moved by one position in memory.
+
+ \row \li \l{QStack}<T>
+ \li This is a convenience subclass of QVector that provides
+ "last in, first out" (LIFO) semantics. It adds the following
+ functions to those already present in QVector:
+ \l{QStack::push()}{push()}, \l{QStack::pop()}{pop()},
+ and \l{QStack::top()}{top()}.
+
+ \row \li \l{QQueue}<T>
+ \li This is a convenience subclass of QList that provides
+ "first in, first out" (FIFO) semantics. It adds the following
+ functions to those already present in QList:
+ \l{QQueue::enqueue()}{enqueue()},
+ \l{QQueue::dequeue()}{dequeue()}, and \l{QQueue::head()}{head()}.
+
+ \row \li \l{QSet}<T>
+ \li This provides a single-valued mathematical set with fast
+ lookups.
+
+ \row \li \l{QMap}<Key, T>
+ \li This provides a dictionary (associative array) that maps keys
+ of type Key to values of type T. Normally each key is associated
+ with a single value. QMap stores its data in Key order; if order
+ doesn't matter QHash is a faster alternative.
+
+ \row \li \l{QMultiMap}<Key, T>
+ \li This is a convenience subclass of QMap that provides a nice
+ interface for multi-valued maps, i.e. maps where one key can be
+ associated with multiple values.
+
+ \row \li \l{QHash}<Key, T>
+ \li This has almost the same API as QMap, but provides
+ significantly faster lookups. QHash stores its data in an
+ arbitrary order.
+
+ \row \li \l{QMultiHash}<Key, T>
+ \li This is a convenience subclass of QHash that
+ provides a nice interface for multi-valued hashes.
+
+ \endtable
+
+ Containers can be nested. For example, it is perfectly possible
+ to use a QMap<QString, QList<int> >, where the key type is
+ QString and the value type QList<int>. The only pitfall is that
+ you must insert a space between the closing angle brackets (>);
+ otherwise the C++ compiler will misinterpret the two >'s as a
+ right-shift operator (>>) and report a syntax error.
+
+ The containers are defined in individual header files with the
+ same name as the container (e.g., \c <QLinkedList>). For
+ convenience, the containers are forward declared in \c
+ <QtContainerFwd>.
+
+ \keyword assignable data type
+ \keyword assignable data types
+
+ The values stored in the various containers can be of any
+ \e{assignable data type}. To qualify, a type must provide a
+ default constructor, a copy constructor, and an assignment
+ operator. This covers most data types you are likely to want to
+ store in a container, including basic types such as \c int and \c
+ double, pointer types, and Qt data types such as QString, QDate,
+ and QTime, but it doesn't cover QObject or any QObject subclass
+ (QWidget, QDialog, QTimer, etc.). If you attempt to instantiate a
+ QList<QWidget>, the compiler will complain that QWidget's copy
+ constructor and assignment operators are disabled. If you want to
+ store these kinds of objects in a container, store them as
+ pointers, for example as QList<QWidget *>.
+
+ Here's an example custom data type that meets the requirement of
+ an assignable data type:
+
+ \snippet code/doc_src_containers.cpp 0
+
+ If we don't provide a copy constructor or an assignment operator,
+ C++ provides a default implementation that performs a
+ member-by-member copy. In the example above, that would have been
+ sufficient. Also, if you don't provide any constructors, C++
+ provides a default constructor that initializes its member using
+ default constructors. Although it doesn't provide any
+ explicit constructors or assignment operator, the following data
+ type can be stored in a container:
+
+ \snippet streaming/main.cpp 0
+
+ Some containers have additional requirements for the data types
+ they can store. For example, the Key type of a QMap<Key, T> must
+ provide \c operator<(). Such special requirements are documented
+ in a class's detailed description. In some cases, specific
+ functions have special requirements; these are described on a
+ per-function basis. The compiler will always emit an error if a
+ requirement isn't met.
+
+ Qt's containers provide operator<<() and operator>>() so that they
+ can easily be read and written using a QDataStream. This means
+ that the data types stored in the container must also support
+ operator<<() and operator>>(). Providing such support is
+ straightforward; here's how we could do it for the Movie struct
+ above:
+
+ \snippet streaming/main.cpp 1
+ \codeline
+ \snippet streaming/main.cpp 2
+
+ \keyword default-constructed values
+
+ The documentation of certain container class functions refer to
+ \e{default-constructed values}; for example, QVector
+ automatically initializes its items with default-constructed
+ values, and QMap::value() returns a default-constructed value if
+ the specified key isn't in the map. For most value types, this
+ simply means that a value is created using the default
+ constructor (e.g. an empty string for QString). But for primitive
+ types like \c{int} and \c{double}, as well as for pointer types,
+ the C++ language doesn't specify any initialization; in those
+ cases, Qt's containers automatically initialize the value to 0.
+
+ \section1 The Iterator Classes
+
+ Iterators provide a uniform means to access items in a container.
+ Qt's container classes provide two types of iterators: Java-style
+ iterators and STL-style iterators. Iterators of both types are
+ invalidated when the data in the container is modified or detached
+ from \l{Implicit Sharing}{implicitly shared copies} due to a call
+ to a non-const member function.
+
+ \section2 Java-Style Iterators
+
+ The Java-style iterators are new in Qt 4 and are the standard
+ ones used in Qt applications. They are more convenient to use than
+ the STL-style iterators, at the price of being slightly less
+ efficient. Their API is modelled on Java's iterator classes.
+
+ For each container class, there are two Java-style iterator data
+ types: one that provides read-only access and one that provides
+ read-write access.
+
+ \table
+ \header \li Containers \li Read-only iterator
+ \li Read-write iterator
+ \row \li QList<T>, QQueue<T> \li QListIterator<T>
+ \li QMutableListIterator<T>
+ \row \li QLinkedList<T> \li QLinkedListIterator<T>
+ \li QMutableLinkedListIterator<T>
+ \row \li QVector<T>, QStack<T> \li QVectorIterator<T>
+ \li QMutableVectorIterator<T>
+ \row \li QSet<T> \li QSetIterator<T>
+ \li QMutableSetIterator<T>
+ \row \li QMap<Key, T>, QMultiMap<Key, T> \li QMapIterator<Key, T>
+ \li QMutableMapIterator<Key, T>
+ \row \li QHash<Key, T>, QMultiHash<Key, T> \li QHashIterator<Key, T>
+ \li QMutableHashIterator<Key, T>
+ \endtable
+
+ In this discussion, we will concentrate on QList and QMap. The
+ iterator types for QLinkedList, QVector, and QSet have exactly
+ the same interface as QList's iterators; similarly, the iterator
+ types for QHash have the same interface as QMap's iterators.
+
+ Unlike STL-style iterators (covered \l{STL-style
+ iterators}{below}), Java-style iterators point \e between items
+ rather than directly \e at items. For this reason, they are
+ either pointing to the very beginning of the container (before
+ the first item), at the very end of the container (after the last
+ item), or between two items. The diagram below shows the valid
+ iterator positions as red arrows for a list containing four
+ items:
+
+ \image javaiterators1.png
+
+ Here's a typical loop for iterating through all the elements of a
+ QList<QString> in order and printing them to the console:
+
+ \snippet code/doc_src_containers.cpp 1
+
+ It works as follows: The QList to iterate over is passed to the
+ QListIterator constructor. At that point, the iterator is located
+ just in front of the first item in the list (before item "A").
+ Then we call \l{QListIterator::hasNext()}{hasNext()} to
+ check whether there is an item after the iterator. If there is, we
+ call \l{QListIterator::next()}{next()} to jump over that
+ item. The next() function returns the item that it jumps over. For
+ a QList<QString>, that item is of type QString.
+
+ Here's how to iterate backward in a QList:
+
+ \snippet code/doc_src_containers.cpp 2
+
+ The code is symmetric with iterating forward, except that we
+ start by calling \l{QListIterator::toBack()}{toBack()}
+ to move the iterator after the last item in the list.
+
+ The diagram below illustrates the effect of calling
+ \l{QListIterator::next()}{next()} and
+ \l{QListIterator::previous()}{previous()} on an iterator:
+
+ \image javaiterators2.png
+
+ The following table summarizes the QListIterator API:
+
+ \table
+ \header \li Function \li Behavior
+ \row \li \l{QListIterator::toFront()}{toFront()}
+ \li Moves the iterator to the front of the list (before the first item)
+ \row \li \l{QListIterator::toBack()}{toBack()}
+ \li Moves the iterator to the back of the list (after the last item)
+ \row \li \l{QListIterator::hasNext()}{hasNext()}
+ \li Returns true if the iterator isn't at the back of the list
+ \row \li \l{QListIterator::next()}{next()}
+ \li Returns the next item and advances the iterator by one position
+ \row \li \l{QListIterator::peekNext()}{peekNext()}
+ \li Returns the next item without moving the iterator
+ \row \li \l{QListIterator::hasPrevious()}{hasPrevious()}
+ \li Returns true if the iterator isn't at the front of the list
+ \row \li \l{QListIterator::previous()}{previous()}
+ \li Returns the previous item and moves the iterator back by one position
+ \row \li \l{QListIterator::peekPrevious()}{peekPrevious()}
+ \li Returns the previous item without moving the iterator
+ \endtable
+
+ QListIterator provides no functions to insert or remove items
+ from the list as we iterate. To accomplish this, you must use
+ QMutableListIterator. Here's an example where we remove all
+ odd numbers from a QList<int> using QMutableListIterator:
+
+ \snippet code/doc_src_containers.cpp 3
+
+ The next() call in the loop is made every time. It jumps over the
+ next item in the list. The
+ \l{QMutableListIterator::remove()}{remove()} function removes the
+ last item that we jumped over from the list. The call to
+ \l{QMutableListIterator::remove()}{remove()} does not invalidate
+ the iterator, so it is safe to continue using it. This works just
+ as well when iterating backward:
+
+ \snippet code/doc_src_containers.cpp 4
+
+ If we just want to modify the value of an existing item, we can
+ use \l{QMutableListIterator::setValue()}{setValue()}. In the code
+ below, we replace any value larger than 128 with 128:
+
+ \snippet code/doc_src_containers.cpp 5
+
+ Just like \l{QMutableListIterator::remove()}{remove()},
+ \l{QMutableListIterator::setValue()}{setValue()} operates on the
+ last item that we jumped over. If we iterate forward, this is the
+ item just before the iterator; if we iterate backward, this is
+ the item just after the iterator.
+
+ The \l{QMutableListIterator::next()}{next()} function returns a
+ non-const reference to the item in the list. For simple
+ operations, we don't even need
+ \l{QMutableListIterator::setValue()}{setValue()}:
+
+ \snippet code/doc_src_containers.cpp 6
+
+ As mentioned above, QLinkedList's, QVector's, and QSet's iterator
+ classes have exactly the same API as QList's. We will now turn to
+ QMapIterator, which is somewhat different because it iterates on
+ (key, value) pairs.
+
+ Like QListIterator, QMapIterator provides
+ \l{QMapIterator::toFront()}{toFront()},
+ \l{QMapIterator::toBack()}{toBack()},
+ \l{QMapIterator::hasNext()}{hasNext()},
+ \l{QMapIterator::next()}{next()},
+ \l{QMapIterator::peekNext()}{peekNext()},
+ \l{QMapIterator::hasPrevious()}{hasPrevious()},
+ \l{QMapIterator::previous()}{previous()}, and
+ \l{QMapIterator::peekPrevious()}{peekPrevious()}. The key and
+ value components are extracted by calling key() and value() on
+ the object returned by next(), peekNext(), previous(), or
+ peekPrevious().
+
+ The following example removes all (capital, country) pairs where
+ the capital's name ends with "City":
+
+ \snippet code/doc_src_containers.cpp 7
+
+ QMapIterator also provides a key() and a value() function that
+ operate directly on the iterator and that return the key and
+ value of the last item that the iterator jumped above. For
+ example, the following code copies the contents of a QMap into a
+ QHash:
+
+ \snippet code/doc_src_containers.cpp 8
+
+ If we want to iterate through all the items with the same
+ value, we can use \l{QMapIterator::findNext()}{findNext()}
+ or \l{QMapIterator::findPrevious()}{findPrevious()}.
+ Here's an example where we remove all the items with a particular
+ value:
+
+ \snippet code/doc_src_containers.cpp 9
+
+ \section2 STL-Style Iterators
+
+ STL-style iterators have been available since the release of Qt
+ 2.0. They are compatible with Qt's and STL's \l{generic
+ algorithms} and are optimized for speed.
+
+ For each container class, there are two STL-style iterator types:
+ one that provides read-only access and one that provides
+ read-write access. Read-only iterators should be used wherever
+ possible because they are faster than read-write iterators.
+
+ \table
+ \header \li Containers \li Read-only iterator
+ \li Read-write iterator
+ \row \li QList<T>, QQueue<T> \li QList<T>::const_iterator
+ \li QList<T>::iterator
+ \row \li QLinkedList<T> \li QLinkedList<T>::const_iterator
+ \li QLinkedList<T>::iterator
+ \row \li QVector<T>, QStack<T> \li QVector<T>::const_iterator
+ \li QVector<T>::iterator
+ \row \li QSet<T> \li QSet<T>::const_iterator
+ \li QSet<T>::iterator
+ \row \li QMap<Key, T>, QMultiMap<Key, T> \li QMap<Key, T>::const_iterator
+ \li QMap<Key, T>::iterator
+ \row \li QHash<Key, T>, QMultiHash<Key, T> \li QHash<Key, T>::const_iterator
+ \li QHash<Key, T>::iterator
+ \endtable
+
+ The API of the STL iterators is modelled on pointers in an array.
+ For example, the \c ++ operator advances the iterator to the next
+ item, and the \c * operator returns the item that the iterator
+ points to. In fact, for QVector and QStack, which store their
+ items at adjacent memory positions, the
+ \l{QVector::iterator}{iterator} type is just a typedef for \c{T *},
+ and the \l{QVector::iterator}{const_iterator} type is
+ just a typedef for \c{const T *}.
+
+ In this discussion, we will concentrate on QList and QMap. The
+ iterator types for QLinkedList, QVector, and QSet have exactly
+ the same interface as QList's iterators; similarly, the iterator
+ types for QHash have the same interface as QMap's iterators.
+
+ Here's a typical loop for iterating through all the elements of a
+ QList<QString> in order and converting them to lowercase:
+
+ \snippet code/doc_src_containers.cpp 10
+
+ Unlike \l{Java-style iterators}, STL-style iterators point
+ directly at items. The begin() function of a container returns an
+ iterator that points to the first item in the container. The
+ end() function of a container returns an iterator to the
+ imaginary item one position past the last item in the container.
+ end() marks an invalid position; it must never be dereferenced.
+ It is typically used in a loop's break condition. If the list is
+ empty, begin() equals end(), so we never execute the loop.
+
+ The diagram below shows the valid iterator positions as red
+ arrows for a vector containing four items:
+
+ \image stliterators1.png
+
+ Iterating backward with an STL-style iterator requires us to
+ decrement the iterator \e before we access the item. This
+ requires a \c while loop:
+
+ \snippet code/doc_src_containers.cpp 11
+
+ In the code snippets so far, we used the unary \c * operator to
+ retrieve the item (of type QString) stored at a certain iterator
+ position, and we then called QString::toLower() on it. Most C++
+ compilers also allow us to write \c{i->toLower()}, but some
+ don't.
+
+ For read-only access, you can use const_iterator, constBegin(),
+ and constEnd(). For example:
+
+ \snippet code/doc_src_containers.cpp 12
+
+ The following table summarizes the STL-style iterators' API:
+
+ \table
+ \header \li Expression \li Behavior
+ \row \li \c{*i} \li Returns the current item
+ \row \li \c{++i} \li Advances the iterator to the next item
+ \row \li \c{i += n} \li Advances the iterator by \c n items
+ \row \li \c{--i} \li Moves the iterator back by one item
+ \row \li \c{i -= n} \li Moves the iterator back by \c n items
+ \row \li \c{i - j} \li Returns the number of items between iterators \c i and \c j
+ \endtable
+
+ The \c{++} and \c{--} operators are available both as prefix
+ (\c{++i}, \c{--i}) and postfix (\c{i++}, \c{i--}) operators. The
+ prefix versions modify the iterators and return a reference to
+ the modified iterator; the postfix versions take a copy of the
+ iterator before they modify it, and return that copy. In
+ expressions where the return value is ignored, we recommend that
+ you use the prefix operators (\c{++i}, \c{--i}), as these are
+ slightly faster.
+
+ For non-const iterator types, the return value of the unary \c{*}
+ operator can be used on the left side of the assignment operator.
+
+ For QMap and QHash, the \c{*} operator returns the value
+ component of an item. If you want to retrieve the key, call key()
+ on the iterator. For symmetry, the iterator types also provide a
+ value() function to retrieve the value. For example, here's how
+ we would print all items in a QMap to the console:
+
+ \snippet code/doc_src_containers.cpp 13
+
+ Thanks to \l{implicit sharing}, it is very inexpensive for a
+ function to return a container per value. The Qt API contains
+ dozens of functions that return a QList or QStringList per value
+ (e.g., QSplitter::sizes()). If you want to iterate over these
+ using an STL iterator, you should always take a copy of the
+ container and iterate over the copy. For example:
+
+ \snippet code/doc_src_containers.cpp 14
+
+ This problem doesn't occur with functions that return a const or
+ non-const reference to a container.
+
+ \l{Implicit sharing} has another consequence on STL-style
+ iterators: You must not take a copy of a container while
+ non-const iterators are active on that container. Java-style
+ iterators don't suffer from that limitation.
+
+ \keyword foreach
+ \section1 The foreach Keyword
+
+ If you just want to iterate over all the items in a container
+ in order, you can use Qt's \c foreach keyword. The keyword is a
+ Qt-specific addition to the C++ language, and is implemented
+ using the preprocessor.
+
+ Its syntax is: \c foreach (\e variable, \e container) \e
+ statement. For example, here's how to use \c foreach to iterate
+ over a QLinkedList<QString>:
+
+ \snippet code/doc_src_containers.cpp 15
+
+ The \c foreach code is significantly shorter than the equivalent
+ code that uses iterators:
+
+ \snippet code/doc_src_containers.cpp 16
+
+ Unless the data type contains a comma (e.g., \c{QPair<int,
+ int>}), the variable used for iteration can be defined within the
+ \c foreach statement:
+
+ \snippet code/doc_src_containers.cpp 17
+
+ And like any other C++ loop construct, you can use braces around
+ the body of a \c foreach loop, and you can use \c break to leave
+ the loop:
+
+ \snippet code/doc_src_containers.cpp 18
+
+ With QMap and QHash, \c foreach accesses the value component of
+ the (key, value) pairs. If you want to iterate over both the keys
+ and the values, you can use iterators (which are fastest), or you
+ can write code like this:
+
+ \snippet code/doc_src_containers.cpp 19
+
+ For a multi-valued map:
+
+ \snippet code/doc_src_containers.cpp 20
+
+ Qt automatically takes a copy of the container when it enters a
+ \c foreach loop. If you modify the container as you are
+ iterating, that won't affect the loop. (If you do not modify the
+ container, the copy still takes place, but thanks to \l{implicit
+ sharing} copying a container is very fast.)
+
+ Since foreach creates a copy of the container, using a non-const
+ reference for the variable does not allow you to modify the original
+ container. It only affects the copy, which is probably not what you
+ want.
+
+ In addition to \c foreach, Qt also provides a \c forever
+ pseudo-keyword for infinite loops:
+
+ \snippet code/doc_src_containers.cpp 21
+
+ If you're worried about namespace pollution, you can disable
+ these macros by adding the following line to your \c .pro file:
+
+ \snippet code/doc_src_containers.cpp 22
+
+ \section1 Other Container-Like Classes
+
+ Qt includes three template classes that resemble containers in
+ some respects. These classes don't provide iterators and cannot
+ be used with the \c foreach keyword.
+
+ \list
+ \li QVarLengthArray<T, Prealloc> provides a low-level
+ variable-length array. It can be used instead of QVector in
+ places where speed is particularly important.
+
+ \li QCache<Key, T> provides a cache to store objects of a certain
+ type T associated with keys of type Key.
+
+ \li QContiguousCache<T> provides an efficient way of caching data
+ that is typically accessed in a contiguous way.
+
+ \li QPair<T1, T2> stores a pair of elements.
+ \endlist
+
+ Additional non-template types that compete with Qt's template
+ containers are QBitArray, QByteArray, QString, and QStringList.
+
+ \section1 Algorithmic Complexity
+
+ Algorithmic complexity is concerned about how fast (or slow) each
+ function is as the number of items in the container grow. For
+ example, inserting an item in the middle of a QLinkedList is an
+ extremely fast operation, irrespective of the number of items
+ stored in the QLinkedList. On the other hand, inserting an item
+ in the middle of a QVector is potentially very expensive if the
+ QVector contains many items, since half of the items must be
+ moved one position in memory.
+
+ To describe algorithmic complexity, we use the following
+ terminology, based on the "big Oh" notation:
+
+ \keyword constant time
+ \keyword logarithmic time
+ \keyword linear time
+ \keyword linear-logarithmic time
+ \keyword quadratic time
+
+ \list
+ \li \b{Constant time:} O(1). A function is said to run in constant
+ time if it requires the same amount of time no matter how many
+ items are present in the container. One example is
+ QLinkedList::insert().
+
+ \li \b{Logarithmic time:} O(log \e n). A function that runs in
+ logarithmic time is a function whose running time is
+ proportional to the logarithm of the number of items in the
+ container. One example is qBinaryFind().
+
+ \li \b{Linear time:} O(\e n). A function that runs in linear time
+ will execute in a time directly proportional to the number of
+ items stored in the container. One example is
+ QVector::insert().
+
+ \li \b{Linear-logarithmic time:} O(\e{n} log \e n). A function
+ that runs in linear-logarithmic time is asymptotically slower
+ than a linear-time function, but faster than a quadratic-time
+ function.
+
+ \li \b{Quadratic time:} O(\e{n}\unicode{178}). A quadratic-time function
+ executes in a time that is proportional to the square of the
+ number of items stored in the container.
+ \endlist
+
+ The following table summarizes the algorithmic complexity of Qt's
+ sequential container classes:
+
+ \table
+ \header \li \li Index lookup \li Insertion \li Prepending \li Appending
+ \row \li QLinkedList<T> \li O(\e n) \li O(1) \li O(1) \li O(1)
+ \row \li QList<T> \li O(1) \li O(n) \li Amort. O(1) \li Amort. O(1)
+ \row \li QVector<T> \li O(1) \li O(n) \li O(n) \li Amort. O(1)
+ \endtable
+
+ In the table, "Amort." stands for "amortized behavior". For
+ example, "Amort. O(1)" means that if you call the function
+ only once, you might get O(\e n) behavior, but if you call it
+ multiple times (e.g., \e n times), the average behavior will be
+ O(1).
+
+ The following table summarizes the algorithmic complexity of Qt's
+ associative containers and sets:
+
+ \table
+ \header \li{1,2} \li{2,1} Key lookup \li{2,1} Insertion
+ \header \li Average \li Worst case \li Average \li Worst case
+ \row \li QMap<Key, T> \li O(log \e n) \li O(log \e n) \li O(log \e n) \li O(log \e n)
+ \row \li QMultiMap<Key, T> \li O(log \e n) \li O(log \e n) \li O(log \e n) \li O(log \e n)
+ \row \li QHash<Key, T> \li Amort. O(1) \li O(\e n) \li Amort. O(1) \li O(\e n)
+ \row \li QSet<Key> \li Amort. O(1) \li O(\e n) \li Amort. O(1) \li O(\e n)
+ \endtable
+
+ With QVector, QHash, and QSet, the performance of appending items
+ is amortized O(log \e n). It can be brought down to O(1) by
+ calling QVector::reserve(), QHash::reserve(), or QSet::reserve()
+ with the expected number of items before you insert the items.
+ The next section discusses this topic in more depth.
+
+ \section1 Growth Strategies
+
+ QVector<T>, QString, and QByteArray store their items
+ contiguously in memory; QList<T> maintains an array of pointers
+ to the items it stores to provide fast index-based access (unless
+ T is a pointer type or a basic type of the size of a pointer, in
+ which case the value itself is stored in the array); QHash<Key,
+ T> keeps a hash table whose size is proportional to the number
+ of items in the hash. To avoid reallocating the data every single
+ time an item is added at the end of the container, these classes
+ typically allocate more memory than necessary.
+
+ Consider the following code, which builds a QString from another
+ QString:
+
+ \snippet code/doc_src_containers.cpp 23
+
+ We build the string \c out dynamically by appending one character
+ to it at a time. Let's assume that we append 15000 characters to
+ the QString string. Then the following 18 reallocations (out of a
+ possible 15000) occur when QString runs out of space: 4, 8, 12,
+ 16, 20, 52, 116, 244, 500, 1012, 2036, 4084, 6132, 8180, 10228,
+ 12276, 14324, 16372. At the end, the QString has 16372 Unicode
+ characters allocated, 15000 of which are occupied.
+
+ The values above may seem a bit strange, but here are the guiding
+ principles:
+ \list
+ \li QString allocates 4 characters at a time until it reaches size 20.
+ \li From 20 to 4084, it advances by doubling the size each time.
+ More precisely, it advances to the next power of two, minus
+ 12. (Some memory allocators perform worst when requested exact
+ powers of two, because they use a few bytes per block for
+ book-keeping.)
+ \li From 4084 on, it advances by blocks of 2048 characters (4096
+ bytes). This makes sense because modern operating systems
+ don't copy the entire data when reallocating a buffer; the
+ physical memory pages are simply reordered, and only the data
+ on the first and last pages actually needs to be copied.
+ \endlist
+
+ QByteArray and QList<T> use more or less the same algorithm as
+ QString.
+
+ QVector<T> also uses that algorithm for data types that can be
+ moved around in memory using memcpy() (including the basic C++
+ types, the pointer types, and Qt's \l{shared classes}) but uses a
+ different algorithm for data types that can only be moved by
+ calling the copy constructor and a destructor. Since the cost of
+ reallocating is higher in that case, QVector<T> reduces the
+ number of reallocations by always doubling the memory when
+ running out of space.
+
+ QHash<Key, T> is a totally different case. QHash's internal hash
+ table grows by powers of two, and each time it grows, the items
+ are relocated in a new bucket, computed as qHash(\e key) %
+ QHash::capacity() (the number of buckets). This remark applies to
+ QSet<T> and QCache<Key, T> as well.
+
+ For most applications, the default growing algorithm provided by
+ Qt does the trick. If you need more control, QVector<T>,
+ QHash<Key, T>, QSet<T>, QString, and QByteArray provide a trio of
+ functions that allow you to check and specify how much memory to
+ use to store the items:
+
+ \list
+ \li \l{QString::capacity()}{capacity()} returns the
+ number of items for which memory is allocated (for QHash and
+ QSet, the number of buckets in the hash table).
+ \li \l{QString::reserve()}{reserve}(\e size) explicitly
+ preallocates memory for \e size items.
+ \li \l{QString::squeeze()}{squeeze()} frees any memory
+ not required to store the items.
+ \endlist
+
+ If you know approximately how many items you will store in a
+ container, you can start by calling reserve(), and when you are
+ done populating the container, you can call squeeze() to release
+ the extra preallocated memory.
+*/
diff --git a/src/corelib/doc/src/datastreamformat.qdoc b/src/corelib/doc/src/datastreamformat.qdoc
new file mode 100644
index 0000000000..8ff31371a2
--- /dev/null
+++ b/src/corelib/doc/src/datastreamformat.qdoc
@@ -0,0 +1,373 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \page datastreamformat.html
+ \title Serializing Qt Data Types
+ \ingroup qt-network
+ \brief Representations of data types that can be serialized by QDataStream.
+
+ The \l QDataStream allows you to serialize some of the Qt data types.
+ The table below lists the data types that QDataStream can serialize
+ and how they are represented. The format described below is
+ \l{QDataStream::setVersion()}{version 12}.
+
+ It is always best to cast integers to a Qt integer type, such as
+ qint16 or quint32, when reading and writing. This ensures that
+ you always know exactly what size integers you are reading and
+ writing, no matter what the underlying platform and architecture
+ the application happens to be running on.
+
+ \table
+ \row \li bool
+ \li \list
+ \li boolean
+ \endlist
+ \row \li qint8
+ \li \list
+ \li signed byte
+ \endlist
+ \row \li qint16
+ \li \list
+ \li signed 16-bit integer
+ \endlist
+ \row \li qint32
+ \li \list
+ \li signed 32-bit integer
+ \endlist
+ \row \li qint64
+ \li \list
+ \li signed 64-bit integer
+ \endlist
+ \row \li quint8
+ \li \list
+ \li unsigned byte
+ \endlist
+ \row \li quint16
+ \li \list
+ \li unsigned 16-bit integer
+ \endlist
+ \row \li quint32
+ \li \list
+ \li unsigned 32-bit integer
+ \endlist
+ \row \li quint64
+ \li \list
+ \li unsigned 64-bit integer
+ \endlist
+ \row \li \c float
+ \li \list
+ \li 32-bit floating point number using the standard IEEE 754 format
+ \endlist
+ \row \li \c double
+ \li \list
+ \li 64-bit floating point number using the standard IEEE 754 format
+ \endlist
+ \row \li \c {const char *}
+ \li \list
+ \li The string length (quint32)
+ \li The string bytes, excluding the terminating 0
+ \endlist
+ \row \li QBitArray
+ \li \list
+ \li The array size (quint32)
+ \li The array bits, i.e. (size + 7)/8 bytes
+ \endlist
+ \row \li QBrush
+ \li \list
+ \li The brush style (quint8)
+ \li The brush color (QColor)
+ \li If style is CustomPattern, the brush pixmap (QPixmap)
+ \endlist
+ \row \li QByteArray
+ \li \list
+ \li If the byte array is null: 0xFFFFFFFF (quint32)
+ \li Otherwise: the array size (quint32) followed by the array bytes, i.e. size bytes
+ \endlist
+ \row \li \l QColor
+ \li \list
+ \li Color spec (qint8)
+ \li Alpha value (quint16)
+ \li Red value (quint16)
+ \li Green value (quint16)
+ \li Blue value (quint16)
+ \li Pad value (quint16)
+ \endlist
+ \row \li QCursor
+ \li \list
+ \li Shape ID (qint16)
+ \li If shape is BitmapCursor: The bitmap (QPixmap), mask (QPixmap), and hot spot (QPoint)
+ \endlist
+ \row \li QDate
+ \li \list
+ \li Julian day (quint32)
+ \endlist
+ \row \li QDateTime
+ \li \list
+ \li Date (QDate)
+ \li Time (QTime)
+ \li 0 for Qt::LocalTime, 1 for Qt::UTC (quint8)
+ \endlist
+ \row \li QEasingCurve
+ \li \list
+ \li type (quint8)
+ \li func (quint64)
+ \li hasConfig (bool)
+ \li If hasConfig is true then these fields follow:
+ \li list
+ \li period (double)
+ \li amplitude (double)
+ \li overshoot (double)
+ \endlist
+ \row \li QFont
+ \li \list
+ \li The family (QString)
+ \li The point size (qint16)
+ \li The style hint (quint8)
+ \li The char set (quint8)
+ \li The weight (quint8)
+ \li The font bits (quint8)
+ \endlist
+ \row \li QHash<Key, T>
+ \li \list
+ \li The number of items (quint32)
+ \li For all items, the key (Key) and value (T)
+ \endlist
+ \row \li QIcon
+ \li \list
+ \li The number of pixmap entries (quint32)
+ \li For all pixmap entries:
+ \list
+ \li The pixmap (QPixmap)
+ \li The file name (QString)
+ \li The pixmap size (QSize)
+ \li The \l{QIcon::Mode}{mode} (quint32)
+ \li The \l{QIcon::State}{state} (quint32)
+ \endlist
+ \endlist
+ \row \li QImage
+ \li \list
+ \li If the image is null a "null image" marker is saved;
+ otherwise the image is saved in PNG or BMP format (depending
+ on the stream version). If you want control of the format,
+ stream the image into a QBuffer (using QImageIO) and stream
+ that.
+ \endlist
+ \row \li QKeySequence
+ \li \list
+ \li A QList<int>, where each integer is a key in the key sequence
+ \endlist
+ \row \li QLinkedList<T>
+ \li \list
+ \li The number of items (quint32)
+ \li The items (T)
+ \endlist
+ \row \li QList<T>
+ \li \list
+ \li The number of items (quint32)
+ \li The items (T)
+ \endlist
+ \row \li QMap<Key, T>
+ \li \list
+ \li The number of items (quint32)
+ \li For all items, the key (Key) and value (T)
+ \endlist
+ \row \li QMargins
+ \li \list
+ \li left (int)
+ \li top (int)
+ \li right (int)
+ \li bottom (int)
+ \endlist
+ \row \li QMatrix
+ \li \list
+ \li m11 (double)
+ \li m12 (double)
+ \li m21 (double)
+ \li m22 (double)
+ \li dx (double)
+ \li dy (double)
+ \endlist
+ \row \li QMatrix4x4
+ \li \list
+ \li m11 (double)
+ \li m12 (double)
+ \li m13 (double)
+ \li m14 (double)
+ \li m21 (double)
+ \li m22 (double)
+ \li m23 (double)
+ \li m24 (double)
+ \li m31 (double)
+ \li m32 (double)
+ \li m33 (double)
+ \li m34 (double)
+ \li m41 (double)
+ \li m42 (double)
+ \li m43 (double)
+ \li m44 (double)
+ \endlist
+ \row \li QPair<T1, T2>
+ \li \list
+ \li first (T1)
+ \li second (T2)
+ \endlist
+ \row \li QPalette
+ \li The disabled, active, and inactive color groups, each of which consists
+ of the following:
+ \list
+ \li foreground (QBrush)
+ \li button (QBrush)
+ \li light (QBrush)
+ \li midlight (QBrush)
+ \li dark (QBrush)
+ \li mid (QBrush)
+ \li text (QBrush)
+ \li brightText (QBrush)
+ \li buttonText (QBrush)
+ \li base (QBrush)
+ \li background (QBrush)
+ \li shadow (QBrush)
+ \li highlight (QBrush)
+ \li highlightedText (QBrush)
+ \li link (QBrush)
+ \li linkVisited (QBrush)
+ \endlist
+ \row \li QPen
+ \li \list
+ \li The pen styles (quint8)
+ \li The pen width (quint16)
+ \li The pen color (QColor)
+ \endlist
+ \row \li QPicture
+ \li \list
+ \li The size of the picture data (quint32)
+ \li The raw bytes of picture data (char)
+ \endlist
+ \row \li QPixmap
+ \li \list
+ \li Save it as a PNG image.
+ \endlist
+ \row \li QPoint
+ \li \list
+ \li The x coordinate (qint32)
+ \li The y coordinate (qint32)
+ \endlist
+ \row \li QQuaternion
+ \li \list
+ \li The scalar component (double)
+ \li The x coordinate (double)
+ \li The y coordinate (double)
+ \li The z coordinate (double)
+ \endlist
+ \row \li QRect
+ \li \list
+ \li left (qint32)
+ \li top (qint32)
+ \li right (qint32)
+ \li bottom (qint32)
+ \endlist
+ \row \li QRegExp
+ \li \list
+ \li The regexp pattern (QString)
+ \li Case sensitivity (quint8)
+ \li Regular expression syntax (quint8)
+ \li Minimal matching (quint8)
+ \endlist
+ \row \li QRegularExpression
+ \li \list
+ \li The regular expression pattern (QString)
+ \li The pattern options (quint32)
+ \endlist
+ \row \li QRegion
+ \li \list
+ \li The size of the data, i.e. 8 + 16 * (number of rectangles) (quint32)
+ \li 10 (qint32)
+ \li The number of rectangles (quint32)
+ \li The rectangles in sequential order (QRect)
+ \endlist
+ \row \li QSize
+ \li \list
+ \li width (qint32)
+ \li height (qint32)
+ \endlist
+ \row \li QString
+ \li \list
+ \li If the string is null: 0xFFFFFFFF (quint32)
+ \li Otherwise: The string length in bytes (quint32) followed by the data in UTF-16
+ \endlist
+ \row \li QTime
+ \li \list
+ \li Milliseconds since midnight (quint32)
+ \endlist
+ \row \li QTransform
+ \li \list
+ \li m11 (double)
+ \li m12 (double)
+ \li m13 (double)
+ \li m21 (double)
+ \li m22 (double)
+ \li m23 (double)
+ \li m31 (double)
+ \li m32 (double)
+ \li m33 (double)
+ \endlist
+ \row \li QUrl
+ \li \list
+ \li Holds an URL (QString)
+ \endlist
+ \row \li QVariant
+ \li \list
+ \li The type of the data (quint32)
+ \li The null flag (qint8)
+ \li The data of the specified type
+ \endlist
+ \row \li QVector2D
+ \li \list
+ \li the x coordinate (double)
+ \li the y coordinate (double)
+ \endlist
+ \row \li QVector3D
+ \li \list
+ \li the x coordinate (double)
+ \li the y coordinate (double)
+ \li the z coordinate (double)
+ \endlist
+ \row \li QVector4D
+ \li \list
+ \li the x coordinate (double)
+ \li the y coordinate (double)
+ \li the z coordinate (double)
+ \li the w coordinate (double)
+ \endlist
+ \row \li QVector<T>
+ \li \list
+ \li The number of items (quint32)
+ \li The items (T)
+ \endlist
+ \endtable
+*/
diff --git a/src/corelib/doc/src/implicit-sharing.qdoc b/src/corelib/doc/src/implicit-sharing.qdoc
new file mode 100644
index 0000000000..6fc60de35e
--- /dev/null
+++ b/src/corelib/doc/src/implicit-sharing.qdoc
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/* TODO: Move some of the documentation from QSharedDataPointer into this
+ document. */
+
+/*!
+ \group shared
+ \title Implicitly Shared Classes
+*/
+
+/*!
+ \page implicit-sharing.html
+ \title Implicit Sharing
+ \ingroup qt-basic-concepts
+
+ \brief Reference counting for fast copying.
+
+ \keyword implicit data sharing
+ \keyword implicit sharing
+ \keyword implicitly shared
+ \keyword reference counting
+ \keyword shared implicitly
+ \keyword shared classes
+
+ Many C++ classes in Qt use implicit data sharing to maximize
+ resource usage and minimize copying. Implicitly shared classes are
+ both safe and efficient when passed as arguments, because only a
+ pointer to the data is passed around, and the data is copied only
+ if and when a function writes to it, i.e., \e {copy-on-write}.
+
+ \tableofcontents
+
+ \section1 Overview
+
+ A shared class consists of a pointer to a shared data block that
+ contains a reference count and the data.
+
+ When a shared object is created, it sets the reference count to 1. The
+ reference count is incremented whenever a new object references the
+ shared data, and decremented when the object dereferences the shared
+ data. The shared data is deleted when the reference count becomes
+ zero.
+
+ \keyword deep copy
+ \keyword shallow copy
+
+ When dealing with shared objects, there are two ways of copying an
+ object. We usually speak about \e deep and \e shallow copies. A deep
+ copy implies duplicating an object. A shallow copy is a reference
+ copy, i.e. just a pointer to a shared data block. Making a deep copy
+ can be expensive in terms of memory and CPU. Making a shallow copy is
+ very fast, because it only involves setting a pointer and incrementing
+ the reference count.
+
+ Object assignment (with operator=()) for implicitly shared objects is
+ implemented using shallow copies.
+
+ The benefit of sharing is that a program does not need to duplicate
+ data unnecessarily, which results in lower memory use and less copying
+ of data. Objects can easily be assigned, sent as function arguments,
+ and returned from functions.
+
+ Implicit sharing takes place behind the scenes; the programmer
+ does not need to worry about it. Even in multithreaded
+ applications, implicit sharing takes place, as explained in
+ \l{Thread-Support in Qt Modules#Threads and Implicitly Shared Classes}
+ {Threads and Implicitly Shared Classes}.
+
+ When implementing your own implicitly shared classes, use the
+ QSharedData and QSharedDataPointer classes.
+
+ \section1 Implicit Sharing in Detail
+
+ Implicit sharing automatically detaches the object from a shared
+ block if the object is about to change and the reference count is
+ greater than one. (This is often called \e {copy-on-write} or
+ \e {value semantics}.)
+
+ An implicitly shared class has total control of its internal data. In
+ any member functions that modify its data, it automatically detaches
+ before modifying the data.
+
+ The QPen class, which uses implicit sharing, detaches from the shared
+ data in all member functions that change the internal data.
+
+ Code fragment:
+ \snippet code/doc_src_groups.cpp 0
+
+
+ \section1 List of Classes
+
+ The classes listed below automatically detach from common data if
+ an object is about to be changed. The programmer will not even
+ notice that the objects are shared. Thus you should treat
+ separate instances of them as separate objects. They will always
+ behave as separate objects but with the added benefit of sharing
+ data whenever possible. For this reason, you can pass instances
+ of these classes as arguments to functions by value without
+ concern for the copying overhead.
+
+ Example:
+ \snippet code/doc_src_groups.cpp 1
+
+ In this example, \c p1 and \c p2 share data until QPainter::begin()
+ is called for \c p2, because painting a pixmap will modify it.
+
+ \warning Do not copy an implicitly shared container (QMap,
+ QVector, etc.) while you are iterating over it using an non-const
+ \l{STL-style iterator}.
+
+ \keyword implicitly shared classes
+ \annotatedlist shared
+*/
diff --git a/src/corelib/doc/src/json.qdoc b/src/corelib/doc/src/json.qdoc
new file mode 100644
index 0000000000..406135cc45
--- /dev/null
+++ b/src/corelib/doc/src/json.qdoc
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \group json
+ \title JSON Classes
+*/
+
+/*!
+ \page json.html
+ \title JSON Support in Qt
+ \ingroup qt-basic-concepts
+ \brief An overview over the JSON support in Qt.
+
+ \ingroup frameworks-technologies
+
+ \keyword JSON
+
+ Qt provides support for dealing with JSON data. JSON is a
+ format to encode object data derived from Javascript, but
+ now widely used as a data exchange format on the internet.
+
+ The JSON support in Qt provides an easy to use C++ API to parse,
+ modify and save JSON data. It also contains support for saving this
+ data in a binary format that is directly mmap'able and very fast to
+ access.
+
+ More details about the JSON data format can be found at \l{http://json.org}{json.org}
+ and in \l{http://tools.ietf.org/html/rfc4627}{RFC-4627}.
+
+ \tableofcontents
+
+ \section1 Overview
+
+ JSON is a format to store structured data. It has 6 basic data types:
+
+ \list
+ \li bool
+ \li double
+ \li string
+ \li array
+ \li object
+ \li null
+ \endlist
+
+ Any value can be any of the above type. A boolean value is represented by the
+ strings true or false in JSON. JSON doesn't explicitly specify the valid range
+ for numbers, but the support in Qt is limited to the valid range and precision of
+ doubles. A string can be any valid unicode string. An array is a list of values, and an
+ object is a dictionary of key/value pairs. All keys in an object are strings, and
+ an object cannot contain any duplicated keys.
+
+ The text representation, of JSON encloses arrays in square brackets ([ ... ]) and
+ objects in curly brackets ({ ... }). The different entries in arrays and objects
+ are separated by commas. The separator between keys and values in an object is a
+ colon (:).
+
+ A simple JSON document encoding a person, its age, address and phone numbers could
+ look like:
+
+ \code
+ {
+ "FirstName": "John",
+ "LastName": "Doe",
+ "Age": 43,
+ "Address": {
+ "Street": "Downing Street 10",
+ "City": "London",
+ "Country": "Great Britain"
+ },
+ "Phone numbers": [
+ "+44 1234567",
+ "+44 2345678"
+ ]
+ }
+ \endcode
+
+ The above example consists of an object with 5 key/value pairs. Two of the values are strings,
+ one is a number, one is another object and the last one an array.
+
+ A valid JSON document is either an array or an object, so a document always starts
+ with a square or curly bracket.
+
+ The JSON support in Qt consists of a set of 4 classes.
+
+
+ \section1 The JSON Classes
+
+ The JSON support in Qt consists of these classes:
+
+ \annotatedlist json
+
+ All JSON classes are value based, implicitly shared classes.
+*/
diff --git a/src/corelib/doc/src/objectmodel/metaobjects.qdoc b/src/corelib/doc/src/objectmodel/metaobjects.qdoc
new file mode 100644
index 0000000000..8e071be91e
--- /dev/null
+++ b/src/corelib/doc/src/objectmodel/metaobjects.qdoc
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \page metaobjects.html
+ \title The Meta-Object System
+ \brief An overview of Qt's meta-object system and introspection capabilities.
+
+ \ingroup qt-basic-concepts
+ \keyword meta-object
+ \target Meta-Object System
+
+ Qt's meta-object system provides the signals and slots mechanism for
+ inter-object communication, run-time type information, and the dynamic
+ property system.
+
+ The meta-object system is based on three things:
+
+ \list 1
+ \li The \l QObject class provides a base class for objects that can
+ take advantage of the meta-object system.
+ \li The Q_OBJECT macro inside the private section of the class
+ declaration is used to enable meta-object features, such as
+ dynamic properties, signals, and slots.
+ \li The \l{moc}{Meta-Object Compiler} (\c moc) supplies each
+ QObject subclass with the necessary code to implement
+ meta-object features.
+ \endlist
+
+ The \c moc tool reads a C++ source file. If it finds one or more
+ class declarations that contain the Q_OBJECT macro, it
+ produces another C++ source file which contains the meta-object
+ code for each of those classes. This generated source file is
+ either \c{#include}'d into the class's source file or, more
+ usually, compiled and linked with the class's implementation.
+
+ In addition to providing the \l{signals and slots} mechanism for
+ communication between objects (the main reason for introducing
+ the system), the meta-object code provides the following
+ additional features:
+
+ \list
+ \li QObject::metaObject() returns the associated
+ \l{QMetaObject}{meta-object} for the class.
+ \li QMetaObject::className() returns the class name as a
+ string at run-time, without requiring native run-time type information
+ (RTTI) support through the C++ compiler.
+ \li QObject::inherits() function returns whether an object is an
+ instance of a class that inherits a specified class within the
+ QObject inheritance tree.
+ \li QObject::tr() and QObject::trUtf8() translate strings for
+ \l{Internationalization with Qt}{internationalization}.
+ \li QObject::setProperty() and QObject::property()
+ dynamically set and get properties by name.
+ \li QMetaObject::newInstance() constructs a new instance of the class.
+ \endlist
+
+ \target qobjectcast
+ It is also possible to perform dynamic casts using qobject_cast()
+ on QObject classes. The qobject_cast() function behaves similarly
+ to the standard C++ \c dynamic_cast(), with the advantages
+ that it doesn't require RTTI support and it works across dynamic
+ library boundaries. It attempts to cast its argument to the pointer
+ type specified in angle-brackets, returning a non-zero pointer if the
+ object is of the correct type (determined at run-time), or 0
+ if the object's type is incompatible.
+
+ For example, let's assume \c MyWidget inherits from QWidget and
+ is declared with the Q_OBJECT macro:
+
+ \snippet qtcast/qtcast.cpp 0
+
+ The \c obj variable, of type \c{QObject *}, actually refers to a
+ \c MyWidget object, so we can cast it appropriately:
+
+ \snippet qtcast/qtcast.cpp 1
+
+ The cast from QObject to QWidget is successful, because the
+ object is actually a \c MyWidget, which is a subclass of QWidget.
+ Since we know that \c obj is a \c MyWidget, we can also cast it to
+ \c{MyWidget *}:
+
+ \snippet qtcast/qtcast.cpp 2
+
+ The cast to \c MyWidget is successful because qobject_cast()
+ makes no distinction between built-in Qt types and custom types.
+
+ \snippet qtcast/qtcast.cpp 3
+ \snippet qtcast/qtcast.cpp 4
+
+ The cast to QLabel, on the other hand, fails. The pointer is then
+ set to 0. This makes it possible to handle objects of different
+ types differently at run-time, based on the type:
+
+ \snippet qtcast/qtcast.cpp 5
+ \snippet qtcast/qtcast.cpp 6
+
+ While it is possible to use QObject as a base class without the
+ Q_OBJECT macro and without meta-object code, neither signals
+ and slots nor the other features described here will be available
+ if the Q_OBJECT macro is not used. From the meta-object
+ system's point of view, a QObject subclass without meta code is
+ equivalent to its closest ancestor with meta-object code. This
+ means for example, that QMetaObject::className() will not return
+ the actual name of your class, but the class name of this
+ ancestor.
+
+ Therefore, we strongly recommend that all subclasses of QObject
+ use the Q_OBJECT macro regardless of whether or not they
+ actually use signals, slots, and properties.
+
+ \sa QMetaObject, {Qt's Property System}, {Signals and Slots}
+*/
diff --git a/src/corelib/doc/src/objectmodel/object.qdoc b/src/corelib/doc/src/objectmodel/object.qdoc
new file mode 100644
index 0000000000..4e212b37dd
--- /dev/null
+++ b/src/corelib/doc/src/objectmodel/object.qdoc
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \page object.html
+ \title Object Model
+ \ingroup qt-basic-concepts
+ \brief A description of the powerful features made possible by Qt's dynamic object model.
+
+ The standard C++ object model provides very efficient runtime
+ support for the object paradigm. But its static nature is
+ inflexibile in certain problem domains. Graphical user interface
+ programming is a domain that requires both runtime efficiency and
+ a high level of flexibility. Qt provides this, by combining the
+ speed of C++ with the flexibility of the Qt Object Model.
+
+ Qt adds these features to C++:
+
+ \list
+ \li a very powerful mechanism for seamless object
+ communication called \l{signals and slots}
+ \li queryable and designable \l{Qt's Property System}{object
+ properties}
+ \li powerful \l{The Event System}{events and event filters}
+ \li contextual \l{i18n}{string translation for internationalization}
+ \li sophisticated interval driven \l timers that make it possible
+ to elegantly integrate many tasks in an event-driven GUI
+ \li hierarchical and queryable \l{Object Trees & Ownership}{object
+ trees} that organize object ownership in a natural way
+ \li guarded pointers (QPointer) that are automatically
+ set to 0 when the referenced object is destroyed, unlike normal C++
+ pointers which become dangling pointers when their objects are destroyed
+ \li a \l{metaobjects.html#qobjectcast}{dynamic cast} that works across
+ library boundaries.
+ \endlist
+
+ Many of these Qt features are implemented with standard C++
+ techniques, based on inheritance from QObject. Others, like the
+ object communication mechanism and the dynamic property system,
+ require the \l{Meta-Object System} provided
+ by Qt's own \l{moc}{Meta-Object Compiler (moc)}.
+
+ The meta-object system is a C++ extension that makes the language
+ better suited to true component GUI programming. Although
+ templates can be used to extend C++, the meta-object system
+ provides benefits using standard C++ that cannot be achieved with
+ templates; see \l{Why Doesn't Qt Use Templates for Signals and
+ Slots?}
+
+ \section1 Important Classes
+
+ These classes form the basis of the Qt Object Model.
+
+ \annotatedlist objectmodel
+
+ \target Identity vs Value
+ \section1 Qt Objects: Identity vs Value
+
+ Some of the added features listed above for the Qt Object Model,
+ require that we think of Qt Objects as identities, not values.
+ Values are copied or assigned; identities are cloned. Cloning
+ means to create a new identity, not an exact copy of the old
+ one. For example, twins have different identities. They may look
+ identical, but they have different names, different locations, and
+ may have completely different social networks.
+
+ Then cloning an identity is a more complex operation than copying
+ or assigning a value. We can see what this means in the Qt Object
+ Model.
+
+ \b{A Qt Object...}
+
+ \list
+
+ \li might have a unique \l{QObject::objectName()}. If we copy a Qt
+ Object, what name should we give the copy?
+
+ \li has a location in an \l{Object Trees & Ownership}
+ {object hierarchy}. If we copy a Qt Object, where should the copy
+ be located?
+
+ \li can be connected to other Qt Objects to emit signals to them or
+ to receive signals emitted by them. If we copy a Qt Object, how
+ should we transfer these connections to the copy?
+
+ \li can have \l{Qt's Property System} {new properties} added to it
+ at runtime that are not declared in the C++ class. If we copy a Qt
+ Object, should the copy include the properties that were added to
+ the original?
+
+ \endlist
+
+ For these reasons, Qt Objects should be treated as identities, not
+ as values. Identities are cloned, not copied or assigned, and
+ cloning an identity is a more complex operation than copying or
+ assigning a value. Therefore, QObject and all subclasses of
+ QObject (direct or indirect) have their \l{No copy constructor}
+ {copy constructor and assignment operator} disabled.
+
+ */
diff --git a/src/corelib/doc/src/objectmodel/objecttrees.qdoc b/src/corelib/doc/src/objectmodel/objecttrees.qdoc
new file mode 100644
index 0000000000..e03a93ab3d
--- /dev/null
+++ b/src/corelib/doc/src/objectmodel/objecttrees.qdoc
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \page objecttrees.html
+ \title Object Trees & Ownership
+ \ingroup qt-basic-concepts
+ \brief Information about the parent-child pattern used to describe
+ object ownership in Qt.
+
+ \section1 Overview
+
+ \link QObject QObjects\endlink organize themselves in object trees.
+ When you create a QObject with another object as parent, it's added to
+ the parent's \link QObject::children() children() \endlink list, and
+ is deleted when the parent is. It turns out that this approach fits
+ the needs of GUI objects very well. For example, a \l QShortcut
+ (keyboard shortcut) is a child of the relevant window, so when the
+ user closes that window, the shorcut is deleted too.
+
+ \l QWidget, the base class of everything that appears on the screen,
+ extends the parent-child relationship. A child normally also becomes a
+ child widget, i.e. it is displayed in its parent's coordinate system
+ and is graphically clipped by its parent's boundaries. For example,
+ when the application deletes a message box after it has been
+ closed, the message box's buttons and label are also deleted, just as
+ we'd want, because the buttons and label are children of the message
+ box.
+
+ You can also delete child objects yourself, and they will remove
+ themselves from their parents. For example, when the user removes a
+ toolbar it may lead to the application deleting one of its \l QToolBar
+ objects, in which case the tool bar's \l QMainWindow parent would
+ detect the change and reconfigure its screen space accordingly.
+
+ The debugging functions \l QObject::dumpObjectTree() and \l
+ QObject::dumpObjectInfo() are often useful when an application looks or
+ acts strangely.
+
+ \target note on the order of construction/destruction of QObjects
+ \section1 Construction/Destruction Order of QObjects
+
+ When \l {QObject} {QObjects} are created on the heap (i.e., created
+ with \e new), a tree can be constructed from them in any order, and
+ later, the objects in the tree can be destroyed in any order. When any
+ QObject in the tree is deleted, if the object has a parent, the
+ destructor automatically removes the object from its parent. If the
+ object has children, the destructor automatically deletes each
+ child. No QObject is deleted twice, regardless of the order of
+ destruction.
+
+ When \l {QObject} {QObjects} are created on the stack, the same
+ behavior applies. Normally, the order of destruction still doesn't
+ present a problem. Consider the following snippet:
+
+ \snippet code/doc_src_objecttrees.cpp 0
+
+ The parent, \c window, and the child, \c quit, are both \l {QObject}
+ {QObjects} because QPushButton inherits QWidget, and QWidget inherits
+ QObject. This code is correct: the destructor of \c quit is \e not
+ called twice because the C++ language standard \e {(ISO/IEC 14882:2003)}
+ specifies that destructors of local objects are called in the reverse
+ order of their constructors. Therefore, the destructor of
+ the child, \c quit, is called first, and it removes itself from its
+ parent, \c window, before the destructor of \c window is called.
+
+ But now consider what happens if we swap the order of construction, as
+ shown in this second snippet:
+
+ \snippet code/doc_src_objecttrees.cpp 1
+
+ In this case, the order of destruction causes a problem. The parent's
+ destructor is called first because it was created last. It then calls
+ the destructor of its child, \c quit, which is incorrect because \c
+ quit is a local variable. When \c quit subsequently goes out of scope,
+ its destructor is called again, this time correctly, but the damage has
+ already been done.
+*/
diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc
new file mode 100644
index 0000000000..9d248f00de
--- /dev/null
+++ b/src/corelib/doc/src/objectmodel/properties.qdoc
@@ -0,0 +1,273 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \page properties.html
+ \title The Property System
+ \brief An overview of Qt's property system.
+
+ \ingroup qt-basic-concepts
+ \target Qt's Property System
+
+ Qt provides a sophisticated property system similar to the ones
+ supplied by some compiler vendors. However, as a compiler- and
+ platform-independent library, Qt does not rely on non-standard
+ compiler features like \c __property or \c [property]. The Qt
+ solution works with \e any standard C++ compiler on every platform
+ Qt supports. It is based on the \l {Meta-Object System} that also
+ provides inter-object communication via \l{signals and slots}.
+
+ \section1 Requirements for Declaring Properties
+
+ To declare a property, use the \l {Q_PROPERTY()} {Q_PROPERTY()}
+ macro in a class that inherits QObject.
+
+ \snippet code/doc_src_properties.cpp 0
+
+ Here are some typical examples of property declarations taken from
+ class QWidget.
+
+ \snippet code/doc_src_properties.cpp 1
+
+ A property behaves like a class data member, but it has additional
+ features accessible through the \l {Meta-Object System}.
+
+ \list
+
+ \li A \c READ accessor function is required. It is for reading the
+ property value. Ideally, a const function is used for this purpose,
+ and it must return either the property's type or a pointer or
+ reference to that type. e.g., QWidget::focus is a read-only property
+ with \c READ function, QWidget::hasFocus().
+
+ \li A \c WRITE accessor function is optional. It is for setting the
+ property value. It must return void and must take exactly one
+ argument, either of the property's type or a pointer or reference
+ to that type. e.g., QWidget::enabled has the \c WRITE function
+ QWidget::setEnabled(). Read-only properties do not need \c WRITE
+ functions. e.g., QWidget::focus has no \c WRITE function.
+
+ \li A \c RESET function is optional. It is for setting the property
+ back to its context specific default value. e.g., QWidget::cursor
+ has the typical \c READ and \c WRITE functions, QWidget::cursor()
+ and QWidget::setCursor(), and it also has a \c RESET function,
+ QWidget::unsetCursor(), since no call to QWidget::setCursor() can
+ mean \e {reset to the context specific cursor}. The \c RESET
+ function must return void and take no parameters.
+
+ \li A \c NOTIFY signal is optional. If defined, it should specify one
+ existing signal in that class that is emitted whenever the value
+ of the property changes.
+
+ \li A \c REVISION number is optional. If included, it defines the
+ the property and its notifier signal to be used in a particular
+ revision of the API that is exposed to QML.
+
+ \li The \c DESIGNABLE attribute indicates whether the property
+ should be visible in the property editor of GUI design tool (e.g.,
+ \l {Qt Designer}). Most properties are \c DESIGNABLE (default
+ true). Instead of true or false, you can specify a boolean
+ member function.
+
+ \li The \c SCRIPTABLE attribute indicates whether this property
+ should be accessible by a scripting engine (default true).
+ Instead of true or false, you can specify a boolean member
+ function.
+
+ \li The \c STORED attribute indicates whether the property should
+ be thought of as existing on its own or as depending on other
+ values. It also indicates whether the property value must be saved
+ when storing the object's state. Most properties are \c STORED
+ (default true), but e.g., QWidget::minimumWidth() has \c STORED
+ false, because its value is just taken from the width component
+ of property QWidget::minimumSize(), which is a QSize.
+
+ \li The \c USER attribute indicates whether the property is
+ designated as the user-facing or user-editable property for the
+ class. Normally, there is only one \c USER property per class
+ (default false). e.g., QAbstractButton::checked is the user
+ editable property for (checkable) buttons. Note that QItemDelegate
+ gets and sets a widget's \c USER property.
+
+ \li The presence of the \c CONSTANT attibute indicates that the property
+ value is constant. For a given object instance, the READ method of a
+ constant property must return the same value every time it is called. This
+ constant value may be different for different instances of the object. A
+ constant property cannot have a WRITE method or a NOTIFY signal.
+
+ \li The presence of the \c FINAL attribute indicates that the property
+ will not be overridden by a derived class. This can be used for performance
+ optimizations in some cases, but is not enforced by moc. Care must be taken
+ never to override a \c FINAL property.
+
+ \endlist
+
+ The \c READ, \c WRITE, and \c RESET functions can be inherited.
+ They can also be virtual. When they are inherited in classes where
+ multiple inheritance is used, they must come from the first
+ inherited class.
+
+ The property type can be any type supported by QVariant, or it can
+ be a user-defined type. In this example, class QDate is considered
+ to be a user-defined type.
+
+ \snippet code/doc_src_properties.cpp 2
+
+ Because QDate is user-defined, you must include the \c{<QDate>}
+ header file with the property declaration.
+
+ For QMap, QList, and QValueList properties, the property value is
+ a QVariant whose value is the entire list or map. Note that the
+ Q_PROPERTY string cannot contain commas, because commas separate
+ macro arguments. Therefore, you must use \c QMap as the property
+ type instead of \c QMap<QString,QVariant>. For consistency, also
+ use \c QList and \c QValueList instead of \c QList<QVariant> and
+ \c QValueList<QVariant>.
+
+ \section1 Reading and Writing Properties with the Meta-Object System
+
+ A property can be read and written using the generic functions
+ QObject::property() and QObject::setProperty(), without knowing
+ anything about the owning class except the property's name. In
+ the code snippet below, the call to QAbstractButton::setDown() and
+ the call to QObject::setProperty() both set property "down".
+
+ \snippet code/doc_src_properties.cpp 3
+
+ Accessing a property through its \c WRITE accessor is the better
+ of the two, because it is faster and gives better diagnostics at
+ compile time, but setting the property this way requires that you
+ know about the class at compile time. Accessing properties by name
+ lets you access classes you don't know about at compile time. You
+ can \e discover a class's properties at run time by querying its
+ QObject, QMetaObject, and \l {QMetaProperty} {QMetaProperties}.
+
+ \snippet code/doc_src_properties.cpp 4
+
+ In the above snippet, QMetaObject::property() is used to get \l
+ {QMetaProperty} {metadata} about each property defined in some
+ unknown class. The property name is fetched from the metadata and
+ passed to QObject::property() to get the \l {QVariant} {value} of
+ the property in the current \l {QObject}{object}.
+
+ \section1 A Simple Example
+
+ Suppose we have a class MyClass, which is derived from QObject and
+ which uses the Q_OBJECT macro in its private section. We want to
+ declare a property in MyClass to keep track of a priorty
+ value. The name of the property will be \e priority, and its type
+ will be an enumeration type named \e Priority, which is defined in
+ MyClass.
+
+ We declare the property with the Q_PROPERTY() macro in the private
+ section of the class. The required \c READ function is named \c
+ priority, and we include a \c WRITE function named \c setPriority.
+ The enumeration type must be registered with the \l {Meta-Object
+ System} using the Q_ENUMS() macro. Registering an enumeration type
+ makes the enumerator names available for use in calls to
+ QObject::setProperty(). We must also provide our own declarations
+ for the \c READ and \c WRITE functions. The declaration of MyClass
+ then might look like this:
+
+ \snippet code/doc_src_properties.cpp 5
+
+ The \c READ function is const and returns the property type. The
+ \c WRITE function returns void and has exactly one parameter of
+ the property type. The meta-object compiler enforces these
+ requirements.
+
+ Given a pointer to an instance of MyClass or a pointer to a
+ QObject that is an instance of MyClass, we have two ways to set
+ its priority property:
+
+ \snippet code/doc_src_properties.cpp 6
+
+ In the example, the enumeration type that is the property type is
+ declared in MyClass and registered with the \l{Meta-Object System}
+ using the Q_ENUMS() macro. This makes the enumeration values
+ available as strings for use as in the call to setProperty(). Had
+ the enumeration type been declared in another class, its fully
+ qualified name (i.e., OtherClass::Priority) would be required, and
+ that other class would also have to inherit QObject and register
+ the enumeration type there using the Q_ENUMS() macro.
+
+ A similar macro, Q_FLAGS(), is also available. Like Q_ENUMS(), it
+ registers an enumeration type, but it marks the type as being a
+ set of \e flags, i.e. values that can be OR'd together. An I/O
+ class might have enumeration values \c Read and \c Write and then
+ QObject::setProperty() could accept \c{Read | Write}. Q_FLAGS()
+ should be used to register this enumeration type.
+
+ \section1 Dynamic Properties
+
+ QObject::setProperty() can also be used to add \e new properties
+ to an instance of a class at runtime. When it is called with a
+ name and a value, if a property with the given name exists in the
+ QObject, and if the given value is compatible with the property's
+ type, the value is stored in the property, and true is returned.
+ If the value is \e not compatible with the property's type, the
+ property is \e not changed, and false is returned. But if the
+ property with the given name doesn't exist in the QObject (i.e.,
+ if it wasn't declared with Q_PROPERTY(), a new property with the
+ given name and value is automatically added to the QObject, but
+ false is still returned. This means that a return of false can't
+ be used to determine whether a particular property was actually
+ set, unless you know in advance that the property already exists
+ in the QObject.
+
+ Note that \e dynamic properties are added on a per instance basis,
+ i.e., they are added to QObject, not QMetaObject. A property can
+ be removed from an instance by passing the property name and an
+ invalid QVariant value to QObject::setProperty(). The default
+ constructor for QVariant constructs an invalid QVariant.
+
+ Dynamic properties can be queried with QObject::property(), just
+ like properties declared at compile time with Q_PROPERTY().
+
+ \sa {Meta-Object System}, {Signals and Slots}
+
+ \section1 Properties and Custom Types
+
+ Custom types used by properties need to be registered using the
+ Q_DECLARE_METATYPE() macro so that their values can be stored in
+ QVariant objects. This makes them suitable for use with both
+ static properties declared using the Q_PROPERTY() macro in class
+ definitions and dynamic properties created at run-time.
+
+ \sa Q_DECLARE_METATYPE(), QMetaType, QVariant
+
+ \section1 Adding Additional Information to a Class
+
+ Connected to the property system is an additional macro,
+ Q_CLASSINFO(), that can be used to attach additional
+ \e{name}--\e{value} pairs to a class's meta-object, for example:
+
+ \snippet code/doc_src_properties.cpp 7
+
+ Like other meta-data, class information is accessible at run-time
+ through the meta-object; see QMetaObject::classInfo() for details.
+*/
diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
new file mode 100644
index 0000000000..0f12c9c8f2
--- /dev/null
+++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
@@ -0,0 +1,468 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \page signalsandslots.html
+ \title Signals & Slots
+ \ingroup qt-basic-concepts
+ \brief An overview of Qt's signals and slots inter-object
+ communication mechanism.
+
+ Signals and slots are used for communication between objects. The
+ signals and slots mechanism is a central feature of Qt and
+ probably the part that differs most from the features provided by
+ other frameworks.
+
+ \tableofcontents
+
+ \section1 Introduction
+
+ In GUI programming, when we change one widget, we often want
+ another widget to be notified. More generally, we want objects of
+ any kind to be able to communicate with one another. For example,
+ if a user clicks a \uicontrol{Close} button, we probably want the
+ window's \l{QWidget::close()}{close()} function to be called.
+
+ Older toolkits achieve this kind of communication using
+ callbacks. A callback is a pointer to a function, so if you want
+ a processing function to notify you about some event you pass a
+ pointer to another function (the callback) to the processing
+ function. The processing function then calls the callback when
+ appropriate. Callbacks have two fundamental flaws: Firstly, they
+ are not type-safe. We can never be certain that the processing
+ function will call the callback with the correct arguments.
+ Secondly, the callback is strongly coupled to the processing
+ function since the processing function must know which callback
+ to call.
+
+ \section1 Signals and Slots
+
+ In Qt, we have an alternative to the callback technique: We use
+ signals and slots. A signal is emitted when a particular event
+ occurs. Qt's widgets have many predefined signals, but we can
+ always subclass widgets to add our own signals to them. A slot
+ is a function that is called in response to a particular signal.
+ Qt's widgets have many pre-defined slots, but it is common
+ practice to subclass widgets and add your own slots so that you
+ can handle the signals that you are interested in.
+
+ \image abstract-connections.png
+ \omit
+ \caption An abstract view of some signals and slots connections
+ \endomit
+
+ The signals and slots mechanism is type safe: The signature of a
+ signal must match the signature of the receiving slot. (In fact a
+ slot may have a shorter signature than the signal it receives
+ because it can ignore extra arguments.) Since the signatures are
+ compatible, the compiler can help us detect type mismatches.
+ Signals and slots are loosely coupled: A class which emits a
+ signal neither knows nor cares which slots receive the signal.
+ Qt's signals and slots mechanism ensures that if you connect a
+ signal to a slot, the slot will be called with the signal's
+ parameters at the right time. Signals and slots can take any
+ number of arguments of any type. They are completely type safe.
+
+ All classes that inherit from QObject or one of its subclasses
+ (e.g., QWidget) can contain signals and slots. Signals are emitted by
+ objects when they change their state in a way that may be interesting
+ to other objects. This is all the object does to communicate. It
+ does not know or care whether anything is receiving the signals it
+ emits. This is true information encapsulation, and ensures that the
+ object can be used as a software component.
+
+ Slots can be used for receiving signals, but they are also normal
+ member functions. Just as an object does not know if anything receives
+ its signals, a slot does not know if it has any signals connected to
+ it. This ensures that truly independent components can be created with
+ Qt.
+
+ You can connect as many signals as you want to a single slot, and a
+ signal can be connected to as many slots as you need. It is even
+ possible to connect a signal directly to another signal. (This will
+ emit the second signal immediately whenever the first is emitted.)
+
+ Together, signals and slots make up a powerful component programming
+ mechanism.
+
+ \section1 A Small Example
+
+ A minimal C++ class declaration might read:
+
+ \snippet signalsandslots/signalsandslots.h 0
+
+ A small QObject-based class might read:
+
+ \snippet signalsandslots/signalsandslots.h 1
+ \codeline
+ \snippet signalsandslots/signalsandslots.h 2
+ \snippet signalsandslots/signalsandslots.h 3
+
+ The QObject-based version has the same internal state, and provides
+ public methods to access the state, but in addition it has support
+ for component programming using signals and slots. This class can
+ tell the outside world that its state has changed by emitting a
+ signal, \c{valueChanged()}, and it has a slot which other objects
+ can send signals to.
+
+ All classes that contain signals or slots must mention
+ Q_OBJECT at the top of their declaration. They must also derive
+ (directly or indirectly) from QObject.
+
+ Slots are implemented by the application programmer.
+ Here is a possible implementation of the \c{Counter::setValue()}
+ slot:
+
+ \snippet signalsandslots/signalsandslots.cpp 0
+
+ The \c{emit} line emits the signal \c valueChanged() from the
+ object, with the new value as argument.
+
+ In the following code snippet, we create two \c Counter objects
+ and connect the first object's \c valueChanged() signal to the
+ second object's \c setValue() slot using QObject::connect():
+
+ \snippet signalsandslots/signalsandslots.cpp 1
+ \snippet signalsandslots/signalsandslots.cpp 2
+ \codeline
+ \snippet signalsandslots/signalsandslots.cpp 3
+ \snippet signalsandslots/signalsandslots.cpp 4
+
+ Calling \c{a.setValue(12)} makes \c{a} emit a
+ \c{valueChanged(12)} signal, which \c{b} will receive in its
+ \c{setValue()} slot, i.e. \c{b.setValue(12)} is called. Then
+ \c{b} emits the same \c{valueChanged()} signal, but since no slot
+ has been connected to \c{b}'s \c{valueChanged()} signal, the
+ signal is ignored.
+
+ Note that the \c{setValue()} function sets the value and emits
+ the signal only if \c{value != m_value}. This prevents infinite
+ looping in the case of cyclic connections (e.g., if
+ \c{b.valueChanged()} were connected to \c{a.setValue()}).
+
+ By default, for every connection you make, a signal is emitted;
+ two signals are emitted for duplicate connections. You can break
+ all of these connections with a single disconnect() call.
+ If you pass the Qt::UniqueConnection \a type, the connection will only
+ be made if it is not a duplicate. If there is already a duplicate
+ (exact same signal to the exact same slot on the same objects),
+ the connection will fail and connect will return false
+
+ This example illustrates that objects can work together without needing to
+ know any information about each other. To enable this, the objects only
+ need to be connected together, and this can be achieved with some simple
+ QObject::connect() function calls, or with \c{uic}'s
+ \l{Using a Designer UI File in Your Application#Automatic Connections}
+ {automatic connections} feature.
+
+ \section1 Building the Example
+
+ The C++ preprocessor changes or removes the \c{signals},
+ \c{slots}, and \c{emit} keywords so that the compiler is
+ presented with standard C++.
+
+ By running the \l moc on class definitions that contain signals
+ or slots, a C++ source file is produced which should be compiled
+ and linked with the other object files for the application. If
+ you use \l qmake, the makefile rules to automatically invoke \c
+ moc will be added to your project's makefile.
+
+ \section1 Signals
+
+ Signals are emitted by an object when its internal state has changed
+ in some way that might be interesting to the object's client or owner.
+ Signals are public access functions and can be emitted from anywhere,
+ but we recommend to only emit them from the class that defines the
+ signal and its subclasses.
+
+ When a signal is emitted, the slots connected to it are usually
+ executed immediately, just like a normal function call. When this
+ happens, the signals and slots mechanism is totally independent of
+ any GUI event loop. Execution of the code following the \c emit
+ statement will occur once all slots have returned. The situation is
+ slightly different when using \l{Qt::ConnectionType}{queued
+ connections}; in such a case, the code following the \c emit keyword
+ will continue immediately, and the slots will be executed later.
+
+ If several slots are connected to one signal, the slots will be
+ executed one after the other, in the order they have been connected,
+ when the signal is emitted.
+
+ Signals are automatically generated by the \l moc and must not be
+ implemented in the \c .cpp file. They can never have return types
+ (i.e. use \c void).
+
+ A note about arguments: Our experience shows that signals and slots
+ are more reusable if they do not use special types. If
+ QScrollBar::valueChanged() were to use a special type such as the
+ hypothetical QScrollBar::Range, it could only be connected to
+ slots designed specifically for QScrollBar. Connecting different
+ input widgets together would be impossible.
+
+ \section1 Slots
+
+ A slot is called when a signal connected to it is emitted. Slots are
+ normal C++ functions and can be called normally; their only special
+ feature is that signals can be connected to them.
+
+ Since slots are normal member functions, they follow the normal C++
+ rules when called directly. However, as slots, they can be invoked
+ by any component, regardless of its access level, via a signal-slot
+ connection. This means that a signal emitted from an instance of an
+ arbitrary class can cause a private slot to be invoked in an instance
+ of an unrelated class.
+
+ You can also define slots to be virtual, which we have found quite
+ useful in practice.
+
+ Compared to callbacks, signals and slots are slightly slower
+ because of the increased flexibility they provide, although the
+ difference for real applications is insignificant. In general,
+ emitting a signal that is connected to some slots, is
+ approximately ten times slower than calling the receivers
+ directly, with non-virtual function calls. This is the overhead
+ required to locate the connection object, to safely iterate over
+ all connections (i.e. checking that subsequent receivers have not
+ been destroyed during the emission), and to marshall any
+ parameters in a generic fashion. While ten non-virtual function
+ calls may sound like a lot, it's much less overhead than any \c
+ new or \c delete operation, for example. As soon as you perform a
+ string, vector or list operation that behind the scene requires
+ \c new or \c delete, the signals and slots overhead is only
+ responsible for a very small proportion of the complete function
+ call costs. The same is true whenever you do a system call in a slot;
+ or indirectly call more than ten functions.
+ The simplicity and flexibility of the signals and slots mechanism is
+ well worth the overhead, which your users won't even notice.
+
+ Note that other libraries that define variables called \c signals
+ or \c slots may cause compiler warnings and errors when compiled
+ alongside a Qt-based application. To solve this problem, \c
+ #undef the offending preprocessor symbol.
+
+ \section1 Meta-Object Information
+
+ The meta-object compiler (\l moc) parses the class declaration in
+ a C++ file and generates C++ code that initializes the
+ meta-object. The meta-object contains the names of all the signal
+ and slot members, as well as pointers to these functions.
+
+ The meta-object contains additional information such as the
+ object's \link QObject::className() class name\endlink. You can
+ also check if an object \link QObject::inherits()
+ inherits\endlink a specific class, for example:
+
+ \snippet signalsandslots/signalsandslots.cpp 5
+ \snippet signalsandslots/signalsandslots.cpp 6
+
+ The meta-object information is also used by qobject_cast<T>(), which
+ is similar to QObject::inherits() but is less error-prone:
+
+ \snippet signalsandslots/signalsandslots.cpp 7
+
+ See \l{Meta-Object System} for more information.
+
+ \section1 A Real Example
+
+ Here is a simple commented example of a widget.
+
+ \snippet signalsandslots/lcdnumber.h 0
+ \snippet signalsandslots/lcdnumber.h 1
+ \codeline
+ \snippet signalsandslots/lcdnumber.h 2
+ \codeline
+ \snippet signalsandslots/lcdnumber.h 3
+ \snippet signalsandslots/lcdnumber.h 4
+ \snippet signalsandslots/lcdnumber.h 5
+
+ \c LcdNumber inherits QObject, which has most of the signal-slot
+ knowledge, via QFrame and QWidget. It is somewhat similar to the
+ built-in QLCDNumber widget.
+
+ The Q_OBJECT macro is expanded by the preprocessor to declare
+ several member functions that are implemented by the \c{moc}; if
+ you get compiler errors along the lines of "undefined reference
+ to vtable for \c{LcdNumber}", you have probably forgotten to
+ \l{moc}{run the moc} or to include the moc output in the link
+ command.
+
+ \snippet signalsandslots/lcdnumber.h 6
+ \snippet signalsandslots/lcdnumber.h 7
+
+ It's not obviously relevant to the moc, but if you inherit
+ QWidget you almost certainly want to have the \c parent argument
+ in your constructor and pass it to the base class's constructor.
+
+ Some destructors and member functions are omitted here; the \c
+ moc ignores member functions.
+
+ \snippet signalsandslots/lcdnumber.h 8
+ \snippet signalsandslots/lcdnumber.h 9
+
+ \c LcdNumber emits a signal when it is asked to show an impossible
+ value.
+
+ If you don't care about overflow, or you know that overflow
+ cannot occur, you can ignore the \c overflow() signal, i.e. don't
+ connect it to any slot.
+
+ If on the other hand you want to call two different error
+ functions when the number overflows, simply connect the signal to
+ two different slots. Qt will call both (in the order they were connected).
+
+ \snippet signalsandslots/lcdnumber.h 10
+ \snippet signalsandslots/lcdnumber.h 11
+ \snippet signalsandslots/lcdnumber.h 12
+ \codeline
+ \snippet signalsandslots/lcdnumber.h 13
+
+ A slot is a receiving function used to get information about
+ state changes in other widgets. \c LcdNumber uses it, as the code
+ above indicates, to set the displayed number. Since \c{display()}
+ is part of the class's interface with the rest of the program,
+ the slot is public.
+
+ Several of the example programs connect the
+ \l{QScrollBar::valueChanged()}{valueChanged()} signal of a
+ QScrollBar to the \c display() slot, so the LCD number
+ continuously shows the value of the scroll bar.
+
+ Note that \c display() is overloaded; Qt will select the
+ appropriate version when you connect a signal to the slot. With
+ callbacks, you'd have to find five different names and keep track
+ of the types yourself.
+
+ Some irrelevant member functions have been omitted from this
+ example.
+
+ \section1 Signals And Slots With Default Arguments
+
+ The signatures of signals and slots may contain arguments, and the
+ arguments can have default values. Consider QObject::destroyed():
+
+ \code
+ void destroyed(QObject* = 0);
+ \endcode
+
+ When a QObject is deleted, it emits this QObject::destroyed()
+ signal. We want to catch this signal, wherever we might have a
+ dangling reference to the deleted QObject, so we can clean it up.
+ A suitable slot signature might be:
+
+ \code
+ void objectDestroyed(QObject* obj = 0);
+ \endcode
+
+ To connect the signal to the slot, we use QObject::connect().
+ There are several ways to connect signal and slots. The first is to use
+ function pointers:
+ \code
+ connect(sender, &QObject::destroyed, this, &MyObject::objectDestroyed);
+ \endcode
+
+ There are several advantages to using connect() with function pointers.
+ First, it allows the compiler to check that the signal's arguments are
+ compatible with the slot's arguments. Arguments can also be implicitly
+ converted by the compiler, if needed.
+
+ You can also connect to functors or C++11 lamdas:
+
+ \code
+ connect(sender, &QObject::destroyed, [=](){ this->m_objects.remove(sender); });
+ \endcode
+
+ Note that if your compiler does not support C++11 variadic templates,
+ this syntax only works if the signal and slot have 6 arguments or less.
+
+ The other way to connect a signal to a slot is to use QObject::connect()
+ and the \c{SIGNAL} and \c{SLOT} macros.
+ The rule about whether to
+ include arguments or not in the \c{SIGNAL()} and \c{SLOT()}
+ macros, if the arguments have default values, is that the
+ signature passed to the \c{SIGNAL()} macro must \e not have fewer
+ arguments than the signature passed to the \c{SLOT()} macro.
+
+ All of these would work:
+ \code
+ connect(sender, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(Qbject*)));
+ connect(sender, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed()));
+ connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed()));
+ \endcode
+ But this one won't work:
+ \code
+ connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed(QObject*)));
+ \endcode
+
+ ...because the slot will be expecting a QObject that the signal
+ will not send. This connection will report a runtime error.
+
+ Note that signal and slot arguments are not checked by the compiler when
+ using this QObject::connect() overload.
+
+ \section1 Advanced Signals and Slots Usage
+
+ For cases where you may require information on the sender of the
+ signal, Qt provides the QObject::sender() function, which returns
+ a pointer to the object that sent the signal.
+
+ The QSignalMapper class is provided for situations where many
+ signals are connected to the same slot and the slot needs to
+ handle each signal differently.
+
+ Suppose you have three push buttons that determine which file you
+ will open: "Tax File", "Accounts File", or "Report File".
+
+ In order to open the correct file, you use QSignalMapper::setMapping() to
+ map all the clicked() signals to a QSignalMapper object. Then you connect
+ the file's QPushButton::clicked() signal to the QSignalMapper::map() slot.
+
+ \snippet signalmapper/filereader.cpp 0
+
+ Then, you connect the \l{QSignalMapper::}{mapped()} signal to
+ \c{readFile()} where a different file will be opened, depending on
+ which push button is pressed.
+
+ \snippet signalmapper/filereader.cpp 1
+
+ \sa {Meta-Object System}, {Qt's Property System}
+
+ \target 3rd Party Signals and Slots
+ \section2 Using Qt with 3rd Party Signals and Slots
+
+ It is possible to use Qt with a 3rd party signal/slot mechanism.
+ You can even use both mechanisms in the same project. Just add the
+ following line to your qmake project (.pro) file.
+
+ \snippet code/doc_src_containers.cpp 22
+
+ It tells Qt not to define the moc keywords \c{signals}, \c{slots},
+ and \c{emit}, because these names will be used by a 3rd party
+ library, e.g. Boost. Then to continue using Qt signals and slots
+ with the \c{no_keywords} flag, simply replace all uses of the Qt
+ moc keywords in your sources with the corresponding Qt macros
+ Q_SIGNALS (or Q_SIGNAL), Q_SLOTS (or Q_SLOT), and Q_EMIT.
+*/
diff --git a/src/corelib/doc/src/qtcore.qdoc b/src/corelib/doc/src/qtcore.qdoc
new file mode 100644
index 0000000000..66c8704322
--- /dev/null
+++ b/src/corelib/doc/src/qtcore.qdoc
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \module QtCore
+ \title QtCore Module
+ \ingroup modules
+
+ \keyword QtCore
+
+ \brief The QtCore module contains core non-GUI functionality.
+
+ All other Qt modules rely on this module. To include the
+ definitions of the module's classes, use the following directive:
+
+ \snippet code/doc_src_qtcore.cpp 0
+*/
+
diff --git a/src/corelib/doc/src/threads-basics.qdoc b/src/corelib/doc/src/threads-basics.qdoc
new file mode 100644
index 0000000000..0f455c01e5
--- /dev/null
+++ b/src/corelib/doc/src/threads-basics.qdoc
@@ -0,0 +1,572 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \page thread-basics.html
+ \ingroup tutorials
+ \startpage {index.html}{Qt Reference Documentation}
+
+ \title Threading Basics
+ \brief An introduction to threads
+
+ \section1 What Are Threads?
+
+ Threads are about doing things in parallel, just like processes. So how do
+ threads differ from processes? While you are making calculations on a
+ spreadsheet, there may also be a media player running on the same desktop
+ playing your favorite song. Here is an example of two processes working in
+ parallel: one running the spreadsheet program; one running a media player.
+ Multitasking is a well known term for this. A closer look at the media
+ player reveals that there are again things going on in parallel within one
+ single process. While the media player is sending music to the audio driver,
+ the user interface with all its bells and whistles is being constantly
+ updated. This is what threads are for -- concurrency within one single
+ process.
+
+ So how is concurrency implemented? Parallel work on single core CPUs is an
+ illusion which is somewhat similar to the illusion of moving images in
+ cinema.
+ For processes, the illusion is produced by interrupting the processor's
+ work on one process after a very short time. Then the processor moves on to
+ the next process. In order to switch between processes, the current program
+ counter is saved and the next processor's program counter is loaded. This
+ is not sufficient because the same needs to be done with registers and
+ certain architecture and OS specific data.
+
+ Just as one CPU can power two or more processes, it is also possible to let
+ the CPU run on two different code segments of one single process. When a
+ process starts, it always executes one code segment and therefore the
+ process is said to have one thread. However, the program may decide to
+ start a second thread. Then, two different code sequences are processed
+ simultaneously inside one process. Concurrency is achieved on single core
+ CPUs by repeatedly saving program counters and registers then loading the
+ next thread's program counters and registers. No cooperation from the
+ program is required to cycle between the active threads. A thread may be in
+ any state when the switch to the next thread occurs.
+
+ The current trend in CPU design is to have several cores. A typical
+ single-threaded application can make use of only one core. However, a
+ program with multiple threads can be assigned to multiple cores, making
+ things happen in a truly concurrent way. As a result, distributing work
+ to more than one thread can make a program run much faster on multicore
+ CPUs because additional cores can be used.
+
+ \section2 GUI Thread and Worker Thread
+
+ As mentioned, each program has one thread when it is started. This thread
+ is called the "main thread" (also known as the "GUI thread" in Qt
+ applications). The Qt GUI must run in this thread. All widgets and several
+ related classes, for example QPixmap, don't work in secondary threads.
+ A secondary thread is commonly referred to as a "worker thread" because it
+ is used to offload processing work from the main thread.
+
+ \section2 Simultaneous Access to Data
+
+ Each thread has its own stack, which means each thread has its own call
+ history and local variables. Unlike processes, threads share the same
+ address space. The following diagram shows how the building blocks of
+ threads are located in memory. Program counter and registers of inactive
+ threads are typically kept in kernel space. There is a shared copy of the
+ code and a separate stack for each thread.
+
+ \image threadvisual-example.png "Thread visualization"
+
+ If two threads have a pointer to the same object, it is possible that both
+ threads will access that object at the same time and this can potentially
+ destroy the object's integrity. It's easy to imagine the many things that
+ can go wrong when two methods of the same object are executed
+ simultaneously.
+
+ Sometimes it is necessary to access one object from different threads;
+ for example, when objects living in different threads need to communicate.
+ Since threads use the same address space, it is easier and faster for
+ threads to exchange data than it is for processes. Data does not have to be
+ serialized and copied. Passing pointers is possible, but there must be a
+ strict coordination of what thread touches which object. Simultaneous
+ execution of operations on one object must be prevented. There are several
+ ways of achieving this and some of them are described below.
+
+ So what can be done safely? All objects created in a thread can be used
+ safely within that thread provided that other threads don't have references
+ to them and objects don't have implicit coupling with other threads. Such
+ implicit coupling may happen when data is shared between instances as with
+ static members, singletons or global data. Familiarize yourself with the
+ concept of \l{Reentrancy and Thread-Safety}{thread safe and reentrant}
+ classes and functions.
+
+ \section1 Using Threads
+
+ There are basically two use cases for threads:
+
+ \list
+ \li Make processing faster by making use of multicore processors.
+ \li Keep the GUI thread or other time critical threads responsive by
+ offloading long lasting processing or blocking calls to other threads.
+ \endlist
+
+ \section2 When to Use Alternatives to Threads
+
+ Developers need to be very careful with threads. It is easy to start other
+ threads, but very hard to ensure that all shared data remains consistent.
+ Problems are often hard to find because they may only show up once in a
+ while or only on specific hardware configurations. Before creating threads
+ to solve certain problems, possible alternatives should be considered.
+
+ \table
+ \header
+ \li Alternative
+ \li Comment
+ \row
+ \li QEventLoop::processEvents()
+ \li Calling QEventLoop::processEvents() repeatedly during a
+ time-consuming calculation prevents GUI blocking. However, this
+ solution doesn't scale well because the call to processEvents() may
+ occur too often, or not often enough, depending on hardware.
+ \row
+ \li QTimer
+ \li Background processing can sometimes be done conveniently using a
+ timer to schedule execution of a slot at some point in the future.
+ A timer with an interval of 0 will time out as soon as there are no
+ more events to process.
+ \row
+ \li QSocketNotifier QNetworkAccessManager QIODevice::readyRead()
+ \li This is an alternative to having one or multiple threads, each with
+ a blocking read on a slow network connection. As long as the
+ calculation in response to a chunk of network data can be executed
+ quickly, this reactive design is better than synchronous waiting in
+ threads. Reactive design is less error prone and energy efficient
+ than threading. In many cases there are also performance benefits.
+ \endtable
+
+ In general, it is recommended to only use safe and tested paths and to
+ avoid introducing ad-hoc threading concepts. QtConcurrent provides an easy
+ interface for distributing work to all of the processor's cores. The
+ threading code is completely hidden in the QtConcurrent framework, so you
+ don't have to take care of the details. However, QtConcurrent can't be used
+ when communication with the running thread is needed, and it shouldn't be
+ used to handle blocking operations.
+
+ \section2 Which Qt Thread Technology Should You Use?
+
+ Sometimes you want to do more than just running a method in the context of
+ another thread. You may want to have an object which lives in another
+ thread that provides a service to the GUI thread. Maybe you want another
+ thread to stay alive forever to poll hardware ports and send a signal to
+ the GUI thread when something noteworthy has happened. Qt provides
+ different solutions for developing threaded applications. The right
+ solution depends on the purpose of the new thread as well as on the
+ thread's lifetime.
+
+ \table
+ \header
+ \li Lifetime of thread
+ \li Development task
+ \li Solution
+ \row
+ \li One call
+ \li Run one method within another thread and quit the thread when the
+ method is finished.
+ \li Qt provides different solutions:
+ \list
+ \li Write a function and run it with QtConcurrent::run()
+ \li Derive a class from QRunnable and run it in the global thread
+ pool with QThreadPool::globalInstance()->start()
+ \li Derive a class from QThread, reimplement the QThread::run()
+ method and use QThread::start() to run it.
+ \endlist
+
+ \row
+ \li One call
+ \li Operations are to be performed on all items of a container.
+ Processing should be performed using all available cores. A common
+ example is to produce thumbnails from a list of images.
+ \li QtConcurrent provides the \l{QtConcurrent::}{map()} function for
+ applying operations on every container element,
+ \l{QtConcurrent::}{filter()} for selecting container elements, and
+ the option of specifying a reduce function for combining the
+ remaining elements.
+ \row
+ \li One call
+ \li A long running operation has to be put in another thread. During the
+ course of processing, status information should be sent to the GUI
+ thread.
+ \li Use QThread, reimplement run and emit signals as needed. Connect the
+ signals to the GUI thread's slots using queued signal/slot
+ connections.
+
+ \row
+ \li Permanent
+ \li Have an object living in another thread and let it perform different
+ tasks upon request.
+ This means communication to and from the worker thread is required.
+ \li Derive a class from QObject and implement the necessary slots and
+ signals, move the object to a thread with a running event loop and
+ communicate with the object over queued signal/slot connections.
+ \row
+ \li Permanent
+ \li Have an object living in another thread, let the object perform
+ repeated tasks such as polling a port and enable communication with
+ the GUI thread.
+ \li Same as above but also use a timer in the worker thread to implement
+ polling. However, the best solution for polling is to avoid it
+ completely. Sometimes using QSocketNotifier is an alternative.
+ \endtable
+
+
+ \section1 Qt Thread Basics
+
+ QThread is a very convenient cross platform abstraction of native platform
+ threads. Starting a thread is very simple. Let us look at a short piece of
+ code that generates another thread which says hello in that thread and then
+ exits.
+
+ \snippet tutorials/threads/hellothread/hellothread.h 1
+
+ We derive a class from QThread and reimplement the \l{QThread::}{run()}
+ method.
+
+ \snippet tutorials/threads/hellothread/hellothread.cpp 1
+
+ The run method contains the code that will be run in a separate thread. In
+ this example, a message containing the thread ID will be printed.
+ QThread::start() will call the method in another thread.
+
+ \snippet tutorials/threads/hellothread/main.cpp 1
+
+ To start the thread, our thread object needs to be instantiated. The
+ \l{QThread::}{start()} method creates a new thread and calls the
+ reimplemented \l{QThread::}{run()} method in this new thread. Right after
+ \l{QThread::}{start()} is called, two program counters walk through the
+ program code. The main function starts with only the GUI thread running and
+ it should terminate with only the GUI thread running. Exiting the program
+ when another thread is still busy is a programming error, and therefore,
+ wait is called which blocks the calling thread until the
+ \l{QThread::}{run()} method has completed.
+
+ This is the result of running the code:
+
+ \badcode
+ hello from GUI thread 3079423696
+ hello from worker thread 3076111216
+ \endcode
+
+
+ \section2 QObject and Threads
+
+ A QObject is said to have a \e{thread affinity} or, in other words, that it
+ lives in a certain thread. This means that, at creation time, QObject saves
+ a pointer to the current thread. This information becomes relevant when an
+ event is posted with \l{QCoreApplication::}{postEvent()}. The event will be
+ put in the corresponding thread's event loop. If the thread where the
+ QObject lives doesn't have an event loop, the event will never be delivered.
+
+ To start an event loop, \l{QThread::}{exec()} must be called inside
+ \l{QThread::}{run()}. Thread affinity can be changed using
+ \l{QObject::}{moveToThread()}.
+
+ As mentioned above, developers must always be careful when calling objects'
+ methods from other threads. Thread affinity does not change this situation.
+ Qt documentation marks several methods as thread-safe.
+ \l{QCoreApplication::}{postEvent()} is a noteworthy example. A thread-safe
+ method may be called from different threads simultaneously.
+
+ In cases where there is usually no concurrent access to methods, calling
+ non-thread-safe methods of objects in other threads may work thousands
+ of times before a concurrent access occurs, causing unexpected behavior.
+ Writing test code does not entirely ensure thread correctness, but it is
+ still important.
+ On Linux, Valgrind and Helgrind can help detect threading errors.
+
+ The anatomy of QThread is quite interesting:
+
+ \list
+ \li QThread does not live in the new thread where \l{QThread::}{run()} is
+ executed. It lives in the old thread.
+ \li Most QThread methods are the thread's control interface and are meant to
+ be called from the old thread. Do not move this interface to the newly
+ created thread using \l{QObject::}{moveToThread()}; i.e., calling
+ \l{QObject::moveToThread()}{moveToThread(this)} is regarded as bad
+ practice.
+ \li \l{QThread::}{exec()} and the static methods
+ \l{QThread::}{usleep()}, \l{QThread::}{msleep()},
+ \l{QThread::}{sleep()} are meant to be called from the newly created
+ thread.
+ \li Additional members defined in the QThread subclass are
+ accessible by both threads. The developer is responsible for
+ coordinating access. A typical strategy is to set the members before
+ \l{QThread::}{start()} is called. Once the worker thread is running,
+ the main thread should not touch the additional members anymore. After
+ the worker has terminated, the main thread can access the additional
+ members again. This is a convenient strategy for passing parameters to a
+ thread before it is started as well as for collecting the result once it
+ has terminated.
+ \endlist
+
+ A QObject's parent must always be in the same thread. This has a surprising
+ consequence for objects generated within the \l{QThread::}{run()} method:
+
+ \code
+ void HelloThread::run()
+ {
+ QObject *object1 = new QObject(this); //error, parent must be in the same thread
+ QObject object2; // OK
+ QSharedPointer <QObject> object3(new QObject); // OK
+ }
+ \endcode
+
+ \section2 Using a Mutex to Protect the Integrity of Data
+
+ A mutex is an object that has \l{QMutex::}{lock()} and \l{QMutex::}{unlock()}
+ methods and remembers if it is already locked. A mutex is designed to be
+ called from multiple threads. \l{QMutex::}{lock()} returns immediately if
+ the mutex is not locked. The next call from another thread will find the
+ mutex in a locked state and then \l{QMutex::}{lock()} will block the thread
+ until the other thread calls \l{QMutex::}{unlock()}. This functionality can
+ make sure that a code section will be executed by only one thread at a time.
+
+ The following line sketches how a mutex can be used to make a method
+ thread-safe:
+
+ \code
+ void Worker::work()
+ {
+ this->mutex.lock(); // first thread can pass, other threads will be blocked here
+ doWork();
+ this->mutex.unlock();
+ }
+ \endcode
+
+ What happens if one thread does not unlock a mutex? The result can be a
+ frozen application. In the example above, an exception might be thrown and
+ \c{mutex.unlock()} will never be reached. To prevent problems like this,
+ QMutexLocker should be used.
+
+ \code
+ void Worker::work()
+ {
+ QMutexLocker locker(&mutex); // Locks the mutex and unlocks when locker exits the scope
+ doWork();
+ }
+ \endcode
+
+ This looks easy, but mutexes introduce a new class of problems: deadlocks.
+ A deadlock happens when a thread waits for a mutex to become unlocked, but
+ the mutex remains locked because the owning thread is waiting for the first
+ thread to unlock it. The result is a frozen application. Mutexes can be
+ used to make a method thread safe. Most Qt methods aren't thread safe
+ because there is always a performance penalty when using mutexes.
+
+ It isn't always possible to lock and unlock a mutex in a method. Sometimes
+ the need to lock spans several calls. For example, modifying a container
+ with an iterator requires a sequence of several calls which should not be
+ interrupted by other threads. In such a scenario, locking can be achieved
+ with a mutex that is kept outside of the object to be manipulated. With an
+ external mutex, the duration of locking can be adjusted to the needs of the
+ operation. One disadvantage is that external mutexes aid locking, but do
+ not enforce it because users of the object may forget to use it.
+
+ \section2 Using the Event Loop to Prevent Data Corruption
+
+ The event loops of Qt are a very valuable tool for inter-thread
+ communication. Every thread may have its own event loop. A safe way of
+ calling a slot in another thread is by placing that call in another
+ thread's event loop. This ensures that the target object finishes the
+ method that is currently running before another method is started.
+
+ So how is it possible to put a method invocation in an event loop? Qt has
+ two ways of doing this. One way is via queued signal-slot connections; the
+ other way is to post an event with QCoreApplication::postEvent(). A queued
+ signal-slot connection is a signal slot connection that is executed
+ asynchronously. The internal implementation is based on posted events. The
+ arguments of the signal are put into the event loop and the signal method
+ returns immediately.
+
+ The connected slot will be executed at a time which depends on what else is
+ in the event loop.
+
+ Communication via the event loop eliminates the deadlock problem we face
+ when using mutexes. This is why we recommend using the event loop rather
+ than locking an object using a mutex.
+
+ \section2 Dealing with Asynchronous Execution
+
+ One way to obtain a worker thread's result is by waiting for the thread
+ to terminate. In many cases, however, a blocking wait isn't acceptable. The
+ alternative to a blocking wait are asynchronous result deliveries with
+ either posted events or queued signals and slots. This generates a certain
+ overhead because an operation's result does not appear on the next source
+ line, but in a slot located somewhere else in the source file. Qt
+ developers are used to working with this kind of asynchronous behavior
+ because it is much similar to the kind of event-driven programming used in
+ GUI applications.
+
+ \section1 Examples
+
+ This tutorial comes with examples for Qt's three basic ways of working with
+ threads. Two more examples show how to communicate with a running thread
+ and how a QObject can be placed in another thread, providing service to the
+ main thread.
+
+ \list
+ \li Using QThread as shown \l{Qt thread basics}{above}
+ \li \l{Example 1: Using the Thread Pool}{Using the global QThreadPool}
+ \li \l{Example 2: Using QtConcurrent}{Using QtConcurrent}
+ \li \l{Example 3: Clock}{Communication with the GUI thread}
+ \li \l{Example 4: A Permanent Thread}{A permanent QObject in another thread
+ provides service to the main thread}
+ \endlist
+
+ The following examples can all be compiled and run independently. The source can
+ be found in the examples directory: examples/tutorials/threads/
+
+ \section2 Example 1: Using the Thread Pool
+
+ Creating and destroying threads frequently can be expensive. To avoid the
+ cost of thread creation, a thread pool can be used. A thread pool is a
+ place where threads can be parked and fetched. We can write the same
+ "hello thread" program as \l{Qt Thread Basics}{above} using the global
+ thread pool. We derive a class from QRunnable. The code we want to run in
+ another thread needs to be placed in the reimplemented QRunnable::run()
+ method.
+
+ \snippet tutorials/threads/hellothreadpool/hellothreadpool.cpp 1
+
+ We instantiate Work in main(), locate the global thread pool and use the
+ QThreadPool::start() method. Now the thread pool runs our worker in another
+ thread. Using the thread pool has a performance advantage because threads
+ are not destroyed after they have finished running. They are kept in a pool
+ and wait to be used again later.
+
+ \section2 Example 2: Using QtConcurrent
+
+ \snippet tutorials/threads/helloconcurrent/helloconcurrent.cpp 1
+
+ We write a global function hello() to implement the work. QtConcurrent::run()
+ is used to run the function in another thread. The result is a QFuture.
+ QFuture provides a method called \l{QFuture::}{waitForFinished()}, which
+ blocks until the calculation is completed. The real power of QtConcurrent
+ becomes visible when data can be made available in a container. QtConcurrent
+ provides several functions that are able to process itemized data on all
+ available cores simultaneously. The use of QtConcurrent is very similar to
+ applying an STL algorithm to an STL container.
+ \l{examples-threadandconcurrent.html}{QtConcurrent Map} is a very short and
+ clear example about how a container of images can be scaled on all available
+ cores. The image scaling example uses the blocking variants of the functions
+ used. For every blocking function there is also a non-blocking, asynchronous
+ counterpart. Getting results asynchronously is implemented with QFuture and
+ QFutureWatcher.
+
+ \section2 Example 3: Clock
+
+ \image thread_clock.png "clock"
+
+ We want to produce a clock application. The application has a GUI and a
+ worker thread. The worker thread checks every 10 milliseconds what time it
+ is. If the formatted time has changed, the result will be sent to the GUI
+ thread where it is displayed.
+
+ Of course, this is an overly complicated way of designing a clock and,
+ actually, a separate thread is unnecessary. We would be better off placing
+ the timer in the main thread because the calculation made in the timer slot
+ is very short-lived. This example is purely for instructional use and shows
+ how to communicate from a worker thread to a GUI thread. Note that
+ communication in this direction is easy. We only need to add a signal
+ to QThread and make a queued signal/slot connection to the main thread.
+ Communication from the GUI to the worker thread is shown in the next
+ example.
+
+ \snippet tutorials/threads/clock/main.cpp 1
+
+ We've connected the \c clockThread with the label. The connection must be a
+ queued signal-slot connection because we want to put the call in the event
+ loop.
+
+ \snippet tutorials/threads/clock/clockthread.h 1
+
+ We have derived a class from QThread and declared the \c sendTime() signal.
+
+ \snippet tutorials/threads/clock/clockthread.cpp 1
+
+ The trickiest part of this example is that the timer is connected to its
+ slot via a direct connection. A default connection would produce a queued
+ signal-slot connection because the connected objects live in different
+ threads; remember that QThread does not live in the thread it creates.
+
+ Still it is safe to access ClockThread::timerHit() from the worker thread
+ because ClockThread::timerHit() is private and only touches local variables
+ and a private member that isn't touched by public methods.
+ QDateTime::currentDateTime() isn't marked as thread-safe in Qt
+ documentation, however we can get away with using it in this small
+ example because we know that the QDateTime::currentDateTime() static
+ method isn't used in any other threads.
+
+ \section2 Example 4: A Permanent Thread
+
+ This example shows how it is possible to have a QObject in a worker thread
+ that accepts requests from the GUI thread, does polling using a timer and
+ continuously reports results back to the GUI thread. The actual work
+ including the polling must be implemented in a class derived from QObject.
+ We have called this class \c WorkerObject in the code shown below. The
+ thread-specific code is hidden in a class called \c Thread, derived from
+ QThread.
+ \c Thread has two additional public members. The \c launchWorker() member
+ takes the worker object and moves it to another thread with a started event
+ loop.
+ The call blocks for a very short moment until the thread creation operation
+ is completed, allowing the worker object to be used again on the next line.
+ The \c Thread class's code is short but somewhat involved, so we only show
+ how to use the class.
+
+ \snippet tutorials/threads/movedobject/main.cpp 1
+
+ QMetaObject::invokeMethod() calls a slot via the event loop. The worker
+ object's methods should not be called directly after the object has been
+ moved to another thread. We let the worker thread do some work and polling,
+ and use a timer to shut the application down after 3 seconds. Shutting the
+ worker down needs some care. We call \c{Thread::stop()} to exit the event
+ loop. We wait for the thread to terminate and, after this has occurred, we
+ delete the worker.
+
+ \section1 Digging Deeper
+
+ Threading is a very complicated subject. Qt offers more classes for
+ threading than we have presented in this tutorial. The following materials
+ can help you go into the subject in more depth:
+
+ \list
+ \li Good video tutorials about threads with Qt can be found in the material
+ from the \l{Training Day at Qt Developer Days 2009}.
+ \li The \l{Thread Support in Qt} document is a good starting point into
+ the reference documentation.
+ \li Qt comes with several additional examples for
+ \l{Threading and Concurrent Programming Examples}{QThread and QtConcurrent}.
+ \li Several good books describe how to work with Qt threads. The most
+ extensive coverage can be found in \e{Advanced Qt Programming} by Mark
+ Summerfield, Prentice Hall - roughly 70 of 500 pages cover QThread and
+ QtConcurrent.
+ \endlist
+*/
diff --git a/src/corelib/doc/src/threads.qdoc b/src/corelib/doc/src/threads.qdoc
new file mode 100644
index 0000000000..80c9445f6f
--- /dev/null
+++ b/src/corelib/doc/src/threads.qdoc
@@ -0,0 +1,705 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \group thread
+ \title Threading Classes
+*/
+
+/*!
+ \page threads.html
+ \title Thread Support in Qt
+ \ingroup qt-basic-concepts
+ \brief A detailed discussion of thread handling in Qt.
+
+ \ingroup frameworks-technologies
+
+ \nextpage Starting Threads with QThread
+
+ Qt provides thread support in the form of platform-independent
+ threading classes, a thread-safe way of posting events, and
+ signal-slot connections across threads. This makes it easy to
+ develop portable multithreaded Qt applications and take advantage
+ of multiprocessor machines. Multithreaded programming is also a
+ useful paradigm for performing time-consuming operations without
+ freezing the user interface of an application.
+
+ Earlier versions of Qt offered an option to build the library
+ without thread support. Since Qt 4.0, threads are always enabled.
+
+ \section1 Topics:
+
+ \list
+ \li \l{Recommended Reading}
+ \li \l{The Threading Classes}
+ \li \l{Starting Threads with QThread}
+ \li \l{Synchronizing Threads}
+ \li \l{Reentrancy and Thread-Safety}
+ \li \l{Threads and QObjects}
+ \li \l{Concurrent Programming}
+ \li \l{Thread-Support in Qt Modules}
+ \endlist
+
+ \section1 Recommended Reading
+
+ This document is intended for an audience that has knowledge of,
+ and experience with, multithreaded applications. If you are new
+ to threading see our Recommended Reading list:
+
+ \list
+ \li \l{Threads Primer: A Guide to Multithreaded Programming}
+ \li \l{Thread Time: The Multithreaded Programming Guide}
+ \li \l{Pthreads Programming: A POSIX Standard for Better Multiprocessing}
+ \li \l{Win32 Multithreaded Programming}
+ \endlist
+
+ \section1 The Threading Classes
+
+ These classes are relevant to threaded applications.
+
+ \annotatedlist thread
+
+\omit
+ \list
+ \li QThread provides the means to start a new thread.
+ \li QThreadStorage provides per-thread data storage.
+ \li QThreadPool manages a pool of threads that run QRunnable objects.
+ \li QRunnable is an abstract class representing a runnable object.
+ \li QMutex provides a mutual exclusion lock, or mutex.
+ \li QMutexLocker is a convenience class that automatically locks
+ and unlocks a QMutex.
+ \li QReadWriteLock provides a lock that allows simultaneous read access.
+ \li QReadLocker and QWriteLocker are convenience classes that automatically
+ lock and unlock a QReadWriteLock.
+ \li QSemaphore provides an integer semaphore (a generalization of a mutex).
+ \li QWaitCondition provides a way for threads to go to sleep until
+ woken up by another thread.
+ \li QAtomicInt provides atomic operations on integers.
+ \li QAtomicPointer provides atomic operations on pointers.
+ \endlist
+\endomit
+
+ \note Qt's threading classes are implemented with native threading APIs;
+ e.g., Win32 and pthreads. Therefore, they can be used with threads of the
+ same native API.
+*/
+
+/*!
+ \page threads-starting.html
+ \title Starting Threads with QThread
+
+ \contentspage Thread Support in Qt
+ \nextpage Synchronizing Threads
+
+ A QThread instance represents a thread and provides the means to
+ \l{QThread::start()}{start()} a thread, which will then execute the
+ reimplementation of QThread::run(). The \c run() implementation is for a
+ thread what the \c main() entry point is for the application. All code
+ executed in a call stack that starts in the \c run() function is executed
+ by the new thread, and the thread finishes when the function returns.
+ QThread emits signals to indicate that the thread started or finished
+ executing.
+
+ \section1 Creating a Thread
+
+ To create a thread, subclass QThread and reimplement its
+ \l{QThread::run()}{run()} function. For example:
+
+ \snippet threads/threads.h 0
+ \codeline
+ \snippet threads/threads.cpp 0
+ \snippet threads/threads.cpp 1
+ \dots
+ \snippet threads/threads.cpp 2
+
+ \section1 Starting a Thread
+
+ Then, create an instance of the thread object and call
+ QThread::start(). Note that you must create the QApplication (or
+ QCoreApplication) object before you can create a QThread.
+
+ The function will return immediately and the
+ main thread will continue. The code that appears in the
+ \l{QThread::run()}{run()} reimplementation will then be executed
+ in a separate thread.
+
+ Creating threads is explained in more detail in the QThread
+ documentation.
+
+ Note that QCoreApplication::exec() must always be called from the
+ main thread (the thread that executes \c{main()}), not from a
+ QThread. In GUI applications, the main thread is also called the
+ GUI thread because it's the only thread that is allowed to
+ perform GUI-related operations.
+*/
+
+/*!
+ \page threads-synchronizing.html
+ \title Synchronizing Threads
+
+ \previouspage Starting Threads with QThread
+ \contentspage Thread Support in Qt
+ \nextpage Reentrancy and Thread-Safety
+
+ The QMutex, QReadWriteLock, QSemaphore, and QWaitCondition
+ classes provide means to synchronize threads. While the main idea
+ with threads is that they should be as concurrent as possible,
+ there are points where threads must stop and wait for other
+ threads. For example, if two threads try to access the same
+ global variable simultaneously, the results are usually
+ undefined.
+
+ QMutex provides a mutually exclusive lock, or mutex. At most one
+ thread can hold the mutex at any time. If a thread tries to
+ acquire the mutex while the mutex is already locked, the thread will
+ be put to sleep until the thread that currently holds the mutex
+ unlocks it. Mutexes are often used to protect accesses to shared
+ data (i.e., data that can be accessed from multiple threads
+ simultaneously). In the \l{Reentrancy and Thread-Safety} section
+ below, we will use it to make a class thread-safe.
+
+ QReadWriteLock is similar to QMutex, except that it distinguishes
+ between "read" and "write" access to shared data and allows
+ multiple readers to access the data simultaneously. Using
+ QReadWriteLock instead of QMutex when it is possible can make
+ multithreaded programs more concurrent.
+
+ QSemaphore is a generalization of QMutex that protects a certain
+ number of identical resources. In contrast, a mutex protects
+ exactly one resource. The \l{threads/semaphores}{Semaphores}
+ example shows a typical application of semaphores: synchronizing
+ access to a circular buffer between a producer and a consumer.
+
+ QWaitCondition allows a thread to wake up other threads when some
+ condition has been met. One or many threads can block waiting for
+ a QWaitCondition to set a condition with
+ \l{QWaitCondition::wakeOne()}{wakeOne()} or
+ \l{QWaitCondition::wakeAll()}{wakeAll()}. Use
+ \l{QWaitCondition::wakeOne()}{wakeOne()} to wake one randomly
+ selected event or \l{QWaitCondition::wakeAll()}{wakeAll()} to
+ wake them all. The \l{threads/waitconditions}{Wait Conditions}
+ example shows how to solve the producer-consumer problem using
+ QWaitCondition instead of QSemaphore.
+
+ Note that Qt's synchronization classes rely on the use of properly
+ aligned pointers. For instance, you cannot use packed classes with
+ MSVC.
+*/
+
+/*!
+ \page threads-reentrancy.html
+ \title Reentrancy and Thread-Safety
+
+ \keyword reentrant
+ \keyword thread-safe
+
+ \previouspage Synchronizing Threads
+ \contentspage Thread Support in Qt
+ \nextpage Threads and QObjects
+
+ Throughout the documentation, the terms \e{reentrant} and
+ \e{thread-safe} are used to mark classes and functions to indicate
+ how they can be used in multithread applications:
+
+ \list
+ \li A \e thread-safe function can be called simultaneously from
+ multiple threads, even when the invocations use shared data,
+ because all references to the shared data are serialized.
+ \li A \e reentrant function can also be called simultaneously from
+ multiple threads, but only if each invocation uses its own data.
+ \endlist
+
+ Hence, a \e{thread-safe} function is always \e{reentrant}, but a
+ \e{reentrant} function is not always \e{thread-safe}.
+
+ By extension, a class is said to be \e{reentrant} if its member
+ functions can be called safely from multiple threads, as long as
+ each thread uses a \e{different} instance of the class. The class
+ is \e{thread-safe} if its member functions can be called safely
+ from multiple threads, even if all the threads use the \e{same}
+ instance of the class.
+
+ \note Qt classes are only documented as \e{thread-safe} if they
+ are intended to be used by multiple threads. If a function is not
+ marked as thread-safe or reentrant, it should not be used from
+ different threads. If a class is not marked as thread-safe or
+ reentrant then a specific instance of that class should not be
+ accessed from different threads.
+
+ \section1 Reentrancy
+
+ C++ classes are often reentrant, simply because they only access
+ their own member data. Any thread can call a member function on an
+ instance of a reentrant class, as long as no other thread can call
+ a member function on the \e{same} instance of the class at the
+ same time. For example, the \c Counter class below is reentrant:
+
+ \snippet threads/threads.cpp 3
+ \snippet threads/threads.cpp 4
+
+ The class isn't thread-safe, because if multiple threads try to
+ modify the data member \c n, the result is undefined. This is
+ because the \c ++ and \c -- operators aren't always atomic.
+ Indeed, they usually expand to three machine instructions:
+
+ \list 1
+ \li Load the variable's value in a register.
+ \li Increment or decrement the register's value.
+ \li Store the register's value back into main memory.
+ \endlist
+
+ If thread A and thread B load the variable's old value
+ simultaneously, increment their register, and store it back, they
+ end up overwriting each other, and the variable is incremented
+ only once!
+
+ \section1 Thread-Safety
+
+ Clearly, the access must be serialized: Thread A must perform
+ steps 1, 2, 3 without interruption (atomically) before thread B
+ can perform the same steps; or vice versa. An easy way to make
+ the class thread-safe is to protect all access to the data
+ members with a QMutex:
+
+ \snippet threads/threads.cpp 5
+ \snippet threads/threads.cpp 6
+
+ The QMutexLocker class automatically locks the mutex in its
+ constructor and unlocks it when the destructor is invoked, at the
+ end of the function. Locking the mutex ensures that access from
+ different threads will be serialized. The \c mutex data member is
+ declared with the \c mutable qualifier because we need to lock
+ and unlock the mutex in \c value(), which is a const function.
+
+ \section1 Notes on Qt Classes
+
+ Many Qt classes are \e{reentrant}, but they are not made
+ \e{thread-safe}, because making them thread-safe would incur the
+ extra overhead of repeatedly locking and unlocking a QMutex. For
+ example, QString is reentrant but not thread-safe. You can safely
+ access \e{different} instances of QString from multiple threads
+ simultaneously, but you can't safely access the \e{same} instance
+ of QString from multiple threads simultaneously (unless you
+ protect the accesses yourself with a QMutex).
+
+ Some Qt classes and functions are thread-safe. These are mainly
+ the thread-related classes (e.g. QMutex) and fundamental functions
+ (e.g. QCoreApplication::postEvent()).
+
+ \note Terminology in the multithreading domain isn't entirely
+ standardized. POSIX uses definitions of reentrant and thread-safe
+ that are somewhat different for its C APIs. When using other
+ object-oriented C++ class libraries with Qt, be sure the
+ definitions are understood.
+*/
+
+/*!
+ \page threads-qobject.html
+ \title Threads and QObjects
+
+ \previouspage Reentrancy and Thread Safety
+ \contentspage Thread Support in Qt
+ \nextpage Concurrent Programming
+
+ QThread inherits QObject. It emits signals to indicate that the
+ thread started or finished executing, and provides a few slots as
+ well.
+
+ More interesting is that \l{QObject}s can be used in multiple
+ threads, emit signals that invoke slots in other threads, and
+ post events to objects that "live" in other threads. This is
+ possible because each thread is allowed to have its own event
+ loop.
+
+ \section1 QObject Reentrancy
+
+ QObject is reentrant. Most of its non-GUI subclasses, such as
+ QTimer, QTcpSocket, QUdpSocket and QProcess, are also
+ reentrant, making it possible to use these classes from multiple
+ threads simultaneously. Note that these classes are designed to be
+ created and used from within a single thread; creating an object
+ in one thread and calling its functions from another thread is not
+ guaranteed to work. There are three constraints to be aware of:
+
+ \list
+ \li \e{The child of a QObject must always be created in the thread
+ where the parent was created.} This implies, among other
+ things, that you should never pass the QThread object (\c
+ this) as the parent of an object created in the thread (since
+ the QThread object itself was created in another thread).
+
+ \li \e{Event driven objects may only be used in a single thread.}
+ Specifically, this applies to the \l{timers.html}{timer
+ mechanism} and the \l{QtNetwork}{network module}. For example,
+ you cannot start a timer or connect a socket in a thread that
+ is not the \l{QObject::thread()}{object's thread}.
+
+ \li \e{You must ensure that all objects created in a thread are
+ deleted before you delete the QThread.} This can be done
+ easily by creating the objects on the stack in your
+ \l{QThread::run()}{run()} implementation.
+ \endlist
+
+ Although QObject is reentrant, the GUI classes, notably QWidget
+ and all its subclasses, are not reentrant. They can only be used
+ from the main thread. As noted earlier, QCoreApplication::exec()
+ must also be called from that thread.
+
+ In practice, the impossibility of using GUI classes in other
+ threads than the main thread can easily be worked around by
+ putting time-consuming operations in a separate worker thread and
+ displaying the results on screen in the main thread when the
+ worker thread is finished. This is the approach used for
+ implementing the \l{threads/mandelbrot}{Mandelbrot} and
+ the \l{network/blockingfortuneclient}{Blocking Fortune Client}
+ example.
+
+ \section1 Per-Thread Event Loop
+
+ Each thread can have its own event loop. The initial thread
+ starts its event loops using QCoreApplication::exec(); other
+ threads can start an event loop using QThread::exec(). Like
+ QCoreApplication, QThread provides an
+ \l{QThread::exit()}{exit(int)} function and a
+ \l{QThread::quit()}{quit()} slot.
+
+ An event loop in a thread makes it possible for the thread to use
+ certain non-GUI Qt classes that require the presence of an event
+ loop (such as QTimer, QTcpSocket, and QProcess). It also makes it
+ possible to connect signals from any threads to slots of a
+ specific thread. This is explained in more detail in the
+ \l{Signals and Slots Across Threads} section below.
+
+ \image threadsandobjects.png Threads, objects, and event loops
+
+ A QObject instance is said to \e live in the thread in which it
+ is created. Events to that object are dispatched by that thread's
+ event loop. The thread in which a QObject lives is available using
+ QObject::thread().
+
+ Note that for QObjects that are created before QApplication,
+ QObject::thread() returns zero. This means that the main thread
+ will only handle posted events for these objects; other event
+ processing is not done at all for objects with no thread. Use the
+ QObject::moveToThread() function to change the thread affinity for
+ an object and its children (the object cannot be moved if it has a
+ parent).
+
+ Calling \c delete on a QObject from a thread other than the one
+ that \e owns the object (or accessing the object in other ways) is
+ unsafe, unless you guarantee that the object isn't processing
+ events at that moment. Use QObject::deleteLater() instead, and a
+ \l{QEvent::DeferredDelete}{DeferredDelete} event will be posted,
+ which the event loop of the object's thread will eventually pick
+ up. By default, the thread that \e owns a QObject is the thread
+ that \e creates the QObject, but not after QObject::moveToThread()
+ has been called.
+
+ If no event loop is running, events won't be delivered to the
+ object. For example, if you create a QTimer object in a thread but
+ never call \l{QThread::exec()}{exec()}, the QTimer will never emit
+ its \l{QTimer::timeout()}{timeout()} signal. Calling
+ \l{QObject::deleteLater()}{deleteLater()} won't work
+ either. (These restrictions apply to the main thread as well.)
+
+ You can manually post events to any object in any thread at any
+ time using the thread-safe function
+ QCoreApplication::postEvent(). The events will automatically be
+ dispatched by the event loop of the thread where the object was
+ created.
+
+ Event filters are supported in all threads, with the restriction
+ that the monitoring object must live in the same thread as the
+ monitored object. Similarly, QCoreApplication::sendEvent()
+ (unlike \l{QCoreApplication::postEvent()}{postEvent()}) can only
+ be used to dispatch events to objects living in the thread from
+ which the function is called.
+
+ \section1 Accessing QObject Subclasses from Other Threads
+
+ QObject and all of its subclasses are not thread-safe. This
+ includes the entire event delivery system. It is important to keep
+ in mind that the event loop may be delivering events to your
+ QObject subclass while you are accessing the object from another
+ thread.
+
+ If you are calling a function on an QObject subclass that doesn't
+ live in the current thread and the object might receive events,
+ you must protect all access to your QObject subclass's internal
+ data with a mutex; otherwise, you may experience crashes or other
+ undesired behavior.
+
+ Like other objects, QThread objects live in the thread where the
+ object was created -- \e not in the thread that is created when
+ QThread::run() is called. It is generally unsafe to provide slots
+ in your QThread subclass, unless you protect the member variables
+ with a mutex.
+
+ On the other hand, you can safely emit signals from your
+ QThread::run() implementation, because signal emission is
+ thread-safe.
+
+ \section1 Signals and Slots Across Threads
+
+ Qt supports these signal-slot connection types:
+
+ \list
+
+ \li \l{Qt::AutoConnection}{Auto Connection} (default) If the signal is
+ emitted in the thread which the receiving object has affinity then
+ the behavior is the same as the Direct Connection. Otherwise,
+ the behavior is the same as the Queued Connection."
+
+ \li \l{Qt::DirectConnection}{Direct Connection} The slot is invoked
+ immediately, when the signal is emitted. The slot is executed
+ in the emitter's thread, which is not necessarily the
+ receiver's thread.
+
+ \li \l{Qt::QueuedConnection}{Queued Connection} The slot is invoked
+ when control returns to the event loop of the receiver's
+ thread. The slot is executed in the receiver's thread.
+
+ \li \l{Qt::BlockingQueuedConnection}{Blocking Queued Connection}
+ The slot is invoked as for the Queued Connection, except the
+ current thread blocks until the slot returns. \note Using this
+ type to connect objects in the same thread will cause deadlock.
+
+ \li \l{Qt::UniqueConnection}{Unique Connection} The behavior is the
+ same as the Auto Connection, but the connection is made only if
+ it does not duplicate an existing connection. i.e., if the same
+ signal is already connected to the same slot for the same pair
+ of objects, then the connection is not made and connect()
+ returns false.
+
+ \endlist
+
+ The connection type can be specified by passing an additional
+ argument to \l{QObject::connect()}{connect()}. Be aware that
+ using direct connections when the sender and receiver live in
+ different threads is unsafe if an event loop is running in the
+ receiver's thread, for the same reason that calling any function
+ on an object living in another thread is unsafe.
+
+ QObject::connect() itself is thread-safe.
+
+ The \l{threads/mandelbrot}{Mandelbrot} example uses a queued
+ connection to communicate between a worker thread and the main
+ thread. To avoid freezing the main thread's event loop (and, as a
+ consequence, the application's user interface), all the
+ Mandelbrot fractal computation is done in a separate worker
+ thread. The thread emits a signal when it is done rendering the
+ fractal.
+
+ Similarly, the \l{network/blockingfortuneclient}{Blocking Fortune
+ Client} example uses a separate thread for communicating with
+ a TCP server asynchronously.
+*/
+
+/*!
+ \page threads-qtconcurrent.html
+ \title Concurrent Programming
+
+ \previouspage Threads and QObjects
+ \contentspage Thread Support in Qt
+ \nextpage Thread-Support in Qt Modules
+
+ \target qtconcurrent intro
+
+ The QtConcurrent namespace provides high-level APIs that make it
+ possible to write multi-threaded programs without using low-level
+ threading primitives such as mutexes, read-write locks, wait
+ conditions, or semaphores. Programs written with QtConcurrent
+ automatically adjust the number of threads used according to the
+ number of processor cores available. This means that applications
+ written today will continue to scale when deployed on multi-core
+ systems in the future.
+
+ QtConcurrent includes functional programming style APIs for
+ parallel list processing, including a MapReduce and FilterReduce
+ implementation for shared-memory (non-distributed) systems, and
+ classes for managing asynchronous computations in GUI
+ applications:
+
+ \list
+
+ \li QtConcurrent::map() applies a function to every item in a container,
+ modifying the items in-place.
+
+ \li QtConcurrent::mapped() is like map(), except that it returns a new
+ container with the modifications.
+
+ \li QtConcurrent::mappedReduced() is like mapped(), except that the
+ modified results are reduced or folded into a single result.
+
+ \li QtConcurrent::filter() removes all items from a container based on the
+ result of a filter function.
+
+ \li QtConcurrent::filtered() is like filter(), except that it returns a new
+ container with the filtered results.
+
+ \li QtConcurrent::filteredReduced() is like filtered(), except that the
+ filtered results are reduced or folded into a single result.
+
+ \li QtConcurrent::run() runs a function in another thread.
+
+ \li QFuture represents the result of an asynchronous computation.
+
+ \li QFutureIterator allows iterating through results available via QFuture.
+
+ \li QFutureWatcher allows monitoring a QFuture using signals-and-slots.
+
+ \li QFutureSynchronizer is a convenience class that automatically
+ synchronizes several QFutures.
+
+ \endlist
+
+ Qt Concurrent supports several STL-compatible container and iterator types,
+ but works best with Qt containers that have random-access iterators, such as
+ QList or QVector. The map and filter functions accept both containers and begin/end iterators.
+
+ STL Iterator support overview:
+
+ \table
+ \header
+ \li Iterator Type
+ \li Example classes
+ \li Support status
+ \row
+ \li Input Iterator
+ \li
+ \li Not Supported
+ \row
+ \li Output Iterator
+ \li
+ \li Not Supported
+ \row
+ \li Forward Iterator
+ \li std::slist
+ \li Supported
+ \row
+ \li Bidirectional Iterator
+ \li QLinkedList, std::list
+ \li Supported
+ \row
+ \li Random Access Iterator
+ \li QList, QVector, std::vector
+ \li Supported and Recommended
+ \endtable
+
+ Random access iterators can be faster in cases where Qt Concurrent is iterating
+ over a large number of lightweight items, since they allow skipping to any point
+ in the container. In addition, using random access iterators allows Qt Concurrent
+ to provide progress information trough QFuture::progressValue() and QFutureWatcher::
+ progressValueChanged().
+
+ The non in-place modifying functions such as mapped() and filtered() makes a
+ copy of the container when called. If you are using STL containers this copy operation
+ might take some time, in this case we recommend specifying the begin and end iterators
+ for the container instead.
+*/
+
+/*!
+ \page threads-modules.html
+ \title Thread-Support in Qt Modules
+
+ \previouspage Concurrent Programming
+ \contentspage Thread Support in Qt
+
+ \section1 Threads and the SQL Module
+
+ A connection can only be used from within the thread that created it.
+ Moving connections between threads or creating queries from a different
+ thread is not supported.
+
+ In addition, the third party libraries used by the QSqlDrivers can impose
+ further restrictions on using the SQL Module in a multithreaded program.
+ Consult the manual of your database client for more information
+
+ \section1 Painting in Threads
+
+ QPainter can be used in a thread to paint onto QImage, QPrinter, and
+ QPicture paint devices. Painting onto QPixmaps and QWidgets is \e not
+ supported. On Mac OS X the automatic progress dialog will not be
+ displayed if you are printing from outside the GUI thread.
+
+ Any number of threads can paint at any given time, however only
+ one thread at a time can paint on a given paint device. In other
+ words, two threads can paint at the same time if each paints onto
+ separate QImages, but the two threads cannot paint onto the same
+ QImage at the same time.
+
+ Note that on X11 systems without FontConfig support, Qt cannot
+ render text outside of the GUI thread. You can use the
+ QFontDatabase::supportsThreadedFontRendering() function to detect
+ whether or not font rendering can be used outside the GUI thread.
+
+ \section1 Threads and Rich Text Processing
+
+ The QTextDocument, QTextCursor, and \link richtext.html all
+ related classes\endlink are reentrant.
+
+ Note that a QTextDocument instance created in the GUI thread may
+ contain QPixmap image resources. Use QTextDocument::clone() to
+ create a copy of the document, and pass the copy to another thread for
+ further processing (such as printing).
+
+ \section1 Threads and the SVG module
+
+ The QSvgGenerator and QSvgRenderer classes in the QtSvg module
+ are reentrant.
+
+ \section1 Threads and Implicitly Shared Classes
+
+ Qt uses an optimization called \l{implicit sharing} for many of
+ its value class, notably QImage and QString. Beginning with Qt 4,
+ implicit shared classes can safely be copied across threads, like
+ any other value classes. They are fully
+ \l{Reentrancy and Thread-Safety}{reentrant}. The implicit sharing
+ is really \e implicit.
+
+ In many people's minds, implicit sharing and multithreading are
+ incompatible concepts, because of the way the reference counting
+ is typically done. Qt, however, uses atomic reference counting to
+ ensure the integrity of the shared data, avoiding potential
+ corruption of the reference counter.
+
+ Note that atomic reference counting does not guarantee
+ \l{Reentrancy and Thread-Safety}{thread-safety}. Proper locking should be used
+ when sharing an instance of an implicitly shared class between
+ threads. This is the same requirement placed on all
+ \l{Reentrancy and Thread-Safety}{reentrant} classes, shared or not. Atomic reference
+ counting does, however, guarantee that a thread working on its
+ own, local instance of an implicitly shared class is safe. We
+ recommend using \l{Signals and Slots Across Threads}{signals and
+ slots} to pass data between threads, as this can be done without
+ the need for any explicit locking.
+
+ To sum it up, implicitly shared classes in Qt 4 are really \e
+ implicitly shared. Even in multithreaded applications, you can
+ safely use them as if they were plain, non-shared, reentrant
+ value-based classes.
+*/
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 6d7635ef67..a971bfdf12 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -40,6 +40,10 @@
**
****************************************************************************/
+#ifndef QGLOBAL_H
+# include <QtCore/qglobal.h>
+#endif
+
#ifndef QCOMPILERDETECTION_H
#define QCOMPILERDETECTION_H
@@ -86,13 +90,19 @@
# define Q_CC_MSVC_NET
# define Q_OUTOFLINE_TEMPLATE inline
# define Q_NO_TEMPLATE_FRIENDS
+# define Q_COMPILER_MANGLES_RETURN_TYPE
+# define Q_FUNC_INFO __FUNCSIG__
# define Q_ALIGNOF(type) __alignof(type)
# define Q_DECL_ALIGN(n) __declspec(align(n))
# define Q_ASSUME(expr) __assume(expr)
# define Q_UNREACHABLE() __assume(0)
# define Q_NORETURN __declspec(noreturn)
+# define Q_DECL_DEPRECATED __declspec(deprecated)
+# define Q_DECL_EXPORT __declspec(dllexport)
+# define Q_DECL_IMPORT __declspec(dllimport)
/* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */
# if defined(__INTEL_COMPILER)
+# define Q_DECL_VARIABLE_DEPRECATED
# define Q_CC_INTEL
# endif
/* MSVC does not support SSE/MMX on x64 */
@@ -139,6 +149,16 @@
/* work-around for missing compiler intrinsics */
# define __is_empty(X) false
# define __is_pod(X) false
+# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
+# ifdef Q_OS_LINUX
+# define Q_DECL_EXPORT __attribute__((visibility("default")))
+# define Q_DECL_IMPORT __attribute__((visibility("default")))
+# define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
+# else
+# define Q_DECL_EXPORT __declspec(dllexport)
+# define Q_DECL_IMPORT __declspec(dllimport)
+# endif
+
#elif defined(__GNUC__)
# define Q_CC_GNU
# define Q_C_CALLBACKS
@@ -163,12 +183,24 @@
# endif
# endif
+# ifdef Q_OS_WIN
+# define Q_DECL_EXPORT __declspec(dllexport)
+# define Q_DECL_IMPORT __declspec(dllimport)
+# elif defined(QT_VISIBILITY_AVAILABLE)
+# define Q_DECL_EXPORT __attribute__((visibility("default")))
+# define Q_DECL_IMPORT __attribute__((visibility("default")))
+# define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
+# endif
+
+# define Q_FUNC_INFO __PRETTY_FUNCTION__
# define Q_ALIGNOF(type) __alignof__(type)
# define Q_TYPEOF(expr) __typeof__(expr)
+# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
# define Q_LIKELY(expr) __builtin_expect(!!(expr), true)
# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
# define Q_NORETURN __attribute__((__noreturn__))
+# define Q_REQUIRED_RESULT __attribute__ ((__warn_unused_result__))
# if !defined(QT_MOC_CPP)
# define Q_PACKED __attribute__ ((__packed__))
# define Q_NO_PACKED_REFERENCE
@@ -329,6 +361,7 @@
(see __DCC__ above). This one is for C mode files (__EDG is not defined) */
#elif defined(_DIAB_TOOL)
# define Q_CC_DIAB
+# define Q_FUNC_INFO __PRETTY_FUNCTION__
/* Never tested! */
#elif defined(__HIGHC__)
@@ -336,6 +369,7 @@
#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C)
# define Q_CC_SUN
+# define Q_COMPILER_MANGLES_RETURN_TYPE
/* 5.0 compiler or better
'bool' is enabled by default but can be disabled using -features=nobool
in which case _BOOL is not defined
@@ -381,6 +415,7 @@
# if defined(__HP_aCC) || __cplusplus >= 199707L
# define Q_NO_TEMPLATE_FRIENDS
# define Q_CC_HPACC
+# define Q_FUNC_INFO __PRETTY_FUNCTION__
# if __HP_aCC-0 < 060000
# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
# define Q_DECL_EXPORT __declspec(dllexport)
@@ -403,10 +438,6 @@
# error "Qt has not been tested with this compiler - see http://www.qt-project.org/"
#endif
-#ifndef Q_NORETURN
-# define Q_NORETURN
-#endif
-
/*
* C++11 support
*
@@ -474,13 +505,15 @@
#ifdef Q_CC_CLANG
/* General C++ features */
# if !__has_feature(cxx_exceptions)
-# define QT_NO_EXCEPTIONS
+# ifndef QT_NO_EXCEPTIONS
+# define QT_NO_EXCEPTIONS
+# endif
# 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 __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
# if ((__clang_major__ * 100) + __clang_minor__) >= 209 /* since clang 2.9 */
# define Q_COMPILER_AUTO_TYPE
# define Q_COMPILER_DECLTYPE
@@ -573,9 +606,115 @@
//# define Q_COMPILER_INITIALIZER_LISTS
#endif
-#ifndef Q_COMPILER_MANGLES_RETURN_TYPE
-# if defined(Q_CC_MSVC)
-# define Q_COMPILER_MANGLES_RETURN_TYPE
+/*
+ * C++11 keywords and expressions
+ */
+#ifdef Q_COMPILER_NULLPTR
+# define Q_NULLPTR nullptr
+#else
+# 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
+# define Q_DECL_FINAL final
+# ifdef Q_COMPILER_DECLTYPE // required for class-level final to compile in qvariant_p.h
+# define Q_DECL_FINAL_CLASS final
+# else
+# define Q_DECL_FINAL_CLASS
+# endif
+#else
+# define Q_DECL_OVERRIDE
+# define Q_DECL_FINAL
+# define Q_DECL_FINAL_CLASS
+#endif
+
+#if defined(Q_COMPILER_ALIGNOF) && !defined(Q_ALIGNOF)
+# define Q_ALIGNOF(x) alignof(x)
+#endif
+
+/*
+ * Fallback macros to certain compiler features
+ */
+
+#ifndef Q_NORETURN
+# define Q_NORETURN
+#endif
+#ifndef Q_PACKED
+# define Q_PACKED
+# undef Q_NO_PACKED_REFERENCE
+#endif
+#ifndef Q_LIKELY
+# define Q_LIKELY(x) (x)
+#endif
+#ifndef Q_UNLIKELY
+# define Q_UNLIKELY(x) (x)
+#endif
+#ifndef Q_ASSUME
+# define Q_ASSUME(expr) qt_noop()
+#endif
+#ifndef Q_UNREACHABLE
+# define Q_UNREACHABLE() qt_noop()
+#endif
+#ifndef Q_ALLOC_SIZE
+# define Q_ALLOC_SIZE(x)
+#endif
+#ifndef Q_REQUIRED_RESULT
+# define Q_REQUIRED_RESULT
+#endif
+#ifndef Q_DECL_DEPRECATED
+# define Q_DECL_DEPRECATED
+#endif
+#ifndef Q_DECL_VARIABLE_DEPRECATED
+# define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED
+#endif
+#ifndef Q_DECL_EXPORT
+# define Q_DECL_EXPORT
+#endif
+#ifndef Q_DECL_IMPORT
+# define Q_DECL_IMPORT
+#endif
+#ifndef Q_DECL_HIDDEN
+# define Q_DECL_HIDDEN
+#endif
+#ifndef Q_FUNC_INFO
+# if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC)
+# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
+# else
+# define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
+# endif
+#endif
+
+/*
+ Workaround for static const members on MSVC++.
+*/
+
+#if defined(Q_CC_MSVC)
+# define QT_STATIC_CONST static
+# define QT_STATIC_CONST_IMPL
+#else
+# define QT_STATIC_CONST static const
+# define QT_STATIC_CONST_IMPL const
+#endif
+
+/*
+ Proper for-scoping in MIPSpro CC
+*/
+#ifndef QT_NO_KEYWORDS
+# if defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64))
+# define for if (0) {} else for
# endif
#endif
diff --git a/src/corelib/global/qconfig-medium.h b/src/corelib/global/qconfig-medium.h
index b52b067909..ba91303409 100644
--- a/src/corelib/global/qconfig-medium.h
+++ b/src/corelib/global/qconfig-medium.h
@@ -74,9 +74,6 @@
#ifndef QT_NO_IMAGEFORMAT_PPM
# define QT_NO_IMAGEFORMAT_PPM
#endif
-#ifndef QT_NO_IMAGE_TEXT
-# define QT_NO_IMAGE_TEXT
-#endif
#ifndef QT_NO_MOVIE
# define QT_NO_MOVIE
#endif
diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h
index 3244e01c9e..57aa26b381 100644
--- a/src/corelib/global/qconfig-minimal.h
+++ b/src/corelib/global/qconfig-minimal.h
@@ -141,9 +141,6 @@
#ifndef QT_NO_IMAGE_HEURISTIC_MASK
# define QT_NO_IMAGE_HEURISTIC_MASK
#endif
-#ifndef QT_NO_IMAGE_TEXT
-# define QT_NO_IMAGE_TEXT
-#endif
#ifndef QT_NO_MOVIE
# define QT_NO_MOVIE
#endif
diff --git a/src/corelib/global/qconfig-nacl.h b/src/corelib/global/qconfig-nacl.h
index 69980f97a6..7e48afaee3 100644
--- a/src/corelib/global/qconfig-nacl.h
+++ b/src/corelib/global/qconfig-nacl.h
@@ -105,9 +105,6 @@
#ifndef QT_NO_IMAGE_HEURISTIC_MASK
# define QT_NO_IMAGE_HEURISTIC_MASK
#endif
-#ifndef QT_NO_IMAGE_TEXT
-# define QT_NO_IMAGE_TEXT
-#endif
#ifndef QT_NO_MOVIE
# define QT_NO_MOVIE
#endif
diff --git a/src/corelib/global/qconfig-small.h b/src/corelib/global/qconfig-small.h
index e764285e4a..0c0e6aa01a 100644
--- a/src/corelib/global/qconfig-small.h
+++ b/src/corelib/global/qconfig-small.h
@@ -105,9 +105,6 @@
#ifndef QT_NO_IMAGEFORMAT_XPM
# define QT_NO_IMAGEFORMAT_XPM
#endif
-#ifndef QT_NO_IMAGE_TEXT
-# define QT_NO_IMAGE_TEXT
-#endif
#ifndef QT_NO_MOVIE
# define QT_NO_MOVIE
#endif
diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h
index 4ce586a858..54c1be8bd3 100644
--- a/src/corelib/global/qfeatures.h
+++ b/src/corelib/global/qfeatures.h
@@ -118,9 +118,6 @@
// QImage::createHeuristicMask()
//#define QT_NO_IMAGE_HEURISTIC_MASK
-// Image Text
-//#define QT_NO_IMAGE_TEXT
-
// QLCDNumber
//#define QT_NO_LCDNUMBER
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 38ddd7bf97..966d66a038 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -72,7 +72,7 @@
# include <envLib.h>
#endif
-#if defined(Q_OS_MACX) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
#include <CoreServices/CoreServices.h>
#endif
@@ -126,7 +126,7 @@ QT_BEGIN_NAMESPACE
Qt::Alignment parameter, which means that any combination of
Qt::AlignmentFlag values,or 0, is legal:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 0
+ \snippet code/src_corelib_global_qglobal.cpp 0
If you try to pass a value from another enum or just a plain
integer other than 0, the compiler will report an error. If you
@@ -138,7 +138,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 1
+ \snippet code/src_corelib_global_qglobal.cpp 1
You can then use the \c MyClass::Options type to store
combinations of \c MyClass::Option values.
@@ -150,7 +150,7 @@ QT_BEGIN_NAMESPACE
To make the flags available for these purposes, the Q_FLAGS() macro must
be used:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp meta-object flags
+ \snippet code/src_corelib_global_qglobal.cpp meta-object flags
\section1 Naming Convention
@@ -353,18 +353,18 @@ QT_BEGIN_NAMESPACE
The curious user will have seen that the Qt classes derived
from QObject typically include this macro in a private section:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 43
+ \snippet code/src_corelib_global_qglobal.cpp 43
It declares a copy constructor and an assignment operator in the
private section, so that if you use them by mistake, the compiler
will report an error.
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 44
+ \snippet code/src_corelib_global_qglobal.cpp 44
But even this might not catch absolutely every case. You might be
tempted to do something like this:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 45
+ \snippet code/src_corelib_global_qglobal.cpp 45
First of all, don't do that. Most compilers will generate code that
uses the copy constructor, so the privacy violation error will be
@@ -382,7 +382,7 @@ QT_BEGIN_NAMESPACE
The Q_DECLARE_FLAGS() macro expands to
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 2
+ \snippet code/src_corelib_global_qglobal.cpp 2
\a Enum is the name of an existing enum type, whereas \a Flags is
the name of the QFlags<\e{Enum}> typedef.
@@ -461,7 +461,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 3
+ \snippet code/src_corelib_global_qglobal.cpp 3
<QtGlobal> also contains functions that generate messages from the
given string argument: qCritical(), qDebug(), qFatal() and
@@ -470,7 +470,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 4
+ \snippet code/src_corelib_global_qglobal.cpp 4
The remaining functions are qRound() and qRound64(), which both
accept a \l qreal value as their argument returning the value
@@ -532,22 +532,6 @@ QT_BEGIN_NAMESPACE
Convenience typedef for \c{unsigned char}.
*/
-/*!
- \fn qt_set_sequence_auto_mnemonic(bool on)
- \relates <QtGlobal>
-
- Enables automatic mnemonics on Mac if \a on is true; otherwise
- this feature is disabled.
-
- Note that this function is only available on Mac where mnemonics
- are disabled by default.
-
- To access to this function, use an extern declaration:
- extern void qt_set_sequence_auto_mnemonic(bool b);
-
- \sa {QShortcut#mnemonic}{QShortcut}
-*/
-
/*! \typedef ushort
\relates <QtGlobal>
@@ -619,7 +603,7 @@ QT_BEGIN_NAMESPACE
Literals of this type can be created using the Q_INT64_C() macro:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 5
+ \snippet code/src_corelib_global_qglobal.cpp 5
\sa Q_INT64_C(), quint64, qlonglong
*/
@@ -635,7 +619,7 @@ QT_BEGIN_NAMESPACE
Literals of this type can be created using the Q_UINT64_C()
macro:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 6
+ \snippet code/src_corelib_global_qglobal.cpp 6
\sa Q_UINT64_C(), qint64, qulonglong
*/
@@ -712,7 +696,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 8
+ \snippet code/src_corelib_global_qglobal.cpp 8
\sa qint64, Q_UINT64_C()
*/
@@ -725,7 +709,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 9
+ \snippet code/src_corelib_global_qglobal.cpp 9
\sa quint64, Q_INT64_C()
*/
@@ -758,7 +742,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 10
+ \snippet code/src_corelib_global_qglobal.cpp 10
*/
/*! \fn int qRound(qreal value)
@@ -768,7 +752,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 11
+ \snippet code/src_corelib_global_qglobal.cpp 11
*/
/*! \fn qint64 qRound64(qreal value)
@@ -778,7 +762,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 12
+ \snippet code/src_corelib_global_qglobal.cpp 12
*/
/*! \fn const T &qMin(const T &value1, const T &value2)
@@ -788,7 +772,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 13
+ \snippet code/src_corelib_global_qglobal.cpp 13
\sa qMax(), qBound()
*/
@@ -800,7 +784,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 14
+ \snippet code/src_corelib_global_qglobal.cpp 14
\sa qMin(), qBound()
*/
@@ -813,7 +797,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 15
+ \snippet code/src_corelib_global_qglobal.cpp 15
\sa qMin(), qMax()
*/
@@ -843,7 +827,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 16
+ \snippet code/src_corelib_global_qglobal.cpp 16
\sa QT_VERSION_STR, qVersion()
*/
@@ -1602,7 +1586,7 @@ static const unsigned int qt_one = 1;
const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian);
#endif
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
QT_BEGIN_INCLUDE_NAMESPACE
#include "private/qcore_mac_p.h"
@@ -1624,13 +1608,13 @@ Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding e
Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) {
return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding()));
}
-#endif // defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#endif // defined(Q_OS_MAC) && !defined(Q_OS_IOS)
#if defined(Q_OS_MAC)
QSysInfo::MacVersion QSysInfo::macVersion()
{
-#ifndef QT_NO_CORESERVICES
+#ifndef Q_OS_IOS
SInt32 gestalt_version;
if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2);
@@ -1769,12 +1753,12 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 17
+ \snippet code/src_corelib_global_qglobal.cpp 17
If \c b is zero, the Q_ASSERT statement will output the following
message using the qFatal() function:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 18
+ \snippet code/src_corelib_global_qglobal.cpp 18
\sa Q_ASSERT_X(), qFatal(), {Debugging Techniques}
*/
@@ -1792,12 +1776,12 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 19
+ \snippet code/src_corelib_global_qglobal.cpp 19
If \c b is zero, the Q_ASSERT_X statement will output the following
message using the qFatal() function:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 20
+ \snippet code/src_corelib_global_qglobal.cpp 20
\sa Q_ASSERT(), qFatal(), {Debugging Techniques}
*/
@@ -1812,7 +1796,7 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
conditions that it would not otherwise know about. However, there is no
guarantee that the compiler will actually use those hints.
- This macro could be considered a "lighter" version of \ref Q_ASSERT. While
+ This macro could be considered a "lighter" version of \l{Q_ASSERT}. While
Q_ASSERT will abort the program's execution if the condition is false,
Q_ASSUME will tell the compiler not to generate code for those conditions.
Therefore, it is important that the assumptions always hold, otherwise
@@ -1841,11 +1825,11 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
This macro is useful to mark impossible conditions. For example, given the
following enum:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qunreachable-enum
+ \snippet code/src_corelib_global_qglobal.cpp qunreachable-enum
One can write a switch table like so:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qunreachable-switch
+ \snippet code/src_corelib_global_qglobal.cpp qunreachable-switch
The advantage of inserting Q_UNREACHABLE() at that point is that the
compiler is told not to generate code for a shape variable containing that
@@ -1872,7 +1856,7 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 21
+ \snippet code/src_corelib_global_qglobal.cpp 21
\sa qWarning(), {Debugging Techniques}
*/
@@ -1896,7 +1880,7 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
Q_FUNC_INFO can be conveniently used with qDebug(). For example, this function:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 22
+ \snippet code/src_corelib_global_qglobal.cpp 22
when instantiated with the integer type, will with the GCC compiler produce:
@@ -2217,14 +2201,14 @@ int qrand()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 31
+ \snippet code/src_corelib_global_qglobal.cpp 31
It is equivalent to \c{for (;;)}.
If you're worried about namespace pollution, you can disable this
macro by adding the following line to your \c .pro file:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 32
+ \snippet code/src_corelib_global_qglobal.cpp 32
\sa Q_FOREVER
*/
@@ -2254,7 +2238,7 @@ int qrand()
If you're worried about namespace pollution, you can disable this
macro by adding the following line to your \c .pro file:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 33
+ \snippet code/src_corelib_global_qglobal.cpp 33
\sa Q_FOREACH()
*/
@@ -2283,7 +2267,7 @@ int qrand()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 34
+ \snippet code/src_corelib_global_qglobal.cpp 34
The macro QT_TR_NOOP_UTF8() is identical except that it tells lupdate
that the source string is encoded in UTF-8. Corresponding variants
@@ -2305,7 +2289,7 @@ int qrand()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 35
+ \snippet code/src_corelib_global_qglobal.cpp 35
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), {Internationalization with Qt}
*/
@@ -2326,7 +2310,7 @@ int qrand()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 36
+ \snippet code/src_corelib_global_qglobal.cpp 36
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), {Internationalization with Qt}
*/
@@ -2354,11 +2338,11 @@ int qrand()
or
- \tt{\begincomment% <C string> \endcomment}
+ \tt{\\begincomment% <C string> \\endcomment}
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qttrid
+ \snippet code/src_corelib_global_qglobal.cpp qttrid
Creating QM files suitable for use with this function requires passing
the \c -idbased option to the \c lrelease tool.
@@ -2385,7 +2369,7 @@ int qrand()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qttrid_noop
+ \snippet code/src_corelib_global_qglobal.cpp qttrid_noop
\sa qtTrId(), {Internationalization with Qt}
*/
@@ -2402,7 +2386,7 @@ int qrand()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qlikely
+ \snippet code/src_corelib_global_qglobal.cpp qlikely
\sa Q_UNLIKELY()
*/
@@ -2419,7 +2403,7 @@ int qrand()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qunlikely
+ \snippet code/src_corelib_global_qglobal.cpp qunlikely
\sa Q_LIKELY()
*/
@@ -2496,7 +2480,7 @@ int qrand()
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 37
+ \snippet code/src_corelib_global_qglobal.cpp 37
\sa qDebug(), qWarning(), qCritical(), qFatal()
@@ -2528,7 +2512,7 @@ int qrand()
Example of a "primitive" type:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 38
+ \snippet code/src_corelib_global_qglobal.cpp 38
An example of a non-POD "primitive" type is QUuid: Even though
QUuid has constructors (and therefore isn't POD), every bit
@@ -2537,7 +2521,7 @@ int qrand()
Example of a movable type:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 39
+ \snippet code/src_corelib_global_qglobal.cpp 39
*/
/*!
@@ -2607,7 +2591,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Use this macro as in the following examples.
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 40
+ \snippet code/src_corelib_global_qglobal.cpp 40
\sa Q_BIG_ENDIAN, Q_LITTLE_ENDIAN
*/
@@ -2622,7 +2606,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
lowest address. The other bytes follow in increasing order of
significance.
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 41
+ \snippet code/src_corelib_global_qglobal.cpp 41
\sa Q_BYTE_ORDER, Q_BIG_ENDIAN
*/
@@ -2637,7 +2621,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
lowest address. The other bytes follow in decreasing order of
significance.
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 42
+ \snippet code/src_corelib_global_qglobal.cpp 42
\sa Q_BYTE_ORDER, Q_LITTLE_ENDIAN
*/
@@ -2720,7 +2704,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
This macro expands to
- \snippet snippets/code/src_corelib_global_qglobal.cpp begin namespace macro
+ \snippet code/src_corelib_global_qglobal.cpp begin namespace macro
if \c QT_NAMESPACE is defined and nothing otherwise. If should always
appear in the file-level scope and be followed by \c QT_END_NAMESPACE
@@ -2754,7 +2738,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
This macro expands to
- \snippet snippets/code/src_corelib_global_qglobal.cpp end namespace macro
+ \snippet code/src_corelib_global_qglobal.cpp end namespace macro
if \c QT_NAMESPACE is defined and nothing otherwise. It is used to cancel
the effect of \c QT_BEGIN_NAMESPACE.
@@ -2821,7 +2805,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Note that comparing values where either \a p1 or \a p2 is 0.0 will not work.
The solution to this is to compare against values greater than or equal to 1.0.
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 46
+ \snippet code/src_corelib_global_qglobal.cpp 46
The two numbers are compared in a relative way, where the
exactness is stronger the smaller the numbers are.
@@ -2856,7 +2840,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Example:
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 4
+ \snippet code/src_gui_dialogs_qmessagebox.cpp 4
*/
/*!
@@ -2908,12 +2892,12 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 24
+ \snippet code/src_corelib_global_qglobal.cpp 24
If you include \c <QtDebug>, a more convenient syntax is also
available:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 25
+ \snippet code/src_corelib_global_qglobal.cpp 25
With this syntax, the function returns a QDebug object that is
configured to use the QtDebugMsg message type. It automatically
@@ -2943,12 +2927,12 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
string.
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 26
+ \snippet code/src_corelib_global_qglobal.cpp 26
If you include <QtDebug>, a more convenient syntax is
also available:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 27
+ \snippet code/src_corelib_global_qglobal.cpp 27
This syntax inserts a space between each item, and
appends a newline at the end.
@@ -2973,12 +2957,12 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
string.
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 28
+ \snippet code/src_corelib_global_qglobal.cpp 28
If you include <QtDebug>, a more convenient syntax is
also available:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 29
+ \snippet code/src_corelib_global_qglobal.cpp 29
A space is inserted between the items, and a newline is
appended at the end.
@@ -3007,7 +2991,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
similar to the C printf() function.
Example:
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 30
+ \snippet code/src_corelib_global_qglobal.cpp 30
To suppress the output at runtime, install your own message handler
with qInstallMessageHandler().
@@ -3016,110 +3000,4 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
{Debugging Techniques}
*/
-/*!
- \typedef QtMsgHandler
- \relates <QtGlobal>
- \deprecated
-
- This is a typedef for a pointer to a function with the following
- signature:
-
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 7
-
- This typedef is deprecated, you should use QtMessageHandler instead.
- \sa QtMsgType, QtMessageHandler, qInstallMsgHandler(), qInstallMessageHandler()
-*/
-
-/*!
- \typedef QtMessageHandler
- \relates <QtGlobal>
- \since 5.0
-
- This is a typedef for a pointer to a function with the following
- signature:
-
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 49
-
- \sa QtMsgType, qInstallMessageHandler()
-*/
-
-/*!
- \fn QtMessageHandler qInstallMessageHandler(QtMessageHandler handler)
- \relates <QtGlobal>
- \since 5.0
-
- Installs a Qt message \a handler which has been defined
- previously. Returns a pointer to the previous message handler
- (which may be 0).
-
- The message handler is a function that prints out debug messages,
- warnings, critical and fatal error messages. The Qt library (debug
- mode) contains hundreds of warning messages that are printed
- when internal errors (usually invalid function arguments)
- occur. Qt built in release mode also contains such warnings unless
- QT_NO_WARNING_OUTPUT and/or QT_NO_DEBUG_OUTPUT have been set during
- compilation. If you implement your own message handler, you get total
- control of these messages.
-
- The default message handler prints the message to the standard
- output under X11 or to the debugger under Windows. If it is a
- fatal message, the application aborts immediately.
-
- Only one message handler can be defined, since this is usually
- done on an application-wide basis to control debug output.
-
- To restore the message handler, call \c qInstallMessageHandler(0).
-
- Example:
-
- \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 23
-
- \sa QtMessageHandler, QtMsgType, qDebug(), qWarning(), qCritical(), qFatal(),
- {Debugging Techniques}
-*/
-
-/*!
- \fn QtMsgHandler qInstallMsgHandler(QtMsgHandler handler)
- \relates <QtGlobal>
- \deprecated
-
- Installs a Qt message \a handler which has been defined
- previously. This method is deprecated, use qInstallMessageHandler
- instead.
- \sa QtMsgHandler, qInstallMessageHandler
-*/
-/*!
- \fn void qSetMessagePattern(const QString &pattern)
- \relates <QtGlobal>
- \since 5.0
-
- \brief Changes the output of the default message handler.
-
- Allows to tweak the output of qDebug(), qWarning(), qCritical() and qFatal().
-
- Following placeholders are supported:
-
- \table
- \header \li Placeholder \li Description
- \row \li \c %{appname} \li QCoreApplication::applicationName()
- \row \li \c %{file} \li Path to source file
- \row \li \c %{function} \li Function
- \row \li \c %{line} \li Line in source file
- \row \li \c %{message} \li The actual message
- \row \li \c %{pid} \li QCoreApplication::applicationPid()
- \row \li \c %{threadid} \li ID of current thread
- \row \li \c %{type} \li "debug", "warning", "critical" or "fatal"
- \endtable
-
- The default pattern is "%{message}".
-
- The pattern can also be changed at runtime by setting the QT_MESSAGE_PATTERN
- environment variable; if both qSetMessagePattern() is called and QT_MESSAGE_PATTERN is
- set, the environment variable takes precedence.
-
- qSetMessagePattern() has no effect if a custom message handler is installed.
-
- \sa qInstallMessageHandler, Debugging Techniques
- */
-
QT_END_NAMESPACE
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 0828a3dac3..a8547a3ab8 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -62,6 +62,10 @@
#include <QtCore/qconfig.h>
#endif
+/* These two macros makes it possible to turn the builtin line expander into a
+ * string literal. */
+#define QT_STRINGIFY2(x) #x
+#define QT_STRINGIFY(x) QT_STRINGIFY2(x)
#include <QtCore/qsystemdetection.h>
#include <QtCore/qcompilerdetection.h>
@@ -150,28 +154,6 @@ namespace QT_NAMESPACE {}
# define QT_LARGEFILE_SUPPORT 64
#endif
-#ifndef Q_PACKED
-# define Q_PACKED
-# undef Q_NO_PACKED_REFERENCE
-#endif
-
-#ifndef Q_LIKELY
-# define Q_LIKELY(x) (x)
-#endif
-#ifndef Q_UNLIKELY
-# define Q_UNLIKELY(x) (x)
-#endif
-#ifndef Q_ASSUME
-# define Q_ASSUME(expr)
-#endif
-#ifndef Q_UNREACHABLE
-# define Q_UNREACHABLE()
-#endif
-
-#ifndef Q_ALLOC_SIZE
-# define Q_ALLOC_SIZE(x)
-#endif
-
#ifndef Q_CONSTRUCTOR_FUNCTION
# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
namespace { \
@@ -194,14 +176,6 @@ namespace QT_NAMESPACE {}
# define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC)
#endif
-#ifndef Q_REQUIRED_RESULT
-# if defined(Q_CC_GNU)
-# define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result))
-# else
-# define Q_REQUIRED_RESULT
-# endif
-#endif
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -340,45 +314,6 @@ QT_END_INCLUDE_NAMESPACE
# endif
#endif
-/*
- Proper for-scoping in MIPSpro CC
-*/
-#ifndef QT_NO_KEYWORDS
-# if defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64))
-# define for if(0){}else for
-# endif
-#endif
-
-/*
- Workaround for static const members on MSVC++.
-*/
-
-#if defined(Q_CC_MSVC)
-# define QT_STATIC_CONST static
-# define QT_STATIC_CONST_IMPL
-#else
-# define QT_STATIC_CONST static const
-# define QT_STATIC_CONST_IMPL const
-#endif
-
-/*
- Warnings and errors when using deprecated methods
-*/
-#if defined(Q_CC_GNU) || defined(Q_CC_RVCT)
-# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
-#elif defined(Q_CC_MSVC)
-# define Q_DECL_DEPRECATED __declspec(deprecated)
-# if defined (Q_CC_INTEL)
-# define Q_DECL_VARIABLE_DEPRECATED
-# else
-# endif
-#else
-# define Q_DECL_DEPRECATED
-#endif
-#ifndef Q_DECL_VARIABLE_DEPRECATED
-# define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED
-#endif
-
#if defined(QT_NO_DEPRECATED)
# undef QT_DEPRECATED
# undef QT_DEPRECATED_VARIABLE
@@ -448,46 +383,10 @@ QT_END_INCLUDE_NAMESPACE
# define QT_FASTCALL
#endif
-#ifdef Q_COMPILER_NULLPTR
-# define Q_NULLPTR nullptr
-#else
-# 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
-# define Q_DECL_FINAL final
-# ifdef Q_COMPILER_DECLTYPE // required for class-level final to compile in qvariant_p.h
-# define Q_DECL_FINAL_CLASS final
-# else
-# define Q_DECL_FINAL_CLASS
-# endif
-#else
-# define Q_DECL_OVERRIDE
-# define Q_DECL_FINAL
-# define Q_DECL_FINAL_CLASS
-#endif
-
-#if defined(Q_COMPILER_ALIGNOF) && !defined(Q_ALIGNOF)
-# define Q_ALIGNOF(x) alignof(x)
-#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)
-# if defined(Q_CC_MINGW)
+# if defined(Q_CC_MINGW) && !defined(Q_OS_WIN64)
# define QT_ENSURE_STACK_ALIGNED_FOR_SSE __attribute__ ((force_align_arg_pointer))
# else
# define QT_ENSURE_STACK_ALIGNED_FOR_SSE
@@ -561,35 +460,6 @@ class QDataStream;
#define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE))
-#if defined(Q_OS_LINUX) && defined(Q_CC_RVCT)
-# define Q_DECL_EXPORT __attribute__((visibility("default")))
-# define Q_DECL_IMPORT __attribute__((visibility("default")))
-# define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
-#endif
-
-#ifndef Q_DECL_EXPORT
-# if defined(Q_OS_WIN) || defined(Q_CC_RVCT)
-# define Q_DECL_EXPORT __declspec(dllexport)
-# elif defined(QT_VISIBILITY_AVAILABLE)
-# define Q_DECL_EXPORT __attribute__((visibility("default")))
-# define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
-# endif
-# ifndef Q_DECL_EXPORT
-# define Q_DECL_EXPORT
-# endif
-#endif
-#ifndef Q_DECL_IMPORT
-# if defined(Q_OS_WIN) || defined(Q_CC_RVCT)
-# define Q_DECL_IMPORT __declspec(dllimport)
-# else
-# define Q_DECL_IMPORT
-# endif
-#endif
-#ifndef Q_DECL_HIDDEN
-# define Q_DECL_HIDDEN
-#endif
-
-
/*
Create Qt DLL if QT_DLL is defined (Windows only)
*/
@@ -764,58 +634,6 @@ class QDataStream;
# endif
#endif
-// Functions marked as Q_GUI_EXPORT_INLINE were exported and inlined by mistake.
-// Compilers like MinGW complain that the import attribute is ignored.
-#if defined(Q_CC_MINGW)
-# if defined(QT_BUILD_CORE_LIB)
-# define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
-# else
-# define Q_CORE_EXPORT_INLINE inline
-# endif
-# if defined(QT_BUILD_GUI_LIB)
-# define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
-# else
-# define Q_GUI_EXPORT_INLINE inline
-# endif
-# if defined(QT_BUILD_WIDGETS_LIB)
-# define Q_WIDGETS_EXPORT_INLINE Q_WIDGETS_EXPORT inline
-# else
-# define Q_WIDGETS_EXPORT_INLINE inline
-# endif
-# if defined(QT_BUILD_PLATFORMSUPPORT_LIB)
-# define Q_PLATFORMSUPPORT_EXPORT_INLINE Q_PLATFORMSUPPORT_EXPORT inline
-# else
-# define Q_PLATFORMSUPPORT_EXPORT_INLINE inline
-# endif
-# if defined(QT_BUILD_PRINTSUPPORT_LIB)
-# define Q_PRINTSUPPORT_EXPORT_INLINE Q_PRINTSUPPORT_EXPORT inline
-# else
-# define Q_PRINTSUPPORT_EXPORT_INLINE inline
-# endif
-# if defined(QT_BUILD_COMPAT_LIB)
-# define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline
-# else
-# define Q_COMPAT_EXPORT_INLINE inline
-# endif
-#elif defined(Q_CC_RVCT)
-// we force RVCT not to export inlines by passing --visibility_inlines_hidden
-// so we need to just inline it, rather than exporting and inlining
-// note: this affects the contents of the DEF files (ie. these functions do not appear)
-# define Q_CORE_EXPORT_INLINE inline
-# define Q_GUI_EXPORT_INLINE inline
-# define Q_WIDGETS_EXPORT_INLINE inline
-# define Q_PLATFORMSUPPORT_EXPORT_INLINE inline
-# define Q_PRINTSUPPORT_EXPORT_INLINE inline
-# define Q_COMPAT_EXPORT_INLINE inline
-#else
-# define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
-# define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
-# define Q_WIDGETS_EXPORT_INLINE Q_WIDGETS_EXPORT inline
-# define Q_PLATFORMSUPPORT_EXPORT_INLINE Q_PLATFORMSUPPORT_EXPORT inline
-# define Q_PRINTSUPPORT_EXPORT_INLINE Q_PRINTSUPPORT_EXPORT inline
-# define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline
-#endif
-
/*
No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
for Qt's internal unit tests. If you want slower loading times and more
@@ -896,6 +714,10 @@ inline void qUnused(T &x) { (void)x; }
class QString;
Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);
+
+#ifndef Q_CC_MSVC
+Q_NORETURN
+#endif
Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);
#if !defined(Q_ASSERT)
@@ -910,6 +732,9 @@ Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);
#define QT_NO_PAINT_DEBUG
#endif
+#ifndef Q_CC_MSVC
+Q_NORETURN
+#endif
Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line);
#if !defined(Q_ASSERT_X)
@@ -952,29 +777,6 @@ Q_CORE_EXPORT void qBadAlloc();
template <typename T>
inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
-#if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB)
-# define Q_FUNC_INFO __PRETTY_FUNCTION__
-#elif defined(_MSC_VER)
-# define Q_FUNC_INFO __FUNCSIG__
-#else
-# 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
- * string literal. */
-# define QT_STRINGIFY2(x) #x
-# define QT_STRINGIFY(x) QT_STRINGIFY2(x)
-# define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
-# endif
- /* The MIPSpro and RVCT compilers postpones macro expansion,
- and therefore macros must be in scope when being used. */
-# if !defined(Q_CC_MIPS) && !defined(Q_CC_RVCT)
-# undef QT_STRINGIFY2
-# undef QT_STRINGIFY
-# endif
-#endif
-
-
typedef void (*QFunctionPointer)();
#if !defined(Q_UNIMPLEMENTED)
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 8726c18689..52ffae5f98 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
One example of direct use is to forward errors that stem from a scripting language, e.g. QML:
- \snippet doc/src/snippets/code/qlogging/qloggingsnippet.cpp 1
+ \snippet code/qlogging/qlogging.cpp 1
\sa QMessageLogContext, qDebug(), qWarning(), qCritical(), qFatal()
*/
@@ -159,7 +159,6 @@ static void qt_message(QtMsgType msgType, const QMessageLogContext &context, con
}
#undef qDebug
-
void QMessageLogger::debug(const char *msg, ...)
{
va_list ap;
@@ -205,7 +204,6 @@ QDebug QMessageLogger::warning()
#endif
#undef qCritical
-
void QMessageLogger::critical(const char *msg, ...)
{
va_list ap;
@@ -225,12 +223,14 @@ QDebug QMessageLogger::critical()
#endif
#undef qFatal
-
void QMessageLogger::fatal(const char *msg, ...)
{
va_list ap;
va_start(ap, msg); // use variable arg list
qt_message(QtFatalMsg, context, msg, ap);
+#ifndef Q_CC_MSVC
+ Q_UNREACHABLE();
+#endif
va_end(ap);
}
@@ -729,6 +729,112 @@ void qWinMessageHandler2(QtMsgType t, const QMessageLogContext &context,
}
#endif
+/*!
+ \typedef QtMsgHandler
+ \relates <QtGlobal>
+ \deprecated
+
+ This is a typedef for a pointer to a function with the following
+ signature:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 7
+
+ This typedef is deprecated, you should use QtMessageHandler instead.
+ \sa QtMsgType, QtMessageHandler, qInstallMsgHandler(), qInstallMessageHandler()
+*/
+
+/*!
+ \typedef QtMessageHandler
+ \relates <QtGlobal>
+ \since 5.0
+
+ This is a typedef for a pointer to a function with the following
+ signature:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 49
+
+ \sa QtMsgType, qInstallMessageHandler()
+*/
+
+/*!
+ \fn QtMessageHandler qInstallMessageHandler(QtMessageHandler handler)
+ \relates <QtGlobal>
+ \since 5.0
+
+ Installs a Qt message \a handler which has been defined
+ previously. Returns a pointer to the previous message handler
+ (which may be 0).
+
+ The message handler is a function that prints out debug messages,
+ warnings, critical and fatal error messages. The Qt library (debug
+ mode) contains hundreds of warning messages that are printed
+ when internal errors (usually invalid function arguments)
+ occur. Qt built in release mode also contains such warnings unless
+ QT_NO_WARNING_OUTPUT and/or QT_NO_DEBUG_OUTPUT have been set during
+ compilation. If you implement your own message handler, you get total
+ control of these messages.
+
+ The default message handler prints the message to the standard
+ output under X11 or to the debugger under Windows. If it is a
+ fatal message, the application aborts immediately.
+
+ Only one message handler can be defined, since this is usually
+ done on an application-wide basis to control debug output.
+
+ To restore the message handler, call \c qInstallMessageHandler(0).
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 23
+
+ \sa QtMessageHandler, QtMsgType, qDebug(), qWarning(), qCritical(), qFatal(),
+ {Debugging Techniques}
+*/
+
+/*!
+ \fn QtMsgHandler qInstallMsgHandler(QtMsgHandler handler)
+ \relates <QtGlobal>
+ \deprecated
+
+ Installs a Qt message \a handler which has been defined
+ previously. This method is deprecated, use qInstallMessageHandler
+ instead.
+ \sa QtMsgHandler, qInstallMessageHandler
+*/
+/*!
+ \fn void qSetMessagePattern(const QString &pattern)
+ \relates <QtGlobal>
+ \since 5.0
+
+ \brief Changes the output of the default message handler.
+
+ Allows to tweak the output of qDebug(), qWarning(), qCritical() and qFatal().
+
+ Following placeholders are supported:
+
+ \table
+ \header \li Placeholder \li Description
+ \row \li \c %{appname} \li QCoreApplication::applicationName()
+ \row \li \c %{file} \li Path to source file
+ \row \li \c %{function} \li Function
+ \row \li \c %{line} \li Line in source file
+ \row \li \c %{message} \li The actual message
+ \row \li \c %{pid} \li QCoreApplication::applicationPid()
+ \row \li \c %{threadid} \li ID of current thread
+ \row \li \c %{type} \li "debug", "warning", "critical" or "fatal"
+ \endtable
+
+ The default pattern is "%{message}".
+
+ The pattern can also be changed at runtime by setting the QT_MESSAGE_PATTERN
+ environment variable; if both qSetMessagePattern() is called and QT_MESSAGE_PATTERN is
+ set, the environment variable takes precedence.
+
+ qSetMessagePattern() has no effect if a custom message handler is installed.
+
+ \sa qInstallMessageHandler, Debugging Techniques
+ */
+
QtMessageHandler qInstallMessageHandler(QtMessageHandler h)
{
if (!messageHandler)
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h
index ae388b0a38..8366a852ab 100644
--- a/src/corelib/global/qlogging.h
+++ b/src/corelib/global/qlogging.h
@@ -113,6 +113,10 @@ public:
__attribute__ ((format (printf, 2, 3)))
#endif
;
+
+#ifndef Q_CC_MSVC
+ Q_NORETURN
+#endif
void fatal(const char *msg, ...)
#if defined(Q_CC_GNU) && !defined(__INSURE__)
__attribute__ ((format (printf, 2, 3)))
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index c238e9a5f3..50f43e3c78 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -155,12 +155,12 @@ public:
RightButton = 0x00000002,
MidButton = 0x00000004, // ### Qt 6: remove me
MiddleButton = MidButton,
- XButton1 = 0x00000008,
- BackButton = XButton1,
+ BackButton = 0x00000008,
+ XButton1 = BackButton,
ExtraButton1 = XButton1,
- XButton2 = 0x00000010,
- ForwardButton = XButton2,
- ExtraButton2 = XButton2,
+ ForwardButton = 0x00000010,
+ XButton2 = ForwardButton,
+ ExtraButton2 = ForwardButton,
TaskButton = 0x00000020,
ExtraButton3 = TaskButton,
ExtraButton4 = 0x00000040,
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 881b55037d..a613eff6b2 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -219,7 +219,7 @@
\value ExtraButton21 The 24th non-wheel Mouse Button.
\value ExtraButton22 The 25th non-wheel Mouse Button.
\value ExtraButton23 The 26th non-wheel Mouse Button.
- \value ExtraButton44 The 27th non-wheel Mouse Button.
+ \value ExtraButton24 The 27th non-wheel Mouse Button.
\omitvalue MaxMouseButton
\omitvalue MouseButtonMask
@@ -230,7 +230,7 @@
actual 'Mouse Buttons', the device must be re-configured (using
the vendor's configuration tool).
- \sa KeyboardModifier Modifier
+ \sa KeyboardModifier, Modifier
*/
/*!
@@ -257,7 +257,7 @@
\note On Windows Keyboards, Qt::MetaModifier and Qt::Key_Meta are mapped
to the Windows key.
- \sa MouseButton Modifier
+ \sa MouseButton, Modifier
*/
/*!
@@ -278,7 +278,7 @@
point, not as a Qt Key.
\omitvalue MODIFIER_MASK
- \sa KeyboardModifier MouseButton
+ \sa KeyboardModifier, MouseButton
*/
/*!
@@ -542,7 +542,7 @@
arguments to store them in an event behind the scenes. If you try
to use a queued connection and get the error message:
- \snippet doc/src/snippets/code/doc_src_qnamespace.qdoc 0
+ \snippet code/doc_src_qnamespace.qdoc 0
Call qRegisterMetaType() to register the data type before you
establish the connection.
@@ -1981,8 +1981,6 @@
system supports it, a tool window can be decorated
with a somewhat lighter frame. It can also be
combined with Qt::FramelessWindowHint.
- \br
- \br
On Mac OS X, tool windows correspond to the
\l{http://developer.apple.com/documentation/Carbon/Conceptual/HandlingWindowsControls/hitb-wind_cont_concept/chapter_2_section_2.html}{Floating}
class of windows. This means that the window lives on a
@@ -2174,9 +2172,7 @@
should be taken over by the target application,
i.e., the source application should not delete
the data.
- \br
On X11 this value is used to do a move.
- \br
TargetMoveAction is not used on the Mac.
*/
@@ -2643,7 +2639,7 @@
for other strings (e.g.,
"\l{http://qt.nokia.com/doc/qq/qq09-mac-deployment.html}{Deploying Applications on Ma...}").
- \sa QAbstractItemView::textElideMode, QFontMetrics::elidedText(), AlignmentFlag QTabBar::elideMode
+ \sa QAbstractItemView::textElideMode, QFontMetrics::elidedText(), AlignmentFlag, QTabBar::elideMode
*/
/*!
@@ -2721,7 +2717,7 @@
INT_MIN, inclusive. For example, you can define custom priorities
as being relative to each other:
- \snippet doc/src/snippets/code/doc_src_qnamespace.cpp 1
+ \snippet code/doc_src_qnamespace.cpp 1
\sa QCoreApplication::postEvent()
*/
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index 04e0f19f06..109545c10e 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -39,6 +39,10 @@
**
****************************************************************************/
+#ifndef QGLOBAL_H
+# include <QtCore/qglobal.h>
+#endif
+
#ifndef QPROCESSORDETECTION_H
#define QPROCESSORDETECTION_H
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index db5775d021..94ff42a789 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -39,6 +39,10 @@
**
****************************************************************************/
+#ifndef QGLOBAL_H
+# include <QtCore/qglobal.h>
+#endif
+
#ifndef QSYSTEMDETECTION_H
#define QSYSTEMDETECTION_H
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index d6379bf0fe..9e89f9fdc0 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -113,7 +113,7 @@ win32 {
SOURCES += io/qsettings_mac.cpp
}
macx-*: {
- contains(QT_CONFIG, coreservices) {
+ !ios {
SOURCES += io/qstandardpaths_mac.cpp
} else {
SOURCES += io/qstandardpaths_unix.cpp
diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp
index 021698115c..6c10c6cb00 100644
--- a/src/corelib/io/qabstractfileengine.cpp
+++ b/src/corelib/io/qabstractfileengine.cpp
@@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE
For example:
- \snippet doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp 0
+ \snippet code/src_corelib_io_qabstractfileengine.cpp 0
When the handler is destroyed, it is automatically removed from Qt.
@@ -184,7 +184,7 @@ QAbstractFileEngine *qt_custom_file_engine_handler_create(const QString &path)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp 1
+ \snippet code/src_corelib_io_qabstractfileengine.cpp 1
\sa QAbstractFileEngine::create()
*/
@@ -461,7 +461,7 @@ bool QAbstractFileEngine::isSequential() const
This virtual function must be reimplemented by all subclasses.
- \sa setFileName() rmdir()
+ \sa setFileName(), rmdir()
*/
bool QAbstractFileEngine::remove()
{
@@ -515,7 +515,7 @@ bool QAbstractFileEngine::link(const QString &newName)
This virtual function must be reimplemented by all subclasses.
- \sa setFileName() rmdir() isRelativePath()
+ \sa setFileName(), rmdir(), isRelativePath()
*/
bool QAbstractFileEngine::mkdir(const QString &dirName, bool createParentDirectories) const
{
@@ -535,7 +535,7 @@ bool QAbstractFileEngine::mkdir(const QString &dirName, bool createParentDirecto
This virtual function must be reimplemented by all subclasses.
- \sa setFileName() remove() mkdir() isRelativePath()
+ \sa setFileName(), remove(), mkdir(), isRelativePath()
*/
bool QAbstractFileEngine::rmdir(const QString &dirName, bool recurseParentDirectories) const
{
@@ -671,7 +671,7 @@ QString QAbstractFileEngine::fileName(FileName file) const
This virtual function must be reimplemented by all subclasses.
- \sa owner() setFileName(), FileOwner
+ \sa owner(), setFileName(), FileOwner
*/
uint QAbstractFileEngine::ownerId(FileOwner owner) const
{
@@ -687,7 +687,7 @@ uint QAbstractFileEngine::ownerId(FileOwner owner) const
This virtual function must be reimplemented by all subclasses.
- \sa ownerId() setFileName(), FileOwner
+ \sa ownerId(), setFileName(), FileOwner
*/
QString QAbstractFileEngine::owner(FileOwner owner) const
{
@@ -821,7 +821,7 @@ bool QAbstractFileEngine::unmap(uchar *address)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp 2
+ \snippet code/src_corelib_io_qabstractfileengine.cpp 2
QAbstractFileEngineIterator is associated with a path, name filters, and
entry filters. The path is the directory that the iterator lists entries
@@ -846,7 +846,7 @@ bool QAbstractFileEngine::unmap(uchar *address)
Here is an example of how to implement an iterator that returns each of
three fixed entries in sequence.
- \snippet doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp 3
+ \snippet code/src_corelib_io_qabstractfileengine.cpp 3
Note: QAbstractFileEngineIterator does not deal with QDir::IteratorFlags;
it simply returns entries for a single directory.
@@ -1080,7 +1080,7 @@ qint64 QAbstractFileEngine::write(const char *data, qint64 len)
}
/*!
- This function reads one line, terminated by a '\n' character, from the
+ This function reads one line, terminated by a '\\n' character, from the
file info \a data. At most \a maxlen characters will be read. The
end-of-line character is included.
*/
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp
index dfc85a434d..dee4295966 100644
--- a/src/corelib/io/qbuffer.cpp
+++ b/src/corelib/io/qbuffer.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qbuffer.h"
+#include <QtCore/qmetaobject.h>
#include "private/qiodevice_p.h"
QT_BEGIN_NAMESPACE
@@ -112,7 +113,7 @@ QByteArray QBufferPrivate::peek(qint64 maxSize)
interface. The QByteArray is treated just as a standard random-accessed
file. Example:
- \snippet doc/src/snippets/buffer/buffer.cpp 0
+ \snippet buffer/buffer.cpp 0
By default, an internal QByteArray buffer is created for you when
you create a QBuffer. You can access this buffer directly by
@@ -130,12 +131,12 @@ QByteArray QBufferPrivate::peek(qint64 maxSize)
The following code snippet shows how to write data to a
QByteArray using QDataStream and QBuffer:
- \snippet doc/src/snippets/buffer/buffer.cpp 1
+ \snippet buffer/buffer.cpp 1
Effectively, we convert the application's QPalette into a byte
array. Here's how to read the data from the QByteArray:
- \snippet doc/src/snippets/buffer/buffer.cpp 2
+ \snippet buffer/buffer.cpp 2
QTextStream and QDataStream also provide convenience constructors
that take a QByteArray and that create a QBuffer behind the
@@ -194,7 +195,7 @@ QBuffer::QBuffer(QObject *parent)
Example:
- \snippet doc/src/snippets/buffer/buffer.cpp 3
+ \snippet buffer/buffer.cpp 3
\sa open(), setBuffer(), setData()
*/
@@ -230,7 +231,7 @@ QBuffer::~QBuffer()
Example:
- \snippet doc/src/snippets/buffer/buffer.cpp 4
+ \snippet buffer/buffer.cpp 4
If \a byteArray is 0, the buffer creates its own internal
QByteArray to work on. This byte array is initially empty.
@@ -459,9 +460,11 @@ qint64 QBuffer::writeData(const char *data, qint64 len)
\reimp
\internal
*/
-void QBuffer::connectNotify(const char *signal)
+void QBuffer::connectNotify(const QMetaMethod &signal)
{
- if (strcmp(signal + 1, "readyRead()") == 0 || strcmp(signal + 1, "bytesWritten(qint64)") == 0)
+ static const QMetaMethod readyReadSignal = QMetaMethod::fromSignal(&QBuffer::readyRead);
+ static const QMetaMethod bytesWrittenSignal = QMetaMethod::fromSignal(&QBuffer::bytesWritten);
+ if (signal == readyReadSignal || signal == bytesWrittenSignal)
d_func()->signalConnectionCount++;
}
@@ -469,10 +472,16 @@ void QBuffer::connectNotify(const char *signal)
\reimp
\internal
*/
-void QBuffer::disconnectNotify(const char *signal)
+void QBuffer::disconnectNotify(const QMetaMethod &signal)
{
- if (!signal || strcmp(signal + 1, "readyRead()") == 0 || strcmp(signal + 1, "bytesWritten(qint64)") == 0)
- d_func()->signalConnectionCount--;
+ if (signal.isValid()) {
+ static const QMetaMethod readyReadSignal = QMetaMethod::fromSignal(&QBuffer::readyRead);
+ static const QMetaMethod bytesWrittenSignal = QMetaMethod::fromSignal(&QBuffer::bytesWritten);
+ if (signal == readyReadSignal || signal == bytesWrittenSignal)
+ d_func()->signalConnectionCount--;
+ } else {
+ d_func()->signalConnectionCount = 0;
+ }
}
#endif
diff --git a/src/corelib/io/qbuffer.h b/src/corelib/io/qbuffer.h
index 8b42363f24..ffbc554ec4 100644
--- a/src/corelib/io/qbuffer.h
+++ b/src/corelib/io/qbuffer.h
@@ -88,8 +88,8 @@ public:
protected:
#ifndef QT_NO_QOBJECT
- void connectNotify(const char*);
- void disconnectNotify(const char*);
+ void connectNotify(const QMetaMethod &);
+ void disconnectNotify(const QMetaMethod &);
#endif
qint64 readData(char *data, qint64 maxlen);
qint64 writeData(const char *data, qint64 len);
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 1fe2a793a6..bb12bc1c5b 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -81,11 +81,11 @@ QT_BEGIN_NAMESPACE
Example (write binary data to a stream):
- \snippet doc/src/snippets/code/src_corelib_io_qdatastream.cpp 0
+ \snippet code/src_corelib_io_qdatastream.cpp 0
Example (read binary data from a stream):
- \snippet doc/src/snippets/code/src_corelib_io_qdatastream.cpp 1
+ \snippet code/src_corelib_io_qdatastream.cpp 1
Each item written to the stream is written in a predefined binary
format that varies depending on the item's type. Supported Qt
@@ -119,7 +119,7 @@ QT_BEGIN_NAMESPACE
compatibility, you can hardcode the version number in the
application:
- \snippet doc/src/snippets/code/src_corelib_io_qdatastream.cpp 2
+ \snippet code/src_corelib_io_qdatastream.cpp 2
If you are producing a new binary data format, such as a file
format for documents created by your application, you could use a
@@ -127,11 +127,11 @@ QT_BEGIN_NAMESPACE
would write a brief header containing a magic string and a version
number to give yourself room for future expansion. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qdatastream.cpp 3
+ \snippet code/src_corelib_io_qdatastream.cpp 3
Then read it in with:
- \snippet doc/src/snippets/code/src_corelib_io_qdatastream.cpp 4
+ \snippet code/src_corelib_io_qdatastream.cpp 4
You can select which byte order to use when serializing data. The
default setting is big endian (MSB first). Changing it to little
@@ -187,7 +187,7 @@ QT_BEGIN_NAMESPACE
defined, check the \b {Related Non-Members} section of the
class's documentation page.
- \sa QTextStream QVariant
+ \sa QTextStream, QVariant
*/
/*!
@@ -253,9 +253,6 @@ enum {
DefaultStreamVersion = QDataStream::Qt_5_0
};
-// ### 5.0: when streaming invalid QVariants, just the type should
-// be written, no "data" after it
-
/*!
Constructs a data stream that has no I/O device.
@@ -421,7 +418,7 @@ bool QDataStream::atEnd() const
\since 4.6
- \sa FloatingPointPrecision setFloatingPointPrecision()
+ \sa FloatingPointPrecision, setFloatingPointPrecision()
*/
QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const
{
@@ -455,7 +452,7 @@ void QDataStream::setFloatingPointPrecision(QDataStream::FloatingPointPrecision
/*!
Returns the status of the data stream.
- \sa Status setStatus() resetStatus()
+ \sa Status, setStatus(), resetStatus()
*/
QDataStream::Status QDataStream::status() const
@@ -466,7 +463,7 @@ QDataStream::Status QDataStream::status() const
/*!
Resets the status of the data stream.
- \sa Status status() setStatus()
+ \sa Status, status(), setStatus()
*/
void QDataStream::resetStatus()
{
@@ -479,7 +476,7 @@ void QDataStream::resetStatus()
Subsequent calls to setStatus() are ignored until resetStatus()
is called.
- \sa Status status() resetStatus()
+ \sa Status, status(), resetStatus()
*/
void QDataStream::setStatus(Status status)
{
@@ -540,7 +537,7 @@ void QDataStream::setByteOrder(ByteOrder bo)
\value Qt_4_7 Same as Qt_4_6.
\value Qt_4_8 Same as Qt_4_6.
\value Qt_4_9 Same as Qt_4_6.
- \value Qt_5_0 Same as Qt_4_6.
+ \value Qt_5_0 Version 13 (Qt 5.0)
\sa setVersion(), version()
*/
@@ -589,7 +586,7 @@ void QDataStream::setByteOrder(ByteOrder bo)
The \l Version enum provides symbolic constants for the different
versions of Qt. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qdatastream.cpp 5
+ \snippet code/src_corelib_io_qdatastream.cpp 5
\sa version(), Version
*/
@@ -813,7 +810,7 @@ QDataStream &QDataStream::operator>>(double &f)
/*!
\overload
- Reads the '\0'-terminated string \a s from the stream and returns
+ Reads the '\\0'-terminated string \a s from the stream and returns
a reference to the stream.
Space for the string is allocated using \c new -- the caller must
@@ -1094,7 +1091,7 @@ QDataStream &QDataStream::operator<<(double f)
/*!
\overload
- Writes the '\0'-terminated string \a s to the stream and returns a
+ Writes the '\\0'-terminated string \a s to the stream and returns a
reference to the stream.
The string is serialized using writeBytes().
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index 6726537842..a9d0fd4b3f 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -63,7 +63,7 @@
In the common case, it is useful to call the qDebug() function to obtain a
default QDebug object to use for writing debugging information.
- \snippet doc/src/snippets/qdebug/qdebugsnippet.cpp 1
+ \snippet qdebug/qdebugsnippet.cpp 1
This constructs a QDebug object using the constructor that accepts a QtMsgType
value of QtDebugMsg. Similarly, the qWarning(), qCritical() and qFatal()
@@ -80,7 +80,7 @@
most Qt value types. To add support for custom types, you need to implement a
streaming operator, as in the following example:
- \snippet doc/src/snippets/qdebug/qdebugsnippet.cpp 0
+ \snippet qdebug/qdebugsnippet.cpp 0
This is described in the \l{Debugging Techniques} and
\l{Creating Custom Qt Types#Making the Type Printable}{Creating Custom Qt Types}
@@ -251,7 +251,7 @@
/*!
\fn QDebug &QDebug::operator<<(const char *s)
- Writes the '\0'-terminated string, \a s, to the stream and returns a
+ Writes the '\\0'-terminated string, \a s, to the stream and returns a
reference to the stream.
*/
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 23bf3c5f4b..222192b11c 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -358,14 +358,14 @@ inline void QDirPrivate::initFileEngine()
Examples of absolute paths:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 0
+ \snippet code/src_corelib_io_qdir.cpp 0
On Windows, the second example above will be translated to
\c{C:\Documents and Settings} when used to access files.
Examples of relative paths:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 1
+ \snippet code/src_corelib_io_qdir.cpp 1
You can use the isRelative() or isAbsolute() functions to check if
a QDir is using a relative or an absolute file path. Call
@@ -382,7 +382,7 @@ inline void QDirPrivate::initFileEngine()
the location of the directory. However, it can also return "." if
the QDir represents the current directory.
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 2
+ \snippet code/src_corelib_io_qdir.cpp 2
The path for a directory can also be changed with the cd() and cdUp()
functions, both of which operate like familiar shell commands.
@@ -418,7 +418,7 @@ inline void QDirPrivate::initFileEngine()
file or directory. Neither of these functions checks for the
existence of files or directory; they only construct paths.
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 3
+ \snippet code/src_corelib_io_qdir.cpp 3
Files can be removed by using the remove() function. Directories
cannot be removed in the same way as files; use rmdir() to remove
@@ -490,19 +490,19 @@ inline void QDirPrivate::initFileEngine()
Check if a directory exists:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 4
+ \snippet code/src_corelib_io_qdir.cpp 4
(We could also use the static convenience function
QFile::exists().)
Traversing directories and reading a file:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 5
+ \snippet code/src_corelib_io_qdir.cpp 5
A program that lists all the files in the current directory
(excluding symbolic links), sorted by size, smallest first:
- \snippet doc/src/snippets/qdir-listfiles/main.cpp 0
+ \snippet qdir-listfiles/main.cpp 0
\sa QFileInfo, QFile, QFileDialog, QApplication::applicationDirPath(), {Find Files Example}
*/
@@ -630,7 +630,7 @@ QString QDir::absolutePath() const
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 6
+ \snippet code/src_corelib_io_qdir.cpp 6
\sa path(), absolutePath(), exists(), cleanPath(), dirName(),
absoluteFilePath()
@@ -669,7 +669,7 @@ QString QDir::dirName() const
be relative. Redundant multiple separators or "." and ".."
directories in \a fileName are not removed (see cleanPath()).
- \sa dirName() absoluteFilePath(), isRelative(), canonicalPath()
+ \sa dirName(), absoluteFilePath(), isRelative(), canonicalPath()
*/
QString QDir::filePath(const QString &fileName) const
{
@@ -692,7 +692,7 @@ QString QDir::filePath(const QString &fileName) const
exists(). Redundant multiple separators or "." and ".."
directories in \a fileName are not removed (see cleanPath()).
- \sa relativeFilePath() filePath() canonicalPath()
+ \sa relativeFilePath(), filePath(), canonicalPath()
*/
QString QDir::absoluteFilePath(const QString &fileName) const
{
@@ -711,9 +711,9 @@ QString QDir::absoluteFilePath(const QString &fileName) const
/*!
Returns the path to \a fileName relative to the directory.
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 7
+ \snippet code/src_corelib_io_qdir.cpp 7
- \sa absoluteFilePath() filePath() canonicalPath()
+ \sa absoluteFilePath(), filePath(), canonicalPath()
*/
QString QDir::relativeFilePath(const QString &fileName) const
{
@@ -941,7 +941,7 @@ QStringList QDir::nameFilters() const
to ensure that only files with extensions typically used for C++
source files are listed:
- \snippet doc/src/snippets/qdir-namefilters/main.cpp 0
+ \snippet qdir-namefilters/main.cpp 0
\sa nameFilters(), setFilter()
*/
@@ -988,7 +988,7 @@ void QDir::addResourceSearchPath(const QString &path)
Qt uses this search path to locate files with a known prefix. The search
path entries are tested in order, starting with the first entry.
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 8
+ \snippet code/src_corelib_io_qdir.cpp 8
File name prefix must be at least 2 characters long to avoid conflicts with
Windows drive letters.
@@ -1146,7 +1146,7 @@ void QDir::setFilter(Filters filters)
/*!
Returns the value set by setSorting()
- \sa setSorting() SortFlag
+ \sa setSorting(), SortFlag
*/
QDir::SortFlags QDir::sorting() const
{
@@ -1190,7 +1190,7 @@ QDir::SortFlags QDir::sorting() const
The \a sort is specified by OR-ing values from the enum
\l{QDir::SortFlag}.
- \sa sorting() SortFlag
+ \sa sorting(), SortFlag
*/
void QDir::setSorting(SortFlags sort)
{
@@ -1561,7 +1561,7 @@ bool QDir::exists() const
this function returns false. If you want to test for this use
canonicalPath(), e.g.
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 9
+ \snippet code/src_corelib_io_qdir.cpp 9
\sa root(), rootPath()
*/
@@ -1578,7 +1578,7 @@ bool QDir::isRoot() const
Returns true if the directory's path is absolute; otherwise
returns false. See isAbsolutePath().
- \sa isRelative() makeAbsolute() cleanPath()
+ \sa isRelative(), makeAbsolute(), cleanPath()
*/
/*!
@@ -1587,7 +1587,7 @@ bool QDir::isRoot() const
Returns true if \a path is absolute; returns false if it is
relative.
- \sa isAbsolute() isRelativePath() makeAbsolute() cleanPath()
+ \sa isAbsolute(), isRelativePath(), makeAbsolute(), cleanPath()
*/
/*!
@@ -1595,7 +1595,7 @@ bool QDir::isRoot() const
false. (Under Unix a path is relative if it does not start with a
"/").
- \sa makeAbsolute() isAbsolute() isAbsolutePath() cleanPath()
+ \sa makeAbsolute(), isAbsolute(), isAbsolutePath(), cleanPath()
*/
bool QDir::isRelative() const
{
@@ -1610,7 +1610,7 @@ bool QDir::isRelative() const
absolute nothing happens. Returns true if the conversion
succeeded; otherwise returns false.
- \sa isAbsolute() isAbsolutePath() isRelative() cleanPath()
+ \sa isAbsolute(), isAbsolutePath(), isRelative(), cleanPath()
*/
bool QDir::makeAbsolute()
{
@@ -1639,7 +1639,7 @@ bool QDir::makeAbsolute()
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 10
+ \snippet code/src_corelib_io_qdir.cpp 10
*/
bool QDir::operator==(const QDir &dir) const
{
@@ -1718,7 +1718,7 @@ QDir &QDir::operator=(const QString &path)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 11
+ \snippet code/src_corelib_io_qdir.cpp 11
*/
/*!
@@ -1873,7 +1873,7 @@ QString QDir::currentPath()
Under Windows this function will return the directory of the
current user's profile. Typically, this is:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 12
+ \snippet code/src_corelib_io_qdir.cpp 12
Use the toNativeSeparators() function to convert the separators to
the ones that are appropriate for the underlying operating system.
@@ -1966,7 +1966,7 @@ QString QDir::rootPath()
patterns in the list of \a filters; otherwise returns false. The
matching is case insensitive.
- \sa {QRegExp wildcard matching}, QRegExp::exactMatch() entryList() entryInfoList()
+ \sa {QRegExp wildcard matching}, QRegExp::exactMatch(), entryList(), entryInfoList()
*/
bool QDir::match(const QStringList &filters, const QString &fileName)
{
@@ -1984,7 +1984,7 @@ bool QDir::match(const QStringList &filters, const QString &fileName)
contain multiple patterns separated by spaces or semicolons.
The matching is case insensitive.
- \sa {QRegExp wildcard matching}, QRegExp::exactMatch() entryList() entryInfoList()
+ \sa {QRegExp wildcard matching}, QRegExp::exactMatch(), entryList(), entryInfoList()
*/
bool QDir::match(const QString &filter, const QString &fileName)
{
@@ -2001,7 +2001,7 @@ bool QDir::match(const QString &filter, const QString &fileName)
For example, "./local" becomes "local", "local/../bin" becomes
"bin" and "/local/usr/../bin" becomes "/local/bin".
- \sa absolutePath() canonicalPath()
+ \sa absolutePath(), canonicalPath()
*/
QString QDir::cleanPath(const QString &path)
{
@@ -2129,7 +2129,7 @@ QString QDir::cleanPath(const QString &path)
Returns true if \a path is relative; returns false if it is
absolute.
- \sa isRelative() isAbsolutePath() makeAbsolute()
+ \sa isRelative(), isAbsolutePath(), makeAbsolute()
*/
bool QDir::isRelativePath(const QString &path)
{
@@ -2181,7 +2181,7 @@ QStringList QDir::nameFiltersFromString(const QString &nameFilter)
initialized at startup by adding this line to your \c main()
function:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 13
+ \snippet code/src_corelib_io_qdir.cpp 13
If the file name contains characters that cannot be part of a valid C++ function name
(such as '-'), they have to be replaced by the underscore character ('_').
@@ -2190,7 +2190,7 @@ QStringList QDir::nameFiltersFromString(const QString &nameFilter)
main(). If that is not possible, the following workaround can be used
to init the resource \c myapp from the function \c{MyNamespace::myFunction}:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 14
+ \snippet code/src_corelib_io_qdir.cpp 14
\sa Q_CLEANUP_RESOURCE(), {The Qt Resource System}
*/
@@ -2213,7 +2213,7 @@ QStringList QDir::nameFiltersFromString(const QString &nameFilter)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 15
+ \snippet code/src_corelib_io_qdir.cpp 15
\sa Q_INIT_RESOURCE(), {The Qt Resource System}
*/
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 56912e8706..67ea1c9538 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -55,7 +55,7 @@
argument. After construction, the iterator is located before the first
directory entry. Here's how to iterate over all the entries sequentially:
- \snippet doc/src/snippets/code/src_corelib_io_qdiriterator.cpp 0
+ \snippet code/src_corelib_io_qdiriterator.cpp 0
The next() function returns the path to the next directory entry and
advances the iterator. You can also call filePath() to get the current
@@ -338,7 +338,8 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf
end = nameRegExps.constEnd();
iter != end; ++iter) {
- if (iter->exactMatch(fileName)) {
+ QRegExp copy = *iter;
+ if (copy.exactMatch(fileName)) {
matched = true;
break;
}
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 120c5a8c23..b3e3bdde53 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -170,7 +170,7 @@ QAbstractFileEngine *QFilePrivate::engine() const
The following example reads a text file line by line:
- \snippet doc/src/snippets/file/file.cpp 0
+ \snippet file/file.cpp 0
The QIODevice::Text flag passed to open() tells Qt to convert
Windows-style line terminators ("\\r\\n") into C++-style
@@ -182,7 +182,7 @@ QAbstractFileEngine *QFilePrivate::engine() const
The next example uses QTextStream to read a text file
line by line:
- \snippet doc/src/snippets/file/file.cpp 1
+ \snippet file/file.cpp 1
QTextStream takes care of converting the 8-bit data stored on
disk into a 16-bit Unicode QString. By default, it assumes that
@@ -194,7 +194,7 @@ QAbstractFileEngine *QFilePrivate::engine() const
take a QTextStream on the left and various data types (including
QString) on the right:
- \snippet doc/src/snippets/file/file.cpp 2
+ \snippet file/file.cpp 2
QDataStream is similar, in that you can use operator<<() to write
data and operator>>() to read it back. See the class
@@ -217,7 +217,7 @@ QAbstractFileEngine *QFilePrivate::engine() const
read() or readLine() repeatedly until no more data can be read. The next
example uses QTextStream to read \c /proc/modules line by line:
- \snippet doc/src/snippets/file/file.cpp 3
+ \snippet file/file.cpp 3
\section1 Signals
@@ -325,7 +325,7 @@ QString QFile::fileName() const
\e{at the time of the open()} call.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfile.cpp 0
+ \snippet code/src_corelib_io_qfile.cpp 0
Note that the directory separator "/" works for all operating
systems supported by Qt.
@@ -363,7 +363,7 @@ QFile::setFileName(const QString &name)
file names that the user chooses. File names hard-coded into the
application should only use 7-bit ASCII filename characters.
- \sa decodeName() setEncodingFunction()
+ \sa decodeName(), setEncodingFunction()
*/
QByteArray
@@ -378,7 +378,7 @@ QFile::encodeName(const QString &fileName)
This is a typedef for a pointer to a function with the following
signature:
- \snippet doc/src/snippets/code/src_corelib_io_qfile.cpp 1
+ \snippet code/src_corelib_io_qfile.cpp 1
\sa setEncodingFunction(), encodeName()
*/
@@ -420,7 +420,7 @@ QFile::setEncodingFunction(EncoderFn f)
This is a typedef for a pointer to a function with the following
signature:
- \snippet doc/src/snippets/code/src_corelib_io_qfile.cpp 2
+ \snippet code/src_corelib_io_qfile.cpp 2
\sa setDecodingFunction()
*/
@@ -485,7 +485,7 @@ QFile::exists(const QString &fileName)
This name may not represent an existing file; it is only a string.
QFile::exists() returns true if the symlink points to an existing file.
- \sa fileName() setFileName()
+ \sa fileName(), setFileName()
*/
/*!
@@ -896,7 +896,7 @@ bool QFile::open(OpenMode mode)
Returns true if successful; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfile.cpp 3
+ \snippet code/src_corelib_io_qfile.cpp 3
When a QFile is opened using this function, behaviour of close() is
controlled by the AutoCloseHandle flag.
@@ -930,7 +930,7 @@ bool QFile::open(OpenMode mode)
stdin, stdout and stderr streams at the console. To do this, add the
following declaration to your application's project file:
- \snippet doc/src/snippets/code/src_corelib_io_qfile.cpp 4
+ \snippet code/src_corelib_io_qfile.cpp 4
*/
bool QFile::open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
{
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 1805e759ab..1dcde0496d 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -244,14 +244,14 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request)
transparently; similarly, opening a symlink using QFile
effectively opens the link's target. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 0
+ \snippet code/src_corelib_io_qfileinfo.cpp 0
On Windows, symlinks (shortcuts) are \c .lnk files. The reported
size() is that of the symlink (not the link's target), and
opening a symlink using QFile opens the \c .lnk file. For
example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 1
+ \snippet code/src_corelib_io_qfileinfo.cpp 1
Elements of the file's name can be extracted with path() and
fileName(). The fileName()'s parts can be extracted with
@@ -442,7 +442,7 @@ QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo)
path relative to the current directory.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 2
+ \snippet code/src_corelib_io_qfileinfo.cpp 2
\sa isRelative(), QDir::setCurrent(), QDir::isRelativePath()
*/
@@ -496,7 +496,7 @@ void QFileInfo::setFile(const QDir &dir, const QString &file)
QFileInfo will uppercase drive letters. Note that QDir does not do
this. The code snippet below shows this.
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp newstuff
+ \snippet code/src_corelib_io_qfileinfo.cpp newstuff
This function returns the same as filePath(), unless isRelative()
is true. In contrast to canonicalFilePath(), symbolic links or
@@ -688,7 +688,7 @@ QString QFileInfo::filePath() const
Returns the name of the file, excluding the path.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 3
+ \snippet code/src_corelib_io_qfileinfo.cpp 3
Note that, if this QFileInfo object is given a path ending in a
slash, the name of the file is considered empty.
@@ -711,7 +711,7 @@ QString QFileInfo::fileName() const
path isBundle(). On all other platforms an empty QString is returned.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 4
+ \snippet code/src_corelib_io_qfileinfo.cpp 4
\sa isBundle(), filePath(), baseName(), extension()
*/
@@ -730,7 +730,7 @@ QString QFileInfo::bundleName() const
not including) the \e first '.' character.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 5
+ \snippet code/src_corelib_io_qfileinfo.cpp 5
The base name of a file is computed equally on all platforms, independent
@@ -754,7 +754,7 @@ QString QFileInfo::baseName() const
to (but not including) the \e last '.' character.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 6
+ \snippet code/src_corelib_io_qfileinfo.cpp 6
\sa fileName(), suffix(), completeSuffix(), baseName()
*/
@@ -773,7 +773,7 @@ QString QFileInfo::completeBaseName() const
(but not including) the first '.'.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 7
+ \snippet code/src_corelib_io_qfileinfo.cpp 7
\sa fileName(), suffix(), baseName(), completeBaseName()
*/
@@ -792,7 +792,7 @@ QString QFileInfo::completeSuffix() const
including) the last '.'.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 8
+ \snippet code/src_corelib_io_qfileinfo.cpp 8
The suffix of a file is computed equally on all platforms, independent of
file naming conventions (e.g., ".bashrc" on Unix has an empty base name,
@@ -818,12 +818,12 @@ QString QFileInfo::suffix() const
For each of the following, dir() returns a QDir for
\c{"~/examples/191697"}.
- \snippet doc/src/snippets/fileinfo/main.cpp 0
+ \snippet fileinfo/main.cpp 0
For each of the following, dir() returns a QDir for
\c{"."}.
- \snippet doc/src/snippets/fileinfo/main.cpp 1
+ \snippet fileinfo/main.cpp 1
\sa absolutePath(), filePath(), fileName(), isRelative(), absoluteDir()
*/
@@ -1010,7 +1010,7 @@ bool QFileInfo::isBundle() const
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 9
+ \snippet code/src_corelib_io_qfileinfo.cpp 9
\note If the symlink points to a non existing file, exists() returns
false.
@@ -1172,7 +1172,7 @@ uint QFileInfo::groupId() const
always returns true.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 10
+ \snippet code/src_corelib_io_qfileinfo.cpp 10
\sa isReadable(), isWritable(), isExecutable()
*/
@@ -1243,7 +1243,7 @@ qint64 QFileInfo::size() const
If neither creation time nor "last status change" time are not
available, returns the same as lastModified().
- \sa lastModified() lastRead()
+ \sa lastModified(), lastRead()
*/
QDateTime QFileInfo::created() const
{
@@ -1261,7 +1261,7 @@ QDateTime QFileInfo::created() const
/*!
Returns the date and time when the file was last modified.
- \sa created() lastRead()
+ \sa created(), lastRead()
*/
QDateTime QFileInfo::lastModified() const
{
@@ -1282,7 +1282,7 @@ QDateTime QFileInfo::lastModified() const
On platforms where this information is not available, returns the
same as lastModified().
- \sa created() lastModified()
+ \sa created(), lastModified()
*/
QDateTime QFileInfo::lastRead() const
{
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index 21436c1cfc..c2ac85bd80 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -259,7 +259,7 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
// Attributes
entryFlags |= QFileSystemMetaData::ExistsAttribute;
size_ = statBuffer.st_size;
-#if defined (Q_OS_MAC) && !defined(QT_NO_CORESERVICES) \
+#if defined (Q_OS_MAC) && !defined(Q_OS_IOS) \
&& MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (statBuffer.st_flags & UF_HIDDEN) {
entryFlags |= QFileSystemMetaData::HiddenAttribute;
diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h
index 17413d9c76..b5d28f9a5b 100644
--- a/src/corelib/io/qfilesystemengine_p.h
+++ b/src/corelib/io/qfilesystemengine_p.h
@@ -83,7 +83,7 @@ public:
static QString resolveGroupName(uint groupId);
#endif
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
static QString bundleName(const QFileSystemEntry &entry);
#else
static QString bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry) return QString(); }
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 00e116b58f..d1a0621cbe 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
static inline bool _q_isMacHidden(const char *nativePath)
{
OSErr err;
@@ -142,7 +142,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
ret.chop(1);
return QFileSystemEntry(ret);
}
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
{
FSRef fref;
if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) {
@@ -174,7 +174,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
#else
char *ret = 0;
-# if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+# if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
// Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here.
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) {
ret = realpath(entry.nativeFilePath().constData(), (char*)0);
@@ -192,7 +192,12 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
}
}
# else
+# if _POSIX_VERSION >= 200801L
ret = realpath(entry.nativeFilePath().constData(), (char*)0);
+# else
+ ret = (char*)malloc(PATH_MAX);
+ realpath(entry.nativeFilePath().constData(), (char*)ret);
+# endif
# endif
if (ret) {
data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
@@ -303,7 +308,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId)
return QString();
}
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
//static
QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
{
@@ -323,7 +328,7 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data,
QFileSystemMetaData::MetaDataFlags what)
{
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
if (what & QFileSystemMetaData::BundleType) {
if (!data.hasFlags(QFileSystemMetaData::DirectoryType))
what |= QFileSystemMetaData::DirectoryType;
@@ -334,7 +339,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
what |= QFileSystemMetaData::PosixStatFlags;
}
# endif // MAC_OS_X_VERSION_MAX_ALLOWED...
-#endif // defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#endif // defined(Q_OS_MAC) && !defined(Q_OS_IOS)
if (what & QFileSystemMetaData::PosixStatFlags)
what |= QFileSystemMetaData::PosixStatFlags;
@@ -395,7 +400,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
| QFileSystemMetaData::ExistsAttribute;
}
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
if (what & QFileSystemMetaData::AliasType)
{
if (entryExists) {
@@ -441,7 +446,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
}
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
if (what & QFileSystemMetaData::BundleType) {
if (entryExists && data.isDirectory()) {
QCFType<CFStringRef> path = CFStringCreateWithBytes(0,
diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h
index 6053b16752..3a53eb56e9 100644
--- a/src/corelib/io/qfilesystemmetadata_p.h
+++ b/src/corelib/io/qfilesystemmetadata_p.h
@@ -100,7 +100,7 @@ public:
LinkType = 0x00010000,
FileType = 0x00020000,
DirectoryType = 0x00040000,
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
BundleType = 0x00080000,
AliasType = 0x08000000,
#else
@@ -248,7 +248,7 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags)
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
inline bool QFileSystemMetaData::isBundle() const { return (entryFlags & BundleType); }
inline bool QFileSystemMetaData::isAlias() const { return (entryFlags & AliasType); }
#else
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 1cdfc61627..3c2da7fa85 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -215,7 +215,7 @@ QIODevicePrivate::~QIODevicePrivate()
Calling these functions from the main, GUI thread, may cause your
user interface to freeze. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qiodevice.cpp 0
+ \snippet code/src_corelib_io_qiodevice.cpp 0
By subclassing QIODevice, you can provide the same interface to
your own I/O devices. Subclasses of QIODevice are only required to
@@ -239,7 +239,7 @@ QIODevicePrivate::~QIODevicePrivate()
subclassing QIODevice, remember to bypass any buffer you may use
when the device is open in Unbuffered mode.
- \sa QBuffer QFile QTcpSocket
+ \sa QBuffer, QFile, QTcpSocket
*/
/*!
@@ -257,9 +257,9 @@ QIODevicePrivate::~QIODevicePrivate()
\value Truncate If possible, the device is truncated before it is opened.
All earlier contents of the device are lost.
\value Text When reading, the end-of-line terminators are
- translated to '\n'. When writing, the end-of-line
+ translated to '\\n'. When writing, the end-of-line
terminators are translated to the local encoding, for
- example '\r\n' for Win32.
+ example '\\r\\n' for Win32.
\value Unbuffered Any buffer in the device is bypassed.
Certain flags, such as \c Unbuffered and \c Truncate, are
@@ -431,7 +431,7 @@ QIODevice::OpenMode QIODevice::openMode() const
function to set the open mode if the flags change after the device
has been opened.
- \sa openMode() OpenMode
+ \sa openMode(), OpenMode
*/
void QIODevice::setOpenMode(OpenMode openMode)
{
@@ -484,7 +484,7 @@ bool QIODevice::isTextModeEnabled() const
default, this function returns false if openMode() returns
\c NotOpen.
- \sa openMode() OpenMode
+ \sa openMode(), OpenMode
*/
bool QIODevice::isOpen() const
{
@@ -498,7 +498,7 @@ bool QIODevice::isOpen() const
This is a convenience function which checks if the OpenMode of the
device contains the ReadOnly flag.
- \sa openMode() OpenMode
+ \sa openMode(), OpenMode
*/
bool QIODevice::isReadable() const
{
@@ -512,7 +512,7 @@ bool QIODevice::isReadable() const
This is a convenience function which checks if the OpenMode of the
device contains the WriteOnly flag.
- \sa openMode() OpenMode
+ \sa openMode(), OpenMode
*/
bool QIODevice::isWritable() const
{
@@ -524,7 +524,7 @@ bool QIODevice::isWritable() const
otherwise returns false. This function should be called from any
reimplementations of open() or other functions that open the device.
- \sa openMode() OpenMode
+ \sa openMode(), OpenMode
*/
bool QIODevice::open(OpenMode mode)
{
@@ -544,7 +544,7 @@ bool QIODevice::open(OpenMode mode)
First emits aboutToClose(), then closes the device and sets its
OpenMode to NotOpen. The error string is also reset.
- \sa setOpenMode() OpenMode
+ \sa setOpenMode(), OpenMode
*/
void QIODevice::close()
{
@@ -704,7 +704,7 @@ bool QIODevice::reset()
Subclasses that reimplement this function must call the base
implementation in order to include the size of QIODevices' buffer. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qiodevice.cpp 1
+ \snippet code/src_corelib_io_qiodevice.cpp 1
\sa bytesToWrite(), readyRead(), isSequential()
*/
@@ -745,7 +745,7 @@ qint64 QIODevice::bytesToWrite() const
function returns -1 in those cases (that is, reading on a closed
socket or after a process has died).
- \sa readData() readLine() write()
+ \sa readData(), readLine(), write()
*/
qint64 QIODevice::read(char *data, qint64 maxSize)
{
@@ -1032,13 +1032,13 @@ QByteArray QIODevice::readAll()
occurs, this function returns the length of what could be read, or
-1 if nothing was read.
- A terminating '\0' byte is always appended to \a data, so \a
+ A terminating '\\0' byte is always appended to \a data, so \a
maxSize must be larger than 1.
Data is read until either of the following conditions are met:
\list
- \li The first '\n' character is read.
+ \li The first '\\n' character is read.
\li \a maxSize - 1 bytes are read.
\li The end of the device data is detected.
\endlist
@@ -1046,12 +1046,12 @@ QByteArray QIODevice::readAll()
For example, the following code reads a line of characters from a
file:
- \snippet doc/src/snippets/code/src_corelib_io_qiodevice.cpp 2
+ \snippet code/src_corelib_io_qiodevice.cpp 2
- The newline character ('\n') is included in the buffer. If a
+ The newline character ('\\n') is included in the buffer. If a
newline is not encountered before maxSize - 1 bytes are read, a
newline will not be inserted into the buffer. On windows newline
- characters are replaced with '\n'.
+ characters are replaced with '\\n'.
This function calls readLineData(), which is implemented using
repeated calls to getChar(). You can provide a more efficient
@@ -1208,7 +1208,7 @@ QByteArray QIODevice::readLine(qint64 maxSize)
implementation, using getChar(). Buffered devices can improve the
performance of readLine() by reimplementing this function.
- readLine() appends a '\0' byte to \a data; readLineData() does not
+ readLine() appends a '\\0' byte to \a data; readLineData() does not
need to do this.
If you reimplement this function, be careful to return the correct
@@ -1258,7 +1258,7 @@ qint64 QIODevice::readLineData(char *data, qint64 maxSize)
Subclasses that reimplement this function must call the base
implementation in order to include the contents of the QIODevice's buffer. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qiodevice.cpp 3
+ \snippet code/src_corelib_io_qiodevice.cpp 3
\sa readyRead(), readLine()
*/
@@ -1272,7 +1272,7 @@ bool QIODevice::canReadLine() const
device. Returns the number of bytes that were actually written, or
-1 if an error occurred.
- \sa read() writeData()
+ \sa read(), writeData()
*/
qint64 QIODevice::write(const char *data, qint64 maxSize)
{
@@ -1362,7 +1362,7 @@ qint64 QIODevice::write(const char *data, qint64 maxSize)
...
\endcode
- \sa read() writeData()
+ \sa read(), writeData()
*/
qint64 QIODevice::write(const char *data)
{
@@ -1376,7 +1376,7 @@ qint64 QIODevice::write(const char *data)
Writes the content of \a byteArray to the device. Returns the number of
bytes that were actually written, or -1 if an error occurred.
- \sa read() writeData()
+ \sa read(), writeData()
*/
/*!
@@ -1407,7 +1407,7 @@ void QIODevice::ungetChar(char c)
Writes the character \a c to the device. Returns true on success;
otherwise returns false.
- \sa write() getChar() ungetChar()
+ \sa write(), getChar(), ungetChar()
*/
bool QIODevice::putChar(char c)
{
@@ -1457,7 +1457,7 @@ QByteArray QIODevicePrivate::peek(qint64 maxSize)
is 0, the character is discarded. Returns true on success;
otherwise returns false.
- \sa read() putChar() ungetChar()
+ \sa read(), putChar(), ungetChar()
*/
bool QIODevice::getChar(char *c)
{
@@ -1479,7 +1479,7 @@ bool QIODevice::getChar(char *c)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qiodevice.cpp 4
+ \snippet code/src_corelib_io_qiodevice.cpp 4
\sa read()
*/
@@ -1497,7 +1497,7 @@ qint64 QIODevice::peek(char *data, qint64 maxSize)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qiodevice.cpp 5
+ \snippet code/src_corelib_io_qiodevice.cpp 5
This function has no way of reporting errors; returning an empty
QByteArray() can mean either that no data was currently available
@@ -1620,7 +1620,7 @@ QString QIODevice::errorString() const
all the requested information was read and therefore does not retry reading
if there was a problem.
- \sa read() readLine() writeData()
+ \sa read(), readLine(), writeData()
*/
/*!
@@ -1638,7 +1638,7 @@ QString QIODevice::errorString() const
all the information was written and therefore does not retry writing if
there was a problem.
- \sa read() write()
+ \sa read(), write()
*/
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index a510f5390c..4819ec11a0 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -110,6 +110,11 @@ public:
first += r;
return r;
}
+ int peek(char* target, int size) {
+ int r = qMin(size, len);
+ memcpy(target, first, r);
+ return r;
+ }
char* reserve(int size) {
makeSpace(size + len, freeSpaceAtEnd);
char* writePtr = first + len;
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 640704ec86..b75c9c1974 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -451,10 +451,10 @@ void QProcessPrivate::Channel::clear()
containing "-style" and "motif" as two items in the list of
arguments:
- \snippet doc/src/snippets/qprocess/qprocess-simpleexecution.cpp 0
+ \snippet qprocess/qprocess-simpleexecution.cpp 0
\dots
- \snippet doc/src/snippets/qprocess/qprocess-simpleexecution.cpp 1
- \snippet doc/src/snippets/qprocess/qprocess-simpleexecution.cpp 2
+ \snippet qprocess/qprocess-simpleexecution.cpp 1
+ \snippet qprocess/qprocess-simpleexecution.cpp 2
QProcess then enters the \l Starting state, and when the program
has started, QProcess enters the \l Running state and emits
@@ -550,7 +550,7 @@ void QProcessPrivate::Channel::clear()
The following example runs \c gzip to compress the string "Qt
rocks!", without an event loop:
- \snippet doc/src/snippets/process/process.cpp 0
+ \snippet process/process.cpp 0
\section1 Notes for Windows Users
@@ -1184,7 +1184,7 @@ QProcess::ProcessChannelMode QProcess::processChannelMode() const
error channels to the \a mode specified.
This mode will be used the next time start() is called. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 0
+ \snippet code/src_corelib_io_qprocess.cpp 0
\sa processChannelMode(), ProcessChannelMode, setReadChannel()
*/
@@ -1261,7 +1261,7 @@ void QProcess::closeReadChannel(ProcessChannel channel)
Unix and Windows. But it will not display the text data until
QProcess's write channel has been closed. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 1
+ \snippet code/src_corelib_io_qprocess.cpp 1
The write channel is implicitly opened when start() is called.
@@ -1363,10 +1363,10 @@ void QProcess::setStandardErrorFile(const QString &fileName, OpenMode mode)
destination process' standard input.
The following shell command:
- \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 2
+ \snippet code/src_corelib_io_qprocess.cpp 2
Can be accomplished with QProcesses with the following code:
- \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 3
+ \snippet code/src_corelib_io_qprocess.cpp 3
*/
void QProcess::setStandardOutputProcess(QProcess *destination)
{
@@ -1567,7 +1567,7 @@ QProcess::ProcessState QProcess::state() const
For example, the following code adds the \c{C:\\BIN} directory to the list of
executable paths (\c{PATHS}) on Windows:
- \snippet doc/src/snippets/qprocess-environment/main.cpp 0
+ \snippet qprocess-environment/main.cpp 0
\note This function is less efficient than the setProcessEnvironment()
function.
@@ -1605,7 +1605,7 @@ QStringList QProcess::environment() const
For example, the following code adds the \c{C:\\BIN} directory to the list of
executable paths (\c{PATHS}) on Windows and sets \c{TMPDIR}:
- \snippet doc/src/snippets/qprocess-environment/main.cpp 1
+ \snippet qprocess-environment/main.cpp 1
Note how, on Windows, environment variable names are case-insensitive.
@@ -1755,7 +1755,7 @@ void QProcess::setProcessState(ProcessState state)
\e execve()). Reimplement this function to do last minute initialization
of the child process. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 4
+ \snippet code/src_corelib_io_qprocess.cpp 4
You cannot exit the process (by calling exit(), for instance) from
this function. If you need to stop the program before it starts
@@ -2002,12 +2002,12 @@ static QStringList parseCombinedArgString(const QString &program)
program name and its arguments. The arguments are separated by one or
more spaces. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 5
+ \snippet code/src_corelib_io_qprocess.cpp 5
The \a program string can also contain quotes, to ensure that arguments
containing spaces are correctly supplied to the new process. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 6
+ \snippet code/src_corelib_io_qprocess.cpp 6
If the QProcess object is already running a process, a warning may be
printed at the console, and the existing process will continue running.
@@ -2017,7 +2017,7 @@ static QStringList parseCombinedArgString(const QString &program)
way to ensure that \c{"My Documents"} is used as the argument to
the \c dir executable:
- \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 7
+ \snippet code/src_corelib_io_qprocess.cpp 7
The OpenMode is set to \a mode.
*/
@@ -2218,10 +2218,10 @@ bool QProcess::startDetached(const QString &program)
}
QT_BEGIN_INCLUDE_NAMESPACE
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
-#elif defined(Q_OS_WINCE) || (defined(Q_OS_MAC) && defined(QT_NO_CORESERVICES))
+#elif defined(Q_OS_WINCE) || defined(Q_OS_IOS)
static char *qt_empty_environ[] = { 0 };
#define environ qt_empty_environ
#elif !defined(Q_OS_WIN)
@@ -2235,7 +2235,7 @@ QT_END_INCLUDE_NAMESPACE
Returns the environment of the calling process as a list of
key=value pairs. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 8
+ \snippet code/src_corelib_io_qprocess.cpp 8
This function does not cache the system environment. Therefore, it's
possible to obtain an updated version of the environment if low-level C
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index bfa132f353..17dae7b6ca 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -117,13 +117,6 @@ QT_BEGIN_NAMESPACE
// so we will use 512
static const int errorBufferMax = 512;
-#ifdef Q_OS_INTEGRITY
-static inline char *strdup(const char *data)
-{
- return qstrdup(data);
-}
-#endif
-
static int qt_qprocess_deadChild_pipe[2];
static struct sigaction qt_sa_old_sigchld_handler;
static void qt_sa_sigchld_handler(int signum)
@@ -476,7 +469,7 @@ bool QProcessPrivate::createChannel(Channel &channel)
}
QT_BEGIN_INCLUDE_NAMESPACE
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#else
@@ -487,7 +480,7 @@ QT_END_INCLUDE_NAMESPACE
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
-#if !defined(Q_OS_MAC) || !defined(QT_NO_CORESERVICES)
+#if !defined(Q_OS_IOS)
const char *entry;
for (int count = 0; (entry = environ[count]); ++count) {
const char *equal = strchr(entry, '=');
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 4a0211c00a..0937e1e795 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -584,7 +584,7 @@ QResource::addSearchPath(const QString &path)
Returns the current search path list. This list is consulted when
creating a relative resource.
- \sa QDir::addSearchPath() QDir::setSearchPaths()
+ \sa QDir::addSearchPath(), QDir::setSearchPaths()
*/
QStringList
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 1ec0390235..33c1d4301d 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -775,8 +775,6 @@ void QSettingsPrivate::iniEscapedStringList(const QStringList &strs, QByteArray
with Qt 4.0. @Invalid() stands for QVariant(), and
QVariant().toStringList() returns an empty QStringList,
so we're in good shape.
-
- ### Qt 5: Use a nicer syntax, e.g. @List, for variant lists
*/
result += "@Invalid()";
} else {
@@ -2030,7 +2028,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
company is called MySoft, you would construct the QSettings
object as follows:
- \snippet doc/src/snippets/settings/settings.cpp 0
+ \snippet settings/settings.cpp 0
QSettings objects can be created either on the stack or on
the heap (i.e. using \c new). Constructing and destroying a
@@ -2042,11 +2040,11 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
QCoreApplication::setApplicationName(), and then use the default
QSettings constructor:
- \snippet doc/src/snippets/settings/settings.cpp 1
- \snippet doc/src/snippets/settings/settings.cpp 2
- \snippet doc/src/snippets/settings/settings.cpp 3
+ \snippet settings/settings.cpp 1
+ \snippet settings/settings.cpp 2
+ \snippet settings/settings.cpp 3
\dots
- \snippet doc/src/snippets/settings/settings.cpp 4
+ \snippet settings/settings.cpp 4
(Here, we also specify the organization's Internet domain. When
the Internet domain is set, it is used on Mac OS X instead of the
@@ -2060,7 +2058,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
that stores the data associated with the key. To write a setting,
use setValue(). For example:
- \snippet doc/src/snippets/settings/settings.cpp 5
+ \snippet settings/settings.cpp 5
If there already exists a setting with the same key, the existing
value is overwritten by the new value. For efficiency, the
@@ -2069,14 +2067,14 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
You can get a setting's value back using value():
- \snippet doc/src/snippets/settings/settings.cpp 6
+ \snippet settings/settings.cpp 6
If there is no setting with the specified name, QSettings
returns a null QVariant (which can be converted to the integer 0).
You can specify another default value by passing a second
argument to value():
- \snippet doc/src/snippets/settings/settings.cpp 7
+ \snippet settings/settings.cpp 7
To test whether a given key exists, call contains(). To remove
the setting associated with a key, call remove(). To obtain the
@@ -2093,13 +2091,13 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
Instead, you can use the QVariant::value() or the qVariantValue()
template function. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 0
+ \snippet code/src_corelib_io_qsettings.cpp 0
The inverse conversion (e.g., from QColor to QVariant) is
automatic for all data types supported by QVariant, including
GUI-related types:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 1
+ \snippet code/src_corelib_io_qsettings.cpp 1
Custom types registered using qRegisterMetaType() and
qRegisterMetaTypeStreamOperators() can be stored using QSettings.
@@ -2129,18 +2127,18 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
You can form hierarchical keys using the '/' character as a
separator, similar to Unix file paths. For example:
- \snippet doc/src/snippets/settings/settings.cpp 8
- \snippet doc/src/snippets/settings/settings.cpp 9
- \snippet doc/src/snippets/settings/settings.cpp 10
+ \snippet settings/settings.cpp 8
+ \snippet settings/settings.cpp 9
+ \snippet settings/settings.cpp 10
If you want to save or restore many settings with the same
prefix, you can specify the prefix using beginGroup() and call
endGroup() at the end. Here's the same example again, but this
time using the group mechanism:
- \snippet doc/src/snippets/settings/settings.cpp 11
+ \snippet settings/settings.cpp 11
\codeline
- \snippet doc/src/snippets/settings/settings.cpp 12
+ \snippet settings/settings.cpp 12
If a group is set using beginGroup(), the behavior of most
functions changes consequently. Groups can be set recursively.
@@ -2180,8 +2178,8 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
Let's see with an example:
- \snippet doc/src/snippets/settings/settings.cpp 13
- \snippet doc/src/snippets/settings/settings.cpp 14
+ \snippet settings/settings.cpp 13
+ \snippet settings/settings.cpp 14
The table below summarizes which QSettings objects access
which location. "\b{X}" means that the location is the main
@@ -2207,7 +2205,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
argument to the QSettings constructor, followed by the scope, the
organization name, and the application name:
- \snippet doc/src/snippets/settings/settings.cpp 15
+ \snippet settings/settings.cpp 15
The \l{tools/settingseditor}{Settings Editor} example lets you
experiment with different settings location and with fallbacks
@@ -2219,9 +2217,9 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
application. The following example illustrates how to use QSettings
to save and restore the geometry of an application's main window.
- \snippet doc/src/snippets/settings/settings.cpp 16
+ \snippet settings/settings.cpp 16
\codeline
- \snippet doc/src/snippets/settings/settings.cpp 17
+ \snippet settings/settings.cpp 17
See \l{Window Geometry} for a discussion on why it is better to
call QWidget::resize() and QWidget::move() rather than QWidget::setGeometry()
@@ -2231,12 +2229,12 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
called from the main window's constructor and close event handler
as follows:
- \snippet doc/src/snippets/settings/settings.cpp 18
+ \snippet settings/settings.cpp 18
\dots
- \snippet doc/src/snippets/settings/settings.cpp 19
- \snippet doc/src/snippets/settings/settings.cpp 20
+ \snippet settings/settings.cpp 19
+ \snippet settings/settings.cpp 20
\codeline
- \snippet doc/src/snippets/settings/settings.cpp 21
+ \snippet settings/settings.cpp 21
See the \l{mainwindows/application}{Application} example for a
self-contained example that uses QSettings.
@@ -2343,7 +2341,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
takes a file name as first argument and pass QSettings::IniFormat
as second argument. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 2
+ \snippet code/src_corelib_io_qsettings.cpp 2
You can then use the QSettings object to read and write settings
in the file.
@@ -2351,7 +2349,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
On Mac OS X, you can access XML-based \c .plist files by passing
QSettings::NativeFormat as second argument. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 3
+ \snippet code/src_corelib_io_qsettings.cpp 3
\section2 Accessing the Windows Registry Directly
@@ -2362,13 +2360,13 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
For example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 4
+ \snippet code/src_corelib_io_qsettings.cpp 4
All the registry entries that appear under the specified path can
be read or written through the QSettings object as usual (using
forward slashes instead of backslashes). For example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 5
+ \snippet code/src_corelib_io_qsettings.cpp 5
Note that the backslash character is, as mentioned, used by
QSettings to separate subkeys. As a result, you cannot read or
@@ -2382,7 +2380,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
Its default value is accessed by using "Default" or "." in
place of a subkey:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 6
+ \snippet code/src_corelib_io_qsettings.cpp 6
On other platforms than Windows, "Default" and "." would be
treated as regular subkeys.
@@ -2423,7 +2421,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
Another solution is to use preprocessor directives, for
example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 7
+ \snippet code/src_corelib_io_qsettings.cpp 7
\li On Unix and Mac OS X systems, the advisory file locking is disabled
if NFS (or AutoFS or CacheFS) is detected to work around a bug in the
@@ -2489,7 +2487,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
(e.g., QPoint, QRect, and QSize), Qt uses an \c{@}-based
syntax to encode the type. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 8
+ \snippet code/src_corelib_io_qsettings.cpp 8
To minimize compatibility issues, any \c @ that doesn't
appear at the first position in the value or that isn't
@@ -2500,7 +2498,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
Windows applications don't escape backslashes (\c{\}) in file
paths:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 9
+ \snippet code/src_corelib_io_qsettings.cpp 9
QSettings always treats backslash as a special character and
provides no API for reading or writing such entries.
@@ -2549,7 +2547,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
organization, and with parent \a parent.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 10
+ \snippet code/src_corelib_io_qsettings.cpp 10
The scope is set to QSettings::UserScope, and the format is
set to QSettings::NativeFormat (i.e. calling setDefaultFormat()
@@ -2661,11 +2659,11 @@ QSettings::QSettings(const QString &fileName, Format format, QObject *parent)
The code
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 11
+ \snippet code/src_corelib_io_qsettings.cpp 11
is equivalent to
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 12
+ \snippet code/src_corelib_io_qsettings.cpp 12
If QCoreApplication::setOrganizationName() and
QCoreApplication::setApplicationName() has not been previously
@@ -2928,7 +2926,7 @@ QSettings::Status QSettings::status() const
Groups are useful to avoid typing in the same setting paths over
and over. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 13
+ \snippet code/src_corelib_io_qsettings.cpp 13
This will set the value of three settings:
@@ -2955,7 +2953,7 @@ void QSettings::beginGroup(const QString &prefix)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 14
+ \snippet code/src_corelib_io_qsettings.cpp 14
\sa beginGroup(), group()
*/
@@ -2993,7 +2991,7 @@ QString QSettings::group() const
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 15
+ \snippet code/src_corelib_io_qsettings.cpp 15
Use beginWriteArray() to write the array in the first place.
@@ -3016,7 +3014,7 @@ int QSettings::beginReadArray(const QString &prefix)
that you want to save a variable-length list of user names and
passwords. You could then write:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 16
+ \snippet code/src_corelib_io_qsettings.cpp 16
The generated keys will have the form
@@ -3101,12 +3099,12 @@ void QSettings::setArrayIndex(int i)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 17
+ \snippet code/src_corelib_io_qsettings.cpp 17
If a group is set using beginGroup(), only the keys in the group
are returned, without the group prefix:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 18
+ \snippet code/src_corelib_io_qsettings.cpp 18
\sa childGroups(), childKeys()
*/
@@ -3122,12 +3120,12 @@ QStringList QSettings::allKeys() const
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 19
+ \snippet code/src_corelib_io_qsettings.cpp 19
If a group is set using beginGroup(), the top-level keys in that
group are returned, without the group prefix:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 20
+ \snippet code/src_corelib_io_qsettings.cpp 20
You can navigate through the entire setting hierarchy using
childKeys() and childGroups() recursively.
@@ -3146,12 +3144,12 @@ QStringList QSettings::childKeys() const
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 21
+ \snippet code/src_corelib_io_qsettings.cpp 21
If a group is set using beginGroup(), the first-level keys in
that group are returned, without the group prefix.
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 22
+ \snippet code/src_corelib_io_qsettings.cpp 22
You can navigate through the entire setting hierarchy using
childKeys() and childGroups() recursively.
@@ -3194,7 +3192,7 @@ bool QSettings::isWritable() const
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 23
+ \snippet code/src_corelib_io_qsettings.cpp 23
\sa value(), remove(), contains()
*/
@@ -3211,7 +3209,7 @@ void QSettings::setValue(const QString &key, const QVariant &value)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 24
+ \snippet code/src_corelib_io_qsettings.cpp 24
Be aware that if one of the fallback locations contains a setting
with the same key, that setting will be visible after calling
@@ -3220,7 +3218,7 @@ void QSettings::setValue(const QString &key, const QVariant &value)
If \a key is an empty string, all keys in the current group() are
removed. For example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 25
+ \snippet code/src_corelib_io_qsettings.cpp 25
Note that the Windows registry and INI files use case-insensitive
keys, whereas the Carbon Preferences API on Mac OS X uses
@@ -3326,7 +3324,7 @@ bool QSettings::event(QEvent *event)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 26
+ \snippet code/src_corelib_io_qsettings.cpp 26
\sa setValue(), contains(), remove()
*/
@@ -3459,7 +3457,7 @@ void QSettings::setPath(Format format, Scope scope, const QString &path)
Typedef for a pointer to a function with the following signature:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 27
+ \snippet code/src_corelib_io_qsettings.cpp 27
\c ReadFunc is used in \c registerFormat() as a pointer to a function
that reads a set of key/value pairs. \c ReadFunc should read all the
@@ -3474,7 +3472,7 @@ void QSettings::setPath(Format format, Scope scope, const QString &path)
Typedef for a pointer to a function with the following signature:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 28
+ \snippet code/src_corelib_io_qsettings.cpp 28
\c WriteFunc is used in \c registerFormat() as a pointer to a function
that writes a set of key/value pairs. \c WriteFunc is only called once,
@@ -3510,7 +3508,7 @@ void QSettings::setPath(Format format, Scope scope, const QString &path)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 29
+ \snippet code/src_corelib_io_qsettings.cpp 29
\sa setPath()
*/
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index c572fa7b72..ddb9ab581a 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -604,7 +604,7 @@ QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format,
const QString &application)
{
#ifndef QT_BOOTSTRAPPED
- if (organization == QLatin1String("Trolltech"))
+ if (organization == QLatin1String("Qt"))
{
QString organizationDomain = QCoreApplication::organizationDomain();
QString applicationName = QCoreApplication::applicationName();
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index c6103b3f2f..700b80b062 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -94,7 +94,7 @@ QT_BEGIN_NAMESPACE
\value DownloadLocation Returns a directory for user's downloaded files.
- \sa writableLocation() standardLocations() displayName() locate() locateAll()
+ \sa writableLocation(), standardLocations(), displayName(), locate(), locateAll()
*/
/*!
diff --git a/src/corelib/io/qstandardpaths_json.cpp b/src/corelib/io/qstandardpaths_json.cpp
index c7cb858f0f..8542371848 100644
--- a/src/corelib/io/qstandardpaths_json.cpp
+++ b/src/corelib/io/qstandardpaths_json.cpp
@@ -193,7 +193,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
QString value = iter.value().toString();
// optimize for a common case
- value.replace(QLatin1String("${HOME}"), QFile::decodeName(qgetenv("HOME")));
+ value.replace(QLatin1String("${HOME}"), QDir::homePath());
// Do ${} format environment variable substitution if necessary
if (!value.isEmpty() && value.contains(QLatin1String("${"))) {
diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp
index 579d569a01..86c7ed51aa 100644
--- a/src/corelib/io/qtemporarydir.cpp
+++ b/src/corelib/io/qtemporarydir.cpp
@@ -52,7 +52,7 @@
#endif
#include <stdlib.h> // mkdtemp
-#if defined(Q_OS_QNX) || defined(Q_OS_WIN)
+#if defined(Q_OS_QNX) || defined(Q_OS_WIN) || defined(Q_OS_LINUX_ANDROID)
#include <private/qfilesystemengine_p.h>
#endif
@@ -94,7 +94,7 @@ static QString defaultTemplateName()
return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX");
}
-#if defined(Q_OS_QNX ) || defined(Q_OS_WIN)
+#if defined(Q_OS_QNX ) || defined(Q_OS_WIN) || defined(Q_OS_LINUX_ANDROID)
static char *mkdtemp(char *templateName)
{
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@@ -171,7 +171,7 @@ void QTemporaryDirPrivate::create(const QString &templateName)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtemporarydir.cpp 0
+ \snippet code/src_corelib_io_qtemporarydir.cpp 0
It is very important to test that the temporary directory could be
created, using isValid(). Do not use exists(), since a default-constructed
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 75681dadff..cb8b5dbefc 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -466,7 +466,7 @@ static QString defaultTemplateName()
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp 0
+ \snippet code/src_corelib_io_qtemporaryfile.cpp 0
Reopening a QTemporaryFile after calling close() is safe. For as long as
the QTemporaryFile object itself is not destroyed, the unique temporary
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 0411b463b3..ae40f777d8 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -58,13 +58,13 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384;
generating text, QTextStream supports formatting options for field
padding and alignment, and formatting of numbers. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 0
+ \snippet code/src_corelib_io_qtextstream.cpp 0
It's also common to use QTextStream to read console input and write
console output. QTextStream is locale aware, and will automatically decode
standard input using the correct codec. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 1
+ \snippet code/src_corelib_io_qtextstream.cpp 1
Besides using QTextStream's constructors, you can also set the
device or string QTextStream operates on by calling setDevice() or
@@ -117,7 +117,7 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384;
the integer base, thereby disabling the automatic detection, by
calling setIntegerBase(). Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 2
+ \snippet code/src_corelib_io_qtextstream.cpp 2
QTextStream supports many formatting options for generating text.
You can set the field width and pad character by calling
@@ -154,7 +154,7 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384;
\row \li \c left \li Same as setFieldAlignment(AlignLeft).
\row \li \c right \li Same as setFieldAlignment(AlignRight).
\row \li \c center \li Same as setFieldAlignment(AlignCenter).
- \row \li \c endl \li Same as operator<<('\n') and flush().
+ \row \li \c endl \li Same as operator<<('\\n') and flush().
\row \li \c flush \li Same as flush().
\row \li \c reset \li Same as reset().
\row \li \c ws \li Same as skipWhiteSpace().
@@ -1081,7 +1081,7 @@ QTextStream::QTextStream(QByteArray *array, QIODevice::OpenMode openMode)
This constructor is convenient for working on constant
strings. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 3
+ \snippet code/src_corelib_io_qtextstream.cpp 3
*/
QTextStream::QTextStream(const QByteArray &array, QIODevice::OpenMode openMode)
: d_ptr(new QTextStreamPrivate(this))
@@ -1111,7 +1111,7 @@ QTextStream::QTextStream(const QByteArray &array, QIODevice::OpenMode openMode)
This constructor is useful for working directly with the common
FILE based input and output streams: stdin, stdout and stderr. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 4
+ \snippet code/src_corelib_io_qtextstream.cpp 4
*/
QTextStream::QTextStream(FILE *fileHandle, QIODevice::OpenMode openMode)
@@ -1404,11 +1404,11 @@ QTextStream::FieldAlignment QTextStream::fieldAlignment() const
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 5
+ \snippet code/src_corelib_io_qtextstream.cpp 5
The string \c s contains:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 6
+ \snippet code/src_corelib_io_qtextstream.cpp 6
\sa padChar(), setFieldWidth()
*/
@@ -1601,7 +1601,7 @@ void QTextStream::resetStatus()
Subsequent calls to setStatus() are ignored until resetStatus()
is called.
- \sa Status status() resetStatus()
+ \sa Status, status(), resetStatus()
*/
void QTextStream::setStatus(Status status)
{
@@ -2023,7 +2023,7 @@ bool QTextStreamPrivate::getReal(double *f)
reference to the QTextStream, so several operators can be
nested. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 7
+ \snippet code/src_corelib_io_qtextstream.cpp 7
Whitespace is \e not skipped.
*/
@@ -2241,8 +2241,8 @@ QTextStream &QTextStream::operator>>(QByteArray &array)
/*!
\overload
- Stores the word in \a c, terminated by a '\0' character. If no word is
- available, only the '\0' character is stored.
+ Stores the word in \a c, terminated by a '\\0' character. If no word is
+ available, only the '\\0' character is stored.
Warning: Although convenient, this operator is dangerous and must
be used with care. QTextStream assumes that \a c points to a
@@ -2294,7 +2294,7 @@ void QTextStreamPrivate::putNumber(qulonglong number, bool negative)
if (locale != QLocale::c())
flags |= QLocalePrivate::ThousandsGroup;
- const QLocalePrivate *dd = locale.d();
+ const QLocalePrivate *dd = locale.d;
int base = integerBase ? integerBase : 10;
if (negative && base == 10) {
result = dd->longLongToString(-static_cast<qlonglong>(number), -1,
@@ -2503,7 +2503,7 @@ QTextStream &QTextStream::operator<<(double f)
if (numberFlags() & ForcePoint)
flags |= QLocalePrivate::Alternate;
- const QLocalePrivate *dd = d->locale.d();
+ const QLocalePrivate *dd = d->locale.d;
QString num = dd->doubleToString(f, d->realNumberPrecision, form, -1, flags);
d->putString(num, true);
return *this;
@@ -2561,11 +2561,11 @@ QTextStream &QTextStream::operator<<(const QByteArray &array)
string is assumed to be in ISO-8859-1 encoding. This operator
is convenient when working with constant string data. Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 8
+ \snippet code/src_corelib_io_qtextstream.cpp 8
Warning: QTextStream assumes that \a string points to a string of
- text, terminated by a '\0' character. If there is no terminating
- '\0' character, your application may crash.
+ text, terminated by a '\\0' character. If there is no terminating
+ '\\0' character, your application may crash.
*/
QTextStream &QTextStream::operator<<(const char *string)
{
@@ -2865,13 +2865,13 @@ QTextStream &center(QTextStream &stream)
/*!
\relates QTextStream
- Writes '\n' to the \a stream and flushes the stream.
+ Writes '\\n' to the \a stream and flushes the stream.
Equivalent to
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 9
+ \snippet code/src_corelib_io_qtextstream.cpp 9
- Note: On Windows, all '\n' characters are written as '\r\n' if
+ Note: On Windows, all '\\n' characters are written as '\\r\\n' if
QTextStream's device or string is opened using the QIODevice::Text flag.
\sa flush(), reset(), {QTextStream manipulators}
@@ -2993,7 +2993,7 @@ void QTextStream::setCodec(QTextCodec *codec)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 10
+ \snippet code/src_corelib_io_qtextstream.cpp 10
\sa QTextCodec::codecForName(), setLocale()
*/
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index fbc8d761c2..aed1be2ffb 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -64,7 +64,7 @@
unencoded representation is suitable for showing to users, but
the encoded representation is typically what you would send to
a web server. For example, the unencoded URL
- "http://b\uuml\c{}hler.example.com" would be sent to the server as
+ "http://b\\uuml\c{}hler.example.com" would be sent to the server as
"http://xn--bhler-kva.example.com/List%20of%20applicants.xml".
A URL can also be constructed piece by piece by calling
@@ -126,36 +126,51 @@
The parsing mode controls the way QUrl parses strings.
\value TolerantMode QUrl will try to correct some common errors in URLs.
- This mode is useful when processing URLs entered by
- users.
+ This mode is useful for parsing URLs coming from sources
+ not known to be strictly standards-conforming.
\value StrictMode Only valid URLs are accepted. This mode is useful for
general URL validation.
- In TolerantMode, the parser corrects the following invalid input:
+ In TolerantMode, the parser has the following behaviour:
\list
- \li Spaces and "%20": If an encoded URL contains a space, this will be
- replaced with "%20". If a decoded URL contains "%20", this will be
- replaced with a single space before the URL is parsed.
+ \li Spaces and "%20": unencoded space characters will be accepted and will
+ be treated as equivalent to "%20".
\li Single "%" characters: Any occurrences of a percent character "%" not
followed by exactly two hexadecimal characters (e.g., "13% coverage.html")
- will be replaced by "%25".
+ will be replaced by "%25". Note that one lone "%" character will trigger
+ the correction mode for all percent characters.
\li Reserved and unreserved characters: An encoded URL should only
contain a few characters as literals; all other characters should
be percent-encoded. In TolerantMode, these characters will be
automatically percent-encoded where they are not allowed:
- space / double-quote / "<" / ">" / "[" / "\" /
- "]" / "^" / "`" / "{" / "|" / "}"
+ space / double-quote / "<" / ">" / "\" /
+ "^" / "`" / "{" / "|" / "}"
+ Those same characters can be decoded again by passing QUrl::DecodeReserved
+ to toString() or toEncoded().
\endlist
+
+ When in StrictMode, if a parsing error is found, isValid() will return \c
+ false and errorString() will return a simple message describing the error.
+ If more than one error is detected, it is undefined which error gets
+ reported.
+
+ Note that TolerantMode is not usually enough for parsing user input, which
+ often contains more errors and expectations than the parser can deal with.
+ When dealing with data coming directly from the user -- as opposed to data
+ coming from data-transfer sources, such as other programs -- it is
+ recommended to use fromUserInput().
+
+ \sa fromUserInput(), setUrl(), toString(), toEncoded(), QUrl::FormattingOptions
*/
/*!
- \enum QUrl::FormattingOption
+ \enum QUrl::FormattingOptions
The formatting options define how the URL is formatted when written out
as text.
@@ -178,6 +193,62 @@
Note that the case folding rules in \l{RFC 3491}{Nameprep}, which QUrl
conforms to, require host names to always be converted to lower case,
regardless of the Qt::FormattingOptions used.
+
+ The options from QUrl::ComponentFormattingOptions are also possible.
+
+ \sa QUrl::ComponentFormattingOptions
+*/
+
+/*!
+ \enum QUrl::ComponentFormattingOptions
+ \since 5.0
+
+ The component formatting options define how the components of an URL will
+ be formatted when written out as text. They can be combined with the
+ options from QUrl::FormattingOptions when used in toString() and
+ toEncoded().
+
+ \value PrettyDecoded The component is returned in a "pretty form", with
+ most percent-encoded characters decoded. The exact
+ behavior of PrettyDecoded varies from component to
+ component and may also change from Qt release to Qt
+ release. This is the default.
+
+ \value EncodeSpaces Leave space characters in their encoded form ("%20").
+
+ \value EncodeUnicode Leave non-US-ASCII characters encoded in their UTF-8
+ percent-encoded form (e.g., "%C3%A9" for the U+00E9
+ codepoint, LATIN SMALL LETTER E WITH ACUTE).
+
+ \value EncodeDelimiters Leave certain delimiters in their encoded form, as
+ would appear in the URL when the full URL is
+ represented as text. The delimiters are affected
+ by this option change from component to component.
+
+ \value EncodeReserved Leave the US-ASCII reserved characters in their encoded
+ forms.
+
+ \value DecodeReseved Decode the US-ASCII reserved characters.
+
+ \value FullyEncoded Leave all characters in their properly-encoded form,
+ as this component would appear as part of a URL. When
+ used with toString(), this produces a fully-compliant
+ URL in QString form, exactly equal to the result of
+ toEncoded()
+
+ \value MostDecoded Attempt to decode as much as possible. For individual
+ components of the URL, this decodes every percent
+ encoding sequence, control characters (U+0000 to U+001F)
+ and non-US-ASCII sequences that aren't valid UTF-8
+ sequences.
+
+ The values of EncodeReserved and DecodeReserved should not be used together
+ in one call. The behaviour is undefined if that happens. They are provided
+ as separate values because the behaviour of the "pretty mode" with regards
+ to reserved characters is different on certain components and specially on
+ the full URL.
+
+ \sa QUrl::FormattingOptions
*/
#include "qurl.h"
@@ -208,6 +279,12 @@ static inline char toHex(quint8 c)
return c > 9 ? c - 10 + 'A' : c + '0';
}
+static inline quint8 fromHex(quint8 c)
+{
+ c |= 0x20;
+ return c >= 'a' ? c - 'a' + 10 : c - '0';
+}
+
static inline QString ftpScheme()
{
return QStringLiteral("ftp");
@@ -246,24 +323,6 @@ QUrlPrivate::QUrlPrivate(const QUrlPrivate &copy)
{
}
-void QUrlPrivate::clear()
-{
- scheme.clear();
- userName.clear();
- password.clear();
- host.clear();
- port = -1;
- path.clear();
- query.clear();
- fragment.clear();
-
- errorCode = NoError;
- errorSupplement = 0;
- sectionIsPresent = 0;
- sectionHasError = 0;
-}
-
-
// From RFC 3896, Appendix A Collected ABNF for URI
// URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
//[...]
@@ -1391,20 +1450,25 @@ const QByteArray &QUrlPrivate::normalized() const
/*!
- Constructs a URL by parsing \a url. \a url is assumed to be in human
- readable representation, with no percent encoding. QUrl will automatically
- percent encode all characters that are not allowed in a URL.
- The default parsing mode is TolerantMode.
-
- Parses the \a url using the parser mode \a parsingMode.
+ Constructs a URL by parsing \a url. QUrl will automatically percent encode
+ all characters that are not allowed in a URL and decode the percent-encoded
+ sequences that represent a character that is allowed in a URL.
+
+ Parses the \a url using the parser mode \a parsingMode. In TolerantMode
+ (the default), QUrl will correct certain mistakes, notably the presence of
+ a percent character ('%') not followed by two hexadecimal digits, and it
+ will accept any character in any position. In StrictMode, encoding mistakes
+ will not be tolerated and QUrl will also check that certain forbidden
+ characters are not present in unencoded form. If an error is detected in
+ StrictMode, isValid() will return false.
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qurl.cpp 0
+ \snippet code/src_corelib_io_qurl.cpp 0
To construct a URL from an encoded string, call fromEncoded():
- \snippet doc/src/snippets/code/src_corelib_io_qurl.cpp 1
+ \snippet code/src_corelib_io_qurl.cpp 1
\sa setUrl(), setEncodedUrl(), fromEncoded(), TolerantMode
*/
@@ -1445,7 +1509,7 @@ QUrl::~QUrl()
must conform to the standard encoding rules of the URI standard
for the URL to be reported as valid.
- \snippet doc/src/snippets/code/src_corelib_io_qurl.cpp 2
+ \snippet code/src_corelib_io_qurl.cpp 2
*/
bool QUrl::isValid() const
{
@@ -1475,12 +1539,18 @@ void QUrl::clear()
}
/*!
- Parses \a url using the parsing mode \a parsingMode.
-
- \a url is assumed to be in unicode format, with no percent
- encoding.
-
- Calling isValid() will tell whether or not a valid URL was constructed.
+ Parses \a url and sets this object to that value. QUrl will automatically
+ percent encode all characters that are not allowed in a URL and decode the
+ percent-encoded sequences that represent a character that is allowed in a
+ URL.
+
+ Parses the \a url using the parser mode \a parsingMode. In TolerantMode
+ (the default), QUrl will correct certain mistakes, notably the presence of
+ a percent character ('%') not followed by two hexadecimal digits, and it
+ will accept any character in any position. In StrictMode, encoding mistakes
+ will not be tolerated and QUrl will also check that certain forbidden
+ characters are not present in unencoded form. If an error is detected in
+ StrictMode, isValid() will return false.
\sa setEncodedUrl()
*/
@@ -1501,7 +1571,7 @@ void QUrl::setUrl(const QString &url, ParsingMode parsingMode)
and is followed by a ':'. The following example shows a URL where
the scheme is "ftp":
- \img qurl-authority2.png
+ \image qurl-authority2.png
The scheme can also be empty, in which case the URL is interpreted
as relative.
@@ -1548,7 +1618,7 @@ QString QUrl::scheme() const
The following example shows a valid authority string:
- \img qurl-authority.png
+ \image qurl-authority.png
*/
void QUrl::setAuthority(const QString &authority)
{
@@ -1585,7 +1655,7 @@ QString QUrl::authority(ComponentFormattingOptions options) const
separated by a ':'. If the password is empty, the colon must be
omitted. The following example shows a valid user info string:
- \img qurl-authority3.png
+ \image qurl-authority3.png
\sa userInfo(), setUserName(), setPassword(), setAuthority()
*/
@@ -1746,7 +1816,7 @@ void QUrl::setPort(int port)
Example:
- \snippet doc/src/snippets/code/src_corelib_io_qurl.cpp 3
+ \snippet code/src_corelib_io_qurl.cpp 3
*/
int QUrl::port(int defaultPort) const
{
@@ -1758,12 +1828,12 @@ int QUrl::port(int defaultPort) const
Sets the path of the URL to \a path. The path is the part of the
URL that comes after the authority but before the query string.
- \img qurl-ftppath.png
+ \image qurl-ftppath.png
For non-hierarchical schemes, the path will be everything
following the scheme declaration, as in the following example:
- \img qurl-mailtopath.png
+ \image qurl-mailtopath.png
\sa path()
*/
@@ -1862,7 +1932,7 @@ QString QUrl::query(ComponentFormattingOptions options) const
characters. It is typically used in HTTP for referring to a
certain link or point on a page:
- \img qurl-fragment.png
+ \image qurl-fragment.png
The fragment is sometimes also referred to as the URL "reference".
@@ -1938,7 +2008,7 @@ QString QUrl::topLevelDomain(ComponentFormattingOptions options) const
the base URL, but with the merged path, as in the following
example:
- \snippet doc/src/snippets/code/src_corelib_io_qurl.cpp 5
+ \snippet code/src_corelib_io_qurl.cpp 5
Calling resolved() with ".." returns a QUrl whose directory is
one level higher than the original. Similarly, calling resolved()
@@ -2012,14 +2082,16 @@ QUrl QUrl::resolved(const QUrl &relative) const
}
/*!
- Returns true if the URL is relative; otherwise returns false. A
- URL is relative if its scheme is undefined; this function is
- therefore equivalent to calling scheme().isEmpty().
+ Returns true if the URL is relative; otherwise returns false. A URL is
+ relative reference if its scheme is undefined; this function is therefore
+ equivalent to calling scheme().isEmpty().
+
+ Relative references are defined in RFC 3986 section 4.2.
*/
bool QUrl::isRelative() const
{
if (!d) return true;
- return !d->hasScheme() && !d->path.startsWith(QLatin1Char('/'));
+ return !d->hasScheme();
}
/*!
@@ -2173,7 +2245,7 @@ QString QUrl::fromPercentEncoding(const QByteArray &input)
Unreserved is defined as:
ALPHA / DIGIT / "-" / "." / "_" / "~"
- \snippet doc/src/snippets/code/src_corelib_io_qurl.cpp 6
+ \snippet code/src_corelib_io_qurl.cpp 6
*/
QByteArray QUrl::toPercentEncoding(const QString &input, const QByteArray &exclude, const QByteArray &include)
{
@@ -2429,6 +2501,9 @@ QUrl QUrl::fromLocalFile(const QString &localFile)
returned value in the form found on SMB networks (for example,
"//servername/path/to/file.txt").
+ Note: if the path component of this URL contains a non-UTF-8 binary
+ sequence (such as %80), the behaviour of this function is undefined.
+
\sa fromLocalFile(), isLocalFile()
*/
QString QUrl::toLocalFile() const
@@ -2438,19 +2513,35 @@ QString QUrl::toLocalFile() const
return QString();
QString tmp;
- QString ourPath = path();
+ QString ourPath = path(QUrl::MostDecoded);
// magic for shared drive on windows
if (!d->host.isEmpty()) {
- tmp = QStringLiteral("//") + d->host + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/')
+ tmp = QStringLiteral("//") + host() + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/')
? QLatin1Char('/') + ourPath : ourPath);
} else {
tmp = ourPath;
+#ifdef Q_OS_WIN
// magic for drives on windows
if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':'))
tmp.remove(0, 1);
+#endif
}
+ // check if we need to do one more decoding pass
+ int pct = tmp.indexOf(QLatin1Char('%'));
+ while (pct != -1) {
+ Q_ASSERT(tmp.size() >= pct + 2);
+ ushort char1 = tmp.at(pct + 1).unicode();
+ ushort char2 = tmp.at(pct + 2).unicode();
+
+ Q_ASSERT(isHex(char1) && char1 < 0x80u);
+ Q_ASSERT(isHex(char2) && char2 < 0x80u);
+ tmp.replace(pct, 3, QChar(fromHex(char1) << 4 | fromHex(char2)));
+
+ // next iteration
+ pct = tmp.indexOf(QLatin1Char('%'), pct + 1);
+ }
return tmp;
}
diff --git a/src/corelib/io/qurl_p.h b/src/corelib/io/qurl_p.h
index 201ee66238..3a0d80d7ef 100644
--- a/src/corelib/io/qurl_p.h
+++ b/src/corelib/io/qurl_p.h
@@ -108,7 +108,6 @@ public:
QUrlPrivate(const QUrlPrivate &copy);
void parse(const QString &url, QUrl::ParsingMode parsingMode);
- void clear();
bool isEmpty() const
{ return sectionIsPresent == 0 && port == -1 && path.isEmpty(); }
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 3d9af90682..dc53021432 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -339,7 +339,7 @@ qint64 QPersistentModelIndex::internalId() const
Returns the parent QModelIndex for this persistent index, or an invalid
QModelIndex if it has no parent.
- \sa child() sibling() model()
+ \sa child(), sibling(), model()
*/
QModelIndex QPersistentModelIndex::parent() const
{
@@ -352,7 +352,7 @@ QModelIndex QPersistentModelIndex::parent() const
Returns the sibling at \a row and \a column or an invalid QModelIndex if
there is no sibling at this position.
- \sa parent() child()
+ \sa parent(), child()
*/
QModelIndex QPersistentModelIndex::sibling(int row, int column) const
@@ -366,7 +366,7 @@ QModelIndex QPersistentModelIndex::sibling(int row, int column) const
Returns the child of the model index that is stored in the given \a row
and \a column.
- \sa parent() sibling()
+ \sa parent(), sibling()
*/
QModelIndex QPersistentModelIndex::child(int row, int column) const
@@ -906,7 +906,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
Creates a new empty model index. This type of model index is used to
indicate that the position in the model is invalid.
- \sa isValid() QAbstractItemModel
+ \sa isValid(), QAbstractItemModel
*/
/*!
@@ -1217,7 +1217,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
Returns true if the column is inserted; otherwise returns false.
- \sa insertColumns() insertRow() removeColumn()
+ \sa insertColumns(), insertRow(), removeColumn()
*/
/*!
@@ -1230,7 +1230,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
Returns true if the row is inserted; otherwise returns false.
- \sa insertRows() insertColumn() removeRow()
+ \sa insertRows(), insertColumn(), removeRow()
*/
/*!
@@ -1407,7 +1407,7 @@ QAbstractItemModel::~QAbstractItemModel()
For example:
- \snippet examples/itemviews/simpledommodel/dommodel.cpp 2
+ \snippet itemviews/simpledommodel/dommodel.cpp 2
\note When implementing a table based model, columnCount() should return 0
when the parent is valid.
@@ -1627,7 +1627,7 @@ bool QAbstractItemModel::hasIndex(int row, int column, const QModelIndex &parent
Use rowCount() on the parent to find out the number of children.
- \sa parent() index()
+ \sa parent(), index()
*/
bool QAbstractItemModel::hasChildren(const QModelIndex &parent) const
{
@@ -1696,7 +1696,7 @@ bool QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value
Roles that are not in \a roles will not be modified.
- \sa setData() data() itemData()
+ \sa setData(), data(), itemData()
*/
bool QAbstractItemModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
{
@@ -2195,6 +2195,7 @@ QSize QAbstractItemModel::span(const QModelIndex &) const
}
/*!
+ \fn void QAbstractItemModel::setRoleNames(const QHash<int,QByteArray> &theRoleNames)
\since 4.6
\obsolete
@@ -2445,7 +2446,7 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare
For example, as shown in the diagram, we insert three rows before
row 2, so \a first is 2 and \a last is 4:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 0
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 0
This inserts the three new rows as rows 2, 3, and 4.
\row
@@ -2456,7 +2457,7 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare
collection of 4 existing rows (ending in row 3), so \a first is 4
and \a last is 5:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 1
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 1
This appends the two new rows as rows 4 and 5.
\endtable
@@ -2511,7 +2512,7 @@ void QAbstractItemModel::endInsertRows()
For example, as shown in the diagram, we remove the two rows from
row 2 to row 3, so \a first is 2 and \a last is 3:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 2
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 2
\endtable
\note This function emits the rowsAboutToBeRemoved() signal which connected
@@ -2626,7 +2627,7 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star
row 2 to 4 in the source, so \a sourceFirst is 2 and \a sourceLast is 4.
We move those items to above row 2 in the destination, so \a destinationChild is 2.
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 6
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 6
This moves the three rows rows 2, 3, and 4 in the source to become 2, 3 and 4 in
the destination. Other affected siblings are displaced accordingly.
@@ -2637,7 +2638,7 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star
For example, as shown in the diagram, we move three rows to a
collection of 6 existing rows (ending in row 5), so \a destinationChild is 6:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 7
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 7
This moves the target rows to the end of the target parent as 6, 7 and 8.
\row
@@ -2647,7 +2648,7 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star
For example, as shown in the diagram, we move one item from row 2 to row 0,
so \a sourceFirst and \a sourceLast are 2 and \a destinationChild is 0.
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 8
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 8
Note that other rows may be displaced accordingly. Note also that when moving
items within the same parent you should not attempt invalid or no-op moves. In
@@ -2662,7 +2663,7 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star
For example, as shown in the diagram, we move one item from row 2 to row 4,
so \a sourceFirst and \a sourceLast are 2 and \a destinationChild is 4.
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 9
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 9
Note that other rows may be displaced accordingly.
\endtable
@@ -2745,7 +2746,7 @@ void QAbstractItemModel::endMoveRows()
For example, as shown in the diagram, we insert three columns
before column 4, so \a first is 4 and \a last is 6:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 3
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 3
This inserts the three new columns as columns 4, 5, and 6.
\row
@@ -2756,7 +2757,7 @@ void QAbstractItemModel::endMoveRows()
collection of six existing columns (ending in column 5), so
\a first is 6 and \a last is 8:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 4
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 4
This appends the two new columns as columns 6, 7, and 8.
\endtable
@@ -2813,7 +2814,7 @@ void QAbstractItemModel::endInsertColumns()
For example, as shown in the diagram, we remove the three columns
from column 4 to column 6, so \a first is 4 and \a last is 6:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 5
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 5
\endtable
\note This function emits the columnsAboutToBeRemoved() signal which
@@ -2945,6 +2946,7 @@ void QAbstractItemModel::endMoveColumns()
}
/*!
+ \fn void QAbstractItemModel::reset()
\obsolete
Resets the model to its original state in any attached views.
@@ -2958,11 +2960,11 @@ void QAbstractItemModel::endMoveColumns()
For example, in this code both signals modelAboutToBeReset() and modelReset()
are emitted \e after the data changes:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 10
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 10
Instead you should use:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 11
+ \snippet code/src_corelib_kernel_qabstractitemmodel.cpp 11
*/
/*!
@@ -3208,7 +3210,7 @@ QModelIndex QAbstractTableModel::index(int row, int column, const QModelIndex &p
Returns the parent of the model item with the given \a index.
- \sa index() hasChildren()
+ \sa index(), hasChildren()
*/
QModelIndex QAbstractTableModel::parent(const QModelIndex &) const
@@ -3334,7 +3336,7 @@ QModelIndex QAbstractListModel::index(int row, int column, const QModelIndex &pa
/*!
Returns the parent of the model item with the given \a index.
- \sa index() hasChildren()
+ \sa index(), hasChildren()
*/
QModelIndex QAbstractListModel::parent(const QModelIndex & /* index */) const
diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp
index 9cac40469a..c7a5200933 100644
--- a/src/corelib/itemmodels/qidentityproxymodel.cpp
+++ b/src/corelib/itemmodels/qidentityproxymodel.cpp
@@ -102,7 +102,7 @@ class QIdentityProxyModelPrivate : public QAbstractProxyModelPrivate
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
+ \snippet code/src_gui_itemviews_qidentityproxymodel.cpp 0
\sa QAbstractProxyModel, {Model/View Programming}, QAbstractItemModel
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index fa34acdd18..9cc9502577 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -347,13 +347,13 @@ QModelIndexList QItemSelectionRange::indexes() const
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
+ \snippet 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
+ \snippet 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
@@ -1005,7 +1005,7 @@ void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::
Note that this signal will not be emitted when the item model is reset.
- \sa currentIndex() setCurrentIndex() selectionChanged()
+ \sa currentIndex(), setCurrentIndex(), selectionChanged()
*/
/*!
@@ -1016,7 +1016,7 @@ void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::
Note that this signal will not be emitted when the item model is reset.
- \sa currentChanged() currentRowChanged() currentIndex() setCurrentIndex()
+ \sa currentChanged(), currentRowChanged(), currentIndex(), setCurrentIndex()
*/
/*!
@@ -1027,7 +1027,7 @@ void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::
Note that this signal will not be emitted when the item model is reset.
- \sa currentChanged() currentColumnChanged() currentIndex() setCurrentIndex()
+ \sa currentChanged(), currentColumnChanged(), currentIndex(), setCurrentIndex()
*/
/*!
@@ -1040,7 +1040,7 @@ void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::
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()
+ \sa select(), currentChanged()
*/
/*!
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index ae9affb862..68e5e89db3 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -1511,14 +1511,14 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved(
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
+ \snippet 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
+ \snippet qsortfilterproxymodel-details/main.cpp 0
+ \snippet 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
@@ -1546,7 +1546,7 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved(
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
+ \snippet 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
@@ -1569,7 +1569,7 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved(
QSortFilterProxyModel and reimplementing lessThan(), which is
used to compare items. For example:
- \snippet examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 5
+ \snippet itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 5
(This code snippet comes from the
\l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model}
@@ -1581,7 +1581,7 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved(
QSortFilterProxyModel (or on the original model if it implements sort()).
For example:
- \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 4
+ \snippet 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.
@@ -1594,7 +1594,7 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved(
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
+ \snippet 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
@@ -1612,7 +1612,7 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved(
the \l{QSortFilterProxyModel::filterKeyColumn}{filterKeyColumn} property
and performs filtering on columns 0, 1, and 2:
- \snippet examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 3
+ \snippet itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 3
(This code snippet comes from the
\l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model}
diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp
index b13e825c05..e7f219f471 100644
--- a/src/corelib/itemmodels/qstringlistmodel.cpp
+++ b/src/corelib/itemmodels/qstringlistmodel.cpp
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
An example usage of QStringListModel:
- \snippet doc/src/snippets/qstringlistmodel/main.cpp 0
+ \snippet qstringlistmodel/main.cpp 0
\sa QAbstractListModel, QAbstractItemModel, {Model Classes}
*/
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index 0884f10354..e1ed53a840 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -500,13 +500,13 @@ bool QJsonArray::operator!=(const QJsonArray &other) const
\sa constBegin(), end()
*/
-/*! \fn void QJsonArray::push_back(const T &value)
+/*! \fn void QJsonArray::push_back(const QJsonValue &value)
This function is provided for STL compatibility. It is equivalent
to \l{QJsonArray::append()}{append(\a value)}.
*/
-/*! \fn void QJsonArray::push_front(const T &value)
+/*! \fn void QJsonArray::push_front(const QJsonValue &value)
This function is provided for STL compatibility. It is equivalent
to \l{QJsonArray::prepend()}{prepend(\a value)}.
@@ -589,12 +589,7 @@ bool QJsonArray::operator!=(const QJsonArray &other) const
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QJsonArray::begin() QJsonArray::end()
-*/
-
-/*! \fn QJsonArray::iterator::iterator(const iterator &other)
-
- Constructs a copy of \a other.
+ \sa QJsonArray::begin(), QJsonArray::end()
*/
/*! \fn QJsonValueRef QJsonArray::iterator::operator*() const
@@ -791,7 +786,7 @@ bool QJsonArray::operator!=(const QJsonArray &other) const
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QJsonArray::constBegin() QJsonArray::constEnd()
+ \sa QJsonArray::constBegin(), QJsonArray::constEnd()
*/
/*! \typedef QJsonArray::const_iterator::iterator_category
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index be241bc3fc..ae59847dc6 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -176,7 +176,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other)
Returns a QJsonDocument representing the data.
- \sa rawData fromBinaryData isNull DataValidation
+ \sa rawData, fromBinaryData, isNull, DataValidation
*/
QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation)
{
@@ -220,7 +220,7 @@ const char *QJsonDocument::rawData(int *size) const
By default the data is validated. If the \a data is not valid, the method returns
a null document.
- \sa toBinaryData fromRawData isNull DataValidation
+ \sa toBinaryData, fromRawData, isNull, DataValidation
*/
QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidation validation)
{
@@ -361,7 +361,7 @@ QByteArray QJsonDocument::toBinaryData() const
/*!
Returns true if the document contains an array.
- \sa array() isObject()
+ \sa array(), isObject()
*/
bool QJsonDocument::isArray() const
{
@@ -375,7 +375,7 @@ bool QJsonDocument::isArray() const
/*!
Returns true if the document contains an object.
- \sa object() isArray()
+ \sa object(), isArray()
*/
bool QJsonDocument::isObject() const
{
@@ -392,7 +392,7 @@ bool QJsonDocument::isObject() const
Returns an empty object if the document contains an
array.
- \sa isObject array setObject
+ \sa isObject, array, setObject
*/
QJsonObject QJsonDocument::object() const
{
@@ -410,7 +410,7 @@ QJsonObject QJsonDocument::object() const
Returns an empty array if the document contains an
object.
- \sa isArray object setArray
+ \sa isArray, object, setArray
*/
QJsonArray QJsonDocument::array() const
{
@@ -425,7 +425,7 @@ QJsonArray QJsonDocument::array() const
/*!
Sets \a object as the main object of this document.
- \sa setArray object
+ \sa setArray, object
*/
void QJsonDocument::setObject(const QJsonObject &object)
{
@@ -452,7 +452,7 @@ void QJsonDocument::setObject(const QJsonObject &object)
/*!
Sets \a array as the main object of this document.
- \sa setObject array
+ \sa setObject, array
*/
void QJsonDocument::setArray(const QJsonArray &array)
{
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index e880078195..5439855b90 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
/*!
Constructs an empty JSON object
- \sa isEmpty
+ \sa isEmpty()
*/
QJsonObject::QJsonObject()
: d(0), o(0)
@@ -139,7 +139,7 @@ QJsonObject &QJsonObject::operator =(const QJsonObject &other)
The keys in \a map will be used as the keys in the JSON object,
and the QVariant values will be converted to JSON values.
- \sa toVariantMap, QJsonValue::fromVariant
+ \sa toVariantMap(), QJsonValue::fromVariant()
*/
QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map)
{
@@ -200,7 +200,7 @@ int QJsonObject::size() const
/*!
Returns \c true if the object is empty. This is the same as size() == 0.
- \sa size
+ \sa size()
*/
bool QJsonObject::isEmpty() const
{
@@ -215,7 +215,7 @@ bool QJsonObject::isEmpty() const
The returned QJsonValue is \c Undefined, if the key does not exist.
- \sa setValue, QJsonValue, QJsonValue::isUndefined
+ \sa QJsonValue, QJsonValue::isUndefined()
*/
QJsonValue QJsonObject::value(const QString &key) const
{
@@ -236,7 +236,7 @@ QJsonValue QJsonObject::value(const QString &key) const
The returned QJsonValue is \c Undefined, if the key does not exist.
- \sa value, setValue, QJsonValue, QJsonValue::isUndefined
+ \sa value(), QJsonValue, QJsonValue::isUndefined()
*/
QJsonValue QJsonObject::operator [](const QString &key) const
{
@@ -252,7 +252,7 @@ QJsonValue QJsonObject::operator [](const QString &key) const
the assignment will apply to the character in the QJsonArray of QJsonObject
from which you got the reference.
- \sa setValue, value
+ \sa value()
*/
QJsonValueRef QJsonObject::operator [](const QString &key)
{
@@ -277,7 +277,7 @@ QJsonValueRef QJsonObject::operator [](const QString &key)
If the value is QJsonValue::Undefined, it will cause the key to get removed
from the object. The returned iterator will then point to end()
- \sa remove, take, QJsonObject::iterator, end
+ \sa remove(), take(), QJsonObject::iterator, end()
*/
QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &value)
{
@@ -320,7 +320,7 @@ QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &
/*!
Removes \a key from the object.
- \sa insert, take
+ \sa insert(), take()
*/
void QJsonObject::remove(const QString &key)
{
@@ -346,7 +346,7 @@ void QJsonObject::remove(const QString &key)
If \a key was not contained in the object, the returned QJsonValue
is Undefined.
- \sa insert, remove, QJsonValue
+ \sa insert(), remove(), QJsonValue
*/
QJsonValue QJsonObject::take(const QString &key)
{
@@ -370,7 +370,7 @@ QJsonValue QJsonObject::take(const QString &key)
/*!
Returns \c true if the object contains key \a key.
- \sa insert, remove, take
+ \sa insert(), remove(), take()
*/
bool QJsonObject::contains(const QString &key) const
{
@@ -455,7 +455,7 @@ QJsonObject::iterator QJsonObject::find(const QString &key)
return iterator(this, index);
}
-/*! \fn QJsonObject::const_iterator QJsonObject::find(const Key &key) const
+/*! \fn QJsonObject::const_iterator QJsonObject::find(const QString &key) const
\overload
*/
@@ -541,6 +541,10 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
*/
/*! \class QJsonObject::iterator
+ \ingroup json
+ \reentrant
+ \since 5.0
+
\brief The QJsonObject::iterator class provides an STL-style non-const iterator for QJsonObject.
QJsonObject::iterator allows you to iterate over a QJsonObject
@@ -591,7 +595,7 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QJsonObject::begin() QJsonObject::end()
+ \sa QJsonObject::begin(), QJsonObject::end()
*/
/*! \fn QString QJsonObject::iterator::key() const
@@ -729,7 +733,8 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
\sa operator+=(), operator-()
*/
-/*! \class QJsonObject::const_iterator
+/*!
+ \class QJsonObject::const_iterator
\brief The QJsonObject::const_iterator class provides an STL-style const iterator for QJsonObject.
QJsonObject::const_iterator allows you to iterate over a QJsonObject.
@@ -780,7 +785,7 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QJsonObject::constBegin() QJsonObject::constEnd()
+ \sa QJsonObject::constBegin(), QJsonObject::constEnd()
*/
/*! \fn QJsonObject::const_iterator::const_iterator(const iterator &other)
@@ -987,17 +992,6 @@ void QJsonObject::setValueAt(int i, const QJsonValue &val)
Qt-style synonym for QJsonObject::const_iterator.
*/
-
-/*! \class QJsonObject::iterator
- \ingroup json
- \reentrant
- \since 5.0
-
- \brief The QJsonDocument::iterator class provides a way to iterate over q QJsonObject
-
-
- */
-
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QJsonObject &o)
{
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 4b81087e2f..b645d480d7 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -14,6 +14,7 @@ HEADERS += \
kernel/qobject.h \
kernel/qobject_impl.h \
kernel/qobjectdefs.h \
+ kernel/qobjectdefs_impl.h \
kernel/qsignalmapper.h \
kernel/qsocketnotifier.h \
kernel/qtimer.h \
@@ -136,3 +137,10 @@ vxworks {
kernel/qfunctions_vxworks.h
}
+blackberry {
+ SOURCES += \
+ kernel/qeventdispatcher_blackberry.cpp
+ HEADERS += \
+ kernel/qeventdispatcher_blackberry_p.h
+}
+
diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp
index cf9b0cea4f..2ef98dba0f 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.cpp
+++ b/src/corelib/kernel/qabstracteventdispatcher.cpp
@@ -374,7 +374,7 @@ void QAbstractEventDispatcher::closingDown()
Typedef for a function with the signature
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp 0
+ \snippet code/src_corelib_kernel_qabstracteventdispatcher.cpp 0
Note that the type of the \a message is platform dependent. The
following table shows the \a {message}'s type on Windows, Mac, and
@@ -460,7 +460,7 @@ bool QAbstractEventDispatcher::filterEvent(void *message)
This signal is emitted after the event loop returns from a
function that could block.
- \sa wakeUp() aboutToBlock()
+ \sa wakeUp(), aboutToBlock()
*/
/*! \fn void QAbstractEventDispatcher::aboutToBlock()
diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp
index 621223eb88..76db945c45 100644
--- a/src/corelib/kernel/qbasictimer.cpp
+++ b/src/corelib/kernel/qbasictimer.cpp
@@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE
Returns true if the timer is running and has not been stopped; otherwise
returns false.
- \sa start() stop()
+ \sa start(), stop()
*/
/*!
@@ -112,7 +112,7 @@ QT_BEGIN_NAMESPACE
The given \a object will receive timer events.
- \sa stop() isActive() QObject::timerEvent() Qt::CoarseTimer
+ \sa stop(), isActive(), QObject::timerEvent(), Qt::CoarseTimer
*/
void QBasicTimer::start(int msec, QObject *obj)
{
@@ -139,7 +139,7 @@ void QBasicTimer::start(int msec, QObject *obj)
The given \a object will receive timer events.
- \sa stop() isActive() QObject::timerEvent() Qt::TimerType
+ \sa stop(), isActive(), QObject::timerEvent(), Qt::TimerType
*/
void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
{
@@ -160,7 +160,7 @@ void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
/*!
Stops the timer.
- \sa start() isActive()
+ \sa start(), isActive()
*/
void QBasicTimer::stop()
{
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index 048d746183..3fc1b7f801 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -63,7 +63,7 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
-#ifndef QT_NO_CORESERVICES
+#ifndef Q_OS_IOS
#include <CoreServices/CoreServices.h>
#endif
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 56674bc08e..5d70c4c5d8 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -67,10 +67,14 @@
#include <private/qlocale_p.h>
#if defined(Q_OS_UNIX)
-# if !defined(QT_NO_GLIB)
-# include "qeventdispatcher_glib_p.h"
+# if defined(Q_OS_BLACKBERRY)
+# include "qeventdispatcher_blackberry_p.h"
+# else
+# if !defined(QT_NO_GLIB)
+# include "qeventdispatcher_glib_p.h"
+# endif
+# include "qeventdispatcher_unix_p.h"
# endif
-# include "qeventdispatcher_unix_p.h"
#endif
#ifdef Q_OS_WIN
@@ -328,12 +332,16 @@ void QCoreApplicationPrivate::createEventDispatcher()
{
Q_Q(QCoreApplication);
#if defined(Q_OS_UNIX)
+# if defined(Q_OS_BLACKBERRY)
+ eventDispatcher = new QEventDispatcherBlackberry(q);
+# else
# if !defined(QT_NO_GLIB)
if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
eventDispatcher = new QEventDispatcherGlib(q);
else
# endif
eventDispatcher = new QEventDispatcherUNIX(q);
+# endif
#elif defined(Q_OS_WIN)
eventDispatcher = new QEventDispatcherWin32(q);
#else
@@ -1000,7 +1008,7 @@ void QCoreApplication::exit(int returnCode)
The event is \e not deleted when the event has been sent. The normal
approach is to create the event on the stack, for example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 0
+ \snippet code/src_corelib_kernel_qcoreapplication.cpp 0
\sa postEvent(), notify()
*/
@@ -1473,7 +1481,7 @@ void QCoreApplicationPrivate::maybeQuit()
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 1
+ \snippet code/src_corelib_kernel_qcoreapplication.cpp 1
\sa exit(), aboutToQuit(), QApplication::lastWindowClosed()
*/
@@ -1521,7 +1529,7 @@ void QCoreApplication::quit()
The function returns true on success and false on failure.
- \sa removeTranslator() translate() QTranslator::load() {Dynamic Translation}
+ \sa removeTranslator(), translate(), QTranslator::load(), {Dynamic Translation}
*/
bool QCoreApplication::installTranslator(QTranslator *translationFile)
@@ -1634,7 +1642,7 @@ static void replacePercentN(QString *result, int n)
so will most likely result in crashes or other undesirable
behavior.
- \sa QObject::tr() installTranslator()
+ \sa QObject::tr(), installTranslator()
*/
@@ -1910,7 +1918,7 @@ QStringList QCoreApplication::arguments()
organizationName(). On all other platforms, QSettings uses
organizationName() as the organization.
- \sa organizationDomain applicationName
+ \sa organizationDomain, applicationName
*/
void QCoreApplication::setOrganizationName(const QString &orgName)
@@ -1936,7 +1944,7 @@ QString QCoreApplication::organizationName()
On all other platforms, QSettings uses organizationName() as the
organization.
- \sa organizationName applicationName applicationVersion
+ \sa organizationName, applicationName, applicationVersion
*/
void QCoreApplication::setOrganizationDomain(const QString &orgDomain)
{
@@ -1958,7 +1966,7 @@ QString QCoreApplication::organizationDomain()
If not set, the application name defaults to the executable name (since 5.0).
- \sa organizationName organizationDomain applicationVersion applicationFilePath
+ \sa organizationName, organizationDomain, applicationVersion, applicationFilePath
*/
void QCoreApplication::setApplicationName(const QString &application)
{
@@ -1984,7 +1992,7 @@ Q_CORE_EXPORT QString qt_applicationName_noFallback()
\since 4.4
\brief the version of this application
- \sa applicationName organizationName organizationDomain
+ \sa applicationName, organizationName, organizationDomain
*/
void QCoreApplication::setApplicationVersion(const QString &version)
{
@@ -2018,7 +2026,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMutex, libraryPathMutex, (QMutex::Recursive))
If you want to iterate over the list, you can use the \l foreach
pseudo-keyword:
- \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 2
+ \snippet code/src_corelib_kernel_qcoreapplication.cpp 2
\sa setLibraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary,
{How to Create Qt Plugins}
@@ -2140,7 +2148,7 @@ void QCoreApplication::removeLibraryPath(const QString &path)
A function with the following signature that can be used as an
event filter:
- \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 3
+ \snippet code/src_corelib_kernel_qcoreapplication.cpp 3
\sa setEventFilter()
*/
@@ -2275,7 +2283,7 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
The function specified by \a ptr should take no arguments and should
return nothing. For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 4
+ \snippet code/src_corelib_kernel_qcoreapplication.cpp 4
Note that for an application- or module-wide cleanup,
qAddPostRoutine() is often not suitable. For example, if the
@@ -2289,7 +2297,7 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
parent-child mechanism to call a cleanup function at the right
time:
- \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 5
+ \snippet code/src_corelib_kernel_qcoreapplication.cpp 5
By selecting the right parent object, this can often be made to
clean up the module's data at the right moment.
@@ -2303,7 +2311,7 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
translation functions, \c tr() and \c trUtf8(), with these
signatures:
- \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 6
+ \snippet code/src_corelib_kernel_qcoreapplication.cpp 6
This macro is useful if you want to use QObject::tr() or
QObject::trUtf8() in classes that don't inherit from QObject.
@@ -2312,7 +2320,7 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
class definition (before the first \c{public:} or \c{protected:}).
For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 7
+ \snippet code/src_corelib_kernel_qcoreapplication.cpp 7
The \a context parameter is normally the class name, but it can
be any string.
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
new file mode 100644
index 0000000000..462e359bf3
--- /dev/null
+++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** 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_blackberry_p.h"
+#include "qsocketnotifier.h"
+#include "qdebug.h"
+
+#include <bps/bps.h>
+#include <bps/event.h>
+
+struct bpsIOHandlerData {
+ bpsIOHandlerData()
+ : count(0), readfds(0), writefds(0), exceptfds(0)
+ {
+ }
+
+ int count;
+ fd_set *readfds;
+ fd_set *writefds;
+ fd_set *exceptfds;
+};
+
+static int bpsIOReadyDomain = -1;
+
+static int bpsIOHandler(int fd, int io_events, void *data)
+{
+ // decode callback payload
+ bpsIOHandlerData *ioData = static_cast<bpsIOHandlerData*>(data);
+
+ // check if first file is ready
+ bool firstReady = (ioData->count == 0);
+
+ // update ready state of file
+ if (io_events & BPS_IO_INPUT) {
+ FD_SET(fd, ioData->readfds);
+ ioData->count++;
+ }
+
+ if (io_events & BPS_IO_OUTPUT) {
+ FD_SET(fd, ioData->writefds);
+ ioData->count++;
+ }
+
+ if (io_events & BPS_IO_EXCEPT) {
+ FD_SET(fd, ioData->exceptfds);
+ ioData->count++;
+ }
+
+ // force bps_get_event() to return immediately by posting an event to ourselves;
+ // but this only needs to happen once if multiple files become ready at the same time
+ if (firstReady) {
+ // create IO ready event
+ bps_event_t *event;
+ int result = bps_event_create(&event, bpsIOReadyDomain, 0, NULL, NULL);
+ if (result != BPS_SUCCESS) {
+ qWarning("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_event_create() failed");
+ return BPS_FAILURE;
+ }
+
+ // post IO ready event to our thread
+ result = bps_push_event(event);
+ if (result != BPS_SUCCESS) {
+ qWarning("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_push_event() failed");
+ bps_event_destroy(event);
+ return BPS_FAILURE;
+ }
+ }
+
+ return BPS_SUCCESS;
+}
+
+QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberryPrivate()
+ : ioData(new bpsIOHandlerData)
+{
+ // prepare to use BPS
+ int result = bps_initialize();
+ if (result != BPS_SUCCESS)
+ qFatal("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_initialize() failed");
+
+ // get domain for IO ready events - ignoring race condition here for now
+ if (bpsIOReadyDomain == -1) {
+ bpsIOReadyDomain = bps_register_domain();
+ if (bpsIOReadyDomain == -1)
+ qWarning("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_register_domain() failed");
+ }
+
+ // \TODO Reinstate this when bps is fixed. See comment in select() below.
+ // Register thread_pipe[0] with bps
+ /*
+ int io_events = BPS_IO_INPUT;
+ result = bps_add_fd(thread_pipe[0], io_events, &bpsIOHandler, ioData.data());
+ if (result != BPS_SUCCESS)
+ qWarning() << Q_FUNC_INFO << "bps_add_fd() failed";
+ */
+}
+
+QEventDispatcherBlackberryPrivate::~QEventDispatcherBlackberryPrivate()
+{
+ // we're done using BPS
+ bps_shutdown();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+QEventDispatcherBlackberry::QEventDispatcherBlackberry(QObject *parent)
+ : QEventDispatcherUNIX(*new QEventDispatcherBlackberryPrivate, parent)
+{
+}
+
+QEventDispatcherBlackberry::QEventDispatcherBlackberry(QEventDispatcherBlackberryPrivate &dd, QObject *parent)
+ : QEventDispatcherUNIX(dd, parent)
+{
+}
+
+QEventDispatcherBlackberry::~QEventDispatcherBlackberry()
+{
+}
+
+void QEventDispatcherBlackberry::registerSocketNotifier(QSocketNotifier *notifier)
+{
+ Q_ASSERT(notifier);
+
+ // Call the base Unix implementation. Needed to allow select() to be called correctly
+ QEventDispatcherUNIX::registerSocketNotifier(notifier);
+
+ // Register the fd with bps
+ int sockfd = notifier->socket();
+ int type = notifier->type();
+
+ int io_events = 0;
+ switch (type) {
+ case QSocketNotifier::Read:
+ io_events |= BPS_IO_INPUT;
+ break;
+ case QSocketNotifier::Write:
+ io_events |= BPS_IO_OUTPUT;
+ break;
+ case QSocketNotifier::Exception:
+ default:
+ io_events |= BPS_IO_EXCEPT;
+ break;
+ }
+
+ Q_D(QEventDispatcherBlackberry);
+ int result = bps_add_fd(sockfd, io_events, &bpsIOHandler, d->ioData.data());
+ if (result != BPS_SUCCESS)
+ qWarning() << Q_FUNC_INFO << "bps_add_fd() failed";
+}
+
+void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier *notifier)
+{
+ // Unregister the fd with bps
+ int sockfd = notifier->socket();
+ int result = bps_remove_fd(sockfd);
+ if (result != BPS_SUCCESS)
+ qWarning() << Q_FUNC_INFO << "bps_remove_fd() failed";
+
+ // Allow the base Unix implementation to unregister the fd too
+ QEventDispatcherUNIX::unregisterSocketNotifier(notifier);
+}
+
+int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ timeval *timeout)
+{
+ Q_UNUSED(nfds);
+
+ // prepare file sets for bps callback
+ Q_D(QEventDispatcherBlackberry);
+ d->ioData->count = 0;
+ d->ioData->readfds = readfds;
+ d->ioData->writefds = writefds;
+ d->ioData->exceptfds = exceptfds;
+
+ // \TODO Remove this when bps is fixed
+ //
+ // Work around a bug in BPS with which if we register the thread_pipe[0] fd with bps in the
+ // private class' ctor once only then we get spurious notifications that thread_pipe[0] is
+ // ready for reading. The first time the notification is correct and the pipe is emptied in
+ // the calling doSelect() function. The 2nd notification is an error and the resulting attempt
+ // to read and call to wakeUps.testAndSetRelease(1, 0) fails as there has been no intervening
+ // call to QEventDispatcherUNIX::wakeUp().
+ //
+ // Registering thread_pipe[0] here and unregistering it at the end of this call works around
+ // this issue.
+ int io_events = BPS_IO_INPUT;
+ int result = bps_add_fd(d->thread_pipe[0], io_events, &bpsIOHandler, d->ioData.data());
+ if (result != BPS_SUCCESS)
+ qWarning() << Q_FUNC_INFO << "bps_add_fd() failed";
+
+ // reset all file sets
+ if (readfds)
+ FD_ZERO(readfds);
+
+ if (writefds)
+ FD_ZERO(writefds);
+
+ if (exceptfds)
+ FD_ZERO(exceptfds);
+
+ // convert timeout to milliseconds
+ int timeout_ms = -1;
+ if (timeout)
+ timeout_ms = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000);
+
+ // wait for event or file to be ready
+ bps_event_t *event = NULL;
+ result = bps_get_event(&event, timeout_ms);
+ if (result != BPS_SUCCESS)
+ qWarning("QEventDispatcherBlackberry::select: bps_get_event() failed");
+
+ // pass all received events through filter - except IO ready events
+ if (event && bps_event_get_domain(event) != bpsIOReadyDomain)
+ filterEvent((void*)event);
+
+ // \TODO Remove this when bps is fixed (see comment above)
+ result = bps_remove_fd(d->thread_pipe[0]);
+ if (result != BPS_SUCCESS)
+ qWarning() << Q_FUNC_INFO << "bps_remove_fd() failed";
+
+ // the number of bits set in the file sets
+ return d->ioData->count;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry_p.h b/src/corelib/kernel/qeventdispatcher_blackberry_p.h
new file mode 100644
index 0000000000..b996bc7ee7
--- /dev/null
+++ b/src/corelib/kernel/qeventdispatcher_blackberry_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** 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_BLACKBERRY_P_H
+#define QEVENTDISPATCHER_BLACKBERRY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qeventdispatcher_unix_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QEventDispatcherBlackberryPrivate;
+
+class Q_CORE_EXPORT QEventDispatcherBlackberry : public QEventDispatcherUNIX
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QEventDispatcherBlackberry)
+
+public:
+ explicit QEventDispatcherBlackberry(QObject *parent = 0);
+ ~QEventDispatcherBlackberry();
+
+ void registerSocketNotifier(QSocketNotifier *notifier);
+ void unregisterSocketNotifier(QSocketNotifier *notifier);
+
+protected:
+ QEventDispatcherBlackberry(QEventDispatcherBlackberryPrivate &dd, QObject *parent = 0);
+
+ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ timeval *timeout);
+};
+
+struct bpsIOHandlerData;
+
+class Q_CORE_EXPORT QEventDispatcherBlackberryPrivate : public QEventDispatcherUNIXPrivate
+{
+ Q_DECLARE_PUBLIC(QEventDispatcherBlackberry)
+
+public:
+ QEventDispatcherBlackberryPrivate();
+ ~QEventDispatcherBlackberryPrivate();
+
+ QScopedPointer<bpsIOHandlerData> ioData;
+};
+
+QT_END_NAMESPACE
+
+#endif // QEVENTDISPATCHER_BLACKBERRY_P_H
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index d3a64aae04..deea463061 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -275,7 +275,7 @@ void QEventLoop::exit(int returnCode)
false. The event loop is considered running from the time when
exec() is called until exit() is called.
- \sa exec() exit()
+ \sa exec(), exit()
*/
bool QEventLoop::isRunning() const
{
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index e3b0b15e26..4e05b63c82 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -146,23 +146,17 @@ QT_BEGIN_NAMESPACE
static inline const QMetaObjectPrivate *priv(const uint* data)
{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
-static inline const QByteArrayData &stringData(const QMetaObject *mo, int index)
+static inline const QByteArray stringData(const QMetaObject *mo, int index)
{
Q_ASSERT(priv(mo->d.data)->revision >= 7);
- const QByteArrayData &data = mo->d.stringdata[index];
- Q_ASSERT(data.ref.isStatic());
- Q_ASSERT(data.alloc == 0);
- Q_ASSERT(data.capacityReserved == 0);
- Q_ASSERT(data.size >= 0);
+ const QByteArrayDataPtr data = { const_cast<QByteArrayData*>(&mo->d.stringdata[index]) };
+ Q_ASSERT(data.ptr->ref.isStatic());
+ Q_ASSERT(data.ptr->alloc == 0);
+ Q_ASSERT(data.ptr->capacityReserved == 0);
+ Q_ASSERT(data.ptr->size >= 0);
return data;
}
-static inline QByteArray toByteArray(const QByteArrayData &d)
-{
- QByteArrayDataPtr holder = { const_cast<QByteArrayData *>(&d) };
- return QByteArray(holder);
-}
-
static inline const char *rawStringData(const QMetaObject *mo, int index)
{
return stringData(mo, index).data();
@@ -170,13 +164,13 @@ static inline const char *rawStringData(const QMetaObject *mo, int index)
static inline int stringSize(const QMetaObject *mo, int index)
{
- return stringData(mo, index).size;
+ return stringData(mo, index).size();
}
static inline QByteArray typeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo)
{
if (typeInfo & IsUnresolvedType) {
- return toByteArray(stringData(mo, typeInfo & TypeNameIndexMask));
+ return stringData(mo, typeInfo & TypeNameIndexMask);
} else {
// ### Use the QMetaType::typeName() that returns QByteArray
const char *t = QMetaType::typeName(typeInfo);
@@ -193,7 +187,7 @@ static inline int typeFromTypeInfo(const QMetaObject *mo, uint typeInfo)
{
if (!(typeInfo & IsUnresolvedType))
return typeInfo;
- return QMetaType::type(toByteArray(stringData(mo, typeInfo & TypeNameIndexMask)));
+ return QMetaType::type(stringData(mo, typeInfo & TypeNameIndexMask));
}
class QMetaMethodPrivate : public QMetaMethod
@@ -294,11 +288,10 @@ QObject *QMetaObject::newInstance(QGenericArgument val0,
*/
int QMetaObject::static_metacall(Call cl, int idx, void **argv) const
{
- const QMetaObjectExtraData *extra = reinterpret_cast<const QMetaObjectExtraData *>(d.extradata);
Q_ASSERT(priv(d.data)->revision >= 6);
- if (!extra || !extra->static_metacall)
+ if (!d.static_metacall)
return 0;
- extra->static_metacall(0, cl, idx, argv);
+ d.static_metacall(0, cl, idx, argv);
return -1;
}
@@ -492,7 +485,7 @@ int QMetaObject::constructorCount() const
Use code like the following to obtain a QStringList containing the methods
specific to a given class:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp methodCount
+ \snippet code/src_corelib_kernel_qmetaobject.cpp methodCount
\sa method(), methodOffset(), indexOfMethod()
*/
@@ -530,7 +523,7 @@ int QMetaObject::enumeratorCount() const
Use code like the following to obtain a QStringList containing the properties
specific to a given class:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp propertyCount
+ \snippet code/src_corelib_kernel_qmetaobject.cpp propertyCount
\sa property(), propertyOffset(), indexOfProperty()
*/
@@ -572,7 +565,7 @@ static bool methodMatch(const QMetaObject *m, int handle,
if (int(m->d.data[handle + 1]) != argc)
return false;
- if (toByteArray(stringData(m, m->d.data[handle])) != name)
+ if (stringData(m, m->d.data[handle]) != name)
return false;
int paramsIndex = m->d.data[handle + 2] + 1;
@@ -659,6 +652,7 @@ int QMetaObject::indexOfMethod(const char *method) const
}
// Parses a string of comma-separated types into QArgumentTypes.
+// No normalization of the type names is performed.
static void argumentTypesFromString(const char *str, const char *end,
QArgumentTypeArray &types)
{
@@ -812,6 +806,35 @@ int QMetaObjectPrivate::indexOfConstructor(const QMetaObject *m, const QByteArra
return -1;
}
+/*! \internal
+ Returns the signal for the given \a metaObject at \a signal_index.
+
+ It it different from QMetaObject::method(); the index should not include
+ non-signal methods.
+
+ The index must correspond to a signal defined in \ a metaObject itself;
+ it should not be an inherited signal.
+*/
+QMetaMethod QMetaObjectPrivate::signal(const QMetaObject *metaObject, int signal_index)
+{
+ QMetaMethod result;
+ if (signal_index < 0)
+ return result;
+ Q_ASSERT(metaObject != 0);
+
+ int signalOffset = 0;
+ for (const QMetaObject *m = metaObject->d.superdata; m; m = m->d.superdata)
+ signalOffset += priv(m->d.data)->signalCount;
+
+ Q_ASSERT(signal_index >= signalOffset);
+ int signal_index_relative = signal_index - signalOffset;
+ if (signal_index_relative < priv(metaObject->d.data)->signalCount) {
+ result.mobj = metaObject;
+ result.handle = priv(metaObject->d.data)->methodData + 5*signal_index_relative;
+ }
+ return result;
+}
+
/*!
\internal
@@ -869,11 +892,9 @@ static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, co
while (self) {
if (strcmp(rawStringData(self, 0), name) == 0)
return self;
- if (self->d.extradata) {
- const QMetaObject **e;
+ if (self->d.relatedMetaObjects) {
Q_ASSERT(priv(self->d.data)->revision >= 2);
- const QMetaObjectExtraData *extra = (const QMetaObjectExtraData*)(self->d.extradata);
- e = extra->objects;
+ const QMetaObject **e = self->d.relatedMetaObjects;
if (e) {
while (*e) {
if (const QMetaObject *m =QMetaObject_findMetaObject((*e), name))
@@ -1102,7 +1123,7 @@ QMetaProperty QMetaObject::userProperty() const
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp 0
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 0
\sa classInfoCount(), classInfoOffset(), indexOfClassInfo()
*/
@@ -1207,7 +1228,7 @@ static char *qNormalizeType(char *d, int &templdepth, QByteArray &result)
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp 1
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 1
\sa normalizedSignature()
*/
@@ -1312,7 +1333,7 @@ enum { MaximumParamCount = 11 }; // up to 10 arguments + 1 return value
the \l{QPushButton::animateClick()}{animateClick()} slot on a
QPushButton, use the following code:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp 2
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 2
With asynchronous method invocations, the parameters must be of
types that are known to Qt's meta-object system, because Qt needs
@@ -1320,7 +1341,7 @@ enum { MaximumParamCount = 11 }; // up to 10 arguments + 1 return value
scenes. If you try to use a queued connection and get the error
message
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp 3
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 3
call qRegisterMetaType() to register the data type before you
call invokeMethod().
@@ -1328,7 +1349,7 @@ enum { MaximumParamCount = 11 }; // up to 10 arguments + 1 return value
To synchronously invoke the \c compute(QString, int, double) slot on
some arbitrary object \c obj retrieve its return value:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp 4
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 4
If the "compute" slot does not take exactly one QString, one int
and one double in the specified order, the call will fail.
@@ -1483,6 +1504,24 @@ bool QMetaObject::invokeMethod(QObject *obj,
invoked), otherwise returns false.
*/
+/*! \fn bool operator==(const QMetaMethod &m1, const QMetaMethod &m2)
+ \since 5.0
+ \relates QMetaMethod
+ \overload
+
+ Returns true if method \a m1 is equal to method \a m2,
+ otherwise returns false.
+*/
+
+/*! \fn bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2)
+ \since 5.0
+ \relates QMetaMethod
+ \overload
+
+ Returns true if method \a m1 is not equal to method \a m2,
+ otherwise returns false.
+*/
+
/*!
\fn const QMetaObject *QMetaMethod::enclosingMetaObject() const
\internal
@@ -1522,7 +1561,7 @@ QByteArray QMetaMethodPrivate::signature() const
QByteArray QMetaMethodPrivate::name() const
{
Q_ASSERT(priv(mobj->d.data)->revision >= 7);
- return toByteArray(stringData(mobj, mobj->d.data[handle]));
+ return stringData(mobj, mobj->d.data[handle]);
}
int QMetaMethodPrivate::typesDataIndex() const
@@ -1599,14 +1638,14 @@ QList<QByteArray> QMetaMethodPrivate::parameterNames() const
int argc = parameterCount();
int namesIndex = parametersDataIndex() + argc;
for (int i = 0; i < argc; ++i)
- list += toByteArray(stringData(mobj, mobj->d.data[namesIndex + i]));
+ list += stringData(mobj, mobj->d.data[namesIndex + i]);
return list;
}
QByteArray QMetaMethodPrivate::tag() const
{
Q_ASSERT(priv(mobj->d.data)->revision >= 7);
- return toByteArray(stringData(mobj, mobj->d.data[handle + 3]));
+ return stringData(mobj, mobj->d.data[handle + 3]);
}
/*!
@@ -1848,6 +1887,41 @@ QMetaMethod::MethodType QMetaMethod::methodType() const
}
/*!
+ \fn QMetaMethod QMetaMethod::fromSignal(PointerToMemberFunction signal)
+ \since 5.0
+
+ Returns the meta-method that corresponds to the given \a signal, or an
+ invalid QMetaMethod if \a signal is not a signal of the class.
+
+ Example:
+
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 9
+*/
+
+/*! \internal
+
+ Implementation of the fromSignal() function.
+
+ \a metaObject is the class's meta-object
+ \a signal is a pointer to a pointer to a member signal of the class
+*/
+QMetaMethod QMetaMethod::fromSignalImpl(const QMetaObject *metaObject, void **signal)
+{
+ int i = -1;
+ void *args[] = { &i, signal };
+ QMetaMethod result;
+ for (const QMetaObject *m = metaObject; m; m = m->d.superdata) {
+ m->static_metacall(QMetaObject::IndexOfMethod, 0, args);
+ if (i >= 0) {
+ result.mobj = m;
+ result.handle = priv(m->d.data)->methodData + 5*i;
+ break;
+ }
+ }
+ return result;
+}
+
+/*!
Invokes this method on the object \a object. Returns true if the member could be invoked.
Returns false if there is no such member or the parameters did not match.
@@ -1883,7 +1957,7 @@ QMetaMethod::MethodType QMetaMethod::methodType() const
\l{QPushButton::animateClick()}{animateClick()} slot on a
QPushButton:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp 6
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 6
With asynchronous method invocations, the parameters must be of
types that are known to Qt's meta-object system, because Qt needs
@@ -1891,7 +1965,7 @@ QMetaMethod::MethodType QMetaMethod::methodType() const
scenes. If you try to use a queued connection and get the error
message
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp 7
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 7
call qRegisterMetaType() to register the data type before you
call QMetaMethod::invoke().
@@ -1899,7 +1973,7 @@ QMetaMethod::MethodType QMetaMethod::methodType() const
To synchronously invoke the \c compute(QString, int, double) slot on
some arbitrary object \c obj retrieve its return value:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp 8
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 8
QMetaObject::normalizedSignature() is used here to ensure that the format
of the signature is what invoke() expects. E.g. extra whitespace is
@@ -2012,8 +2086,7 @@ bool QMetaMethod::invoke(QObject *object,
int idx_relative = ((handle - priv(mobj->d.data)->methodData) / 5);
int idx_offset = mobj->methodOffset();
Q_ASSERT(QMetaObjectPrivate::get(mobj)->revision >= 6);
- QObjectPrivate::StaticMetaCallFunction callFunction = mobj->d.extradata
- ? reinterpret_cast<const QMetaObjectExtraData *>(mobj->d.extradata)->static_metacall : 0;
+ QObjectPrivate::StaticMetaCallFunction callFunction = mobj->d.static_metacall;
if (connectionType == Qt::DirectConnection) {
if (callFunction) {
@@ -2391,7 +2464,7 @@ QByteArray QMetaEnum::valueToKeys(int value) const
v = v & ~k;
if (!keys.isEmpty())
keys += '|';
- keys += toByteArray(stringData(mobj, mobj->d.data[data + 2*i]));
+ keys += stringData(mobj, mobj->d.data[data + 2*i]);
}
}
return keys;
@@ -3058,7 +3131,7 @@ bool QMetaProperty::isEditable(const QObject *object) const
are specified using Q_CLASSINFO() in the source code. The
information can be retrieved using name() and value(). For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp 5
+ \snippet code/src_corelib_kernel_qmetaobject.cpp 5
This mechanism is free for you to use in your Qt applications. Qt
doesn't use it for any of its classes.
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 095b196dca..1c49506926 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -141,6 +141,20 @@ public:
inline bool isValid() const { return mobj != 0; }
+#ifdef Q_QDOC
+ static QMetaMethod fromSignal(PointerToMemberFunction signal);
+#else
+ template <typename Func>
+ static inline QMetaMethod fromSignal(Func signal)
+ {
+ typedef QtPrivate::FunctionPointer<Func> SignalType;
+ reinterpret_cast<typename SignalType::Object *>(0)->qt_check_for_QOBJECT_macro(
+ *reinterpret_cast<typename SignalType::Object *>(0));
+ return fromSignalImpl(&SignalType::Object::staticMetaObject,
+ reinterpret_cast<void **>(&signal));
+ }
+#endif
+
private:
#if QT_DEPRECATED_SINCE(5,0)
// signature() has been renamed to methodSignature() in Qt 5.
@@ -148,6 +162,7 @@ private:
// you convert to char*.
char *signature(struct renamedInQt5_warning_checkTheLifeTime * = 0) Q_DECL_EQ_DELETE;
#endif
+ static QMetaMethod fromSignalImpl(const QMetaObject *, void **);
const QMetaObject *mobj;
uint handle;
@@ -155,9 +170,16 @@ private:
friend struct QMetaObject;
friend struct QMetaObjectPrivate;
friend class QObject;
+ friend bool operator==(const QMetaMethod &m1, const QMetaMethod &m2);
+ friend bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2);
};
Q_DECLARE_TYPEINFO(QMetaMethod, Q_MOVABLE_TYPE);
+inline bool operator==(const QMetaMethod &m1, const QMetaMethod &m2)
+{ return m1.mobj == m2.mobj && m1.handle == m2.handle; }
+inline bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2)
+{ return !(m1 == m2); }
+
class Q_CORE_EXPORT QMetaEnum
{
public:
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 3b732b4b93..5877ab18e4 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -110,6 +110,8 @@ enum MetaDataFlags {
TypeNameIndexMask = 0x7FFFFFFF
};
+extern int qMetaTypeTypeInternal(const char *);
+
class QArgumentType
{
public:
@@ -117,7 +119,7 @@ public:
: _type(type)
{}
QArgumentType(const QByteArray &name)
- : _type(QMetaType::type(name.constData())), _name(name)
+ : _type(qMetaTypeTypeInternal(name.constData())), _name(name)
{}
QArgumentType()
: _type(0)
@@ -198,6 +200,7 @@ struct QMetaObjectPrivate
int argc, const QArgumentType *types);
static int indexOfConstructor(const QMetaObject *m, const QByteArray &name,
int argc, const QArgumentType *types);
+ static QMetaMethod signal(const QMetaObject *m, int signal_index);
static bool checkConnectArgs(int signalArgc, const QArgumentType *signalTypes,
int methodArgc, const QArgumentType *methodTypes);
static bool checkConnectArgs(const QMetaMethodPrivate *signal,
@@ -211,10 +214,12 @@ struct QMetaObjectPrivate
static void memberIndexes(const QObject *obj, const QMetaMethod &member,
int *signalIndex, int *methodIndex);
static QObjectPrivate::Connection *connect(const QObject *sender, int signal_index,
+ const QMetaObject *smeta,
const QObject *receiver, int method_index_relative,
const QMetaObject *rmeta = 0,
int type = 0, int *types = 0);
static bool disconnect(const QObject *sender, int signal_index,
+ const QMetaObject *smeta,
const QObject *receiver, int method_index, void **slot,
DisconnectType = DisconnectAll);
static inline bool disconnectHelper(QObjectPrivate::Connection *c,
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp
index d262d6a61b..16ff58e1ca 100644
--- a/src/corelib/kernel/qmetaobjectbuilder.cpp
+++ b/src/corelib/kernel/qmetaobjectbuilder.cpp
@@ -609,7 +609,7 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot
\a name. Returns an object that can be used to adjust
the other attributes of the enumerator.
- \sa enumerator(), enumeratorCount(), removeEnumerator(),
+ \sa enumerator(), enumeratorCount(), removeEnumerator()
\sa indexOfEnumerator()
*/
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
@@ -625,7 +625,7 @@ QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
QMetaObject. Returns an object that can be used to adjust the
attributes of the enumerator.
- \sa enumerator(), enumeratorCount(), removeEnumerator(),
+ \sa enumerator(), enumeratorCount(), removeEnumerator()
\sa indexOfEnumerator()
*/
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum& prototype)
@@ -737,13 +737,8 @@ void QMetaObjectBuilder::addMetaObject
}
if ((members & RelatedMetaObjects) != 0) {
- const QMetaObject **objects;
Q_ASSERT(priv(prototype->d.data)->revision >= 2);
- const QMetaObjectExtraData *extra = (const QMetaObjectExtraData *)(prototype->d.extradata);
- if (extra)
- objects = extra->objects;
- else
- objects = 0;
+ const QMetaObject **objects = prototype->d.relatedMetaObjects;
if (objects) {
while (*objects != 0) {
addRelatedMetaObject(*objects);
@@ -754,10 +749,8 @@ void QMetaObjectBuilder::addMetaObject
if ((members & StaticMetacall) != 0) {
Q_ASSERT(priv(prototype->d.data)->revision >= 6);
- const QMetaObjectExtraData *extra =
- (const QMetaObjectExtraData *)(prototype->d.extradata);
- if (extra && extra->static_metacall)
- setStaticMetacallFunction(extra->static_metacall);
+ if (prototype->d.static_metacall)
+ setStaticMetacallFunction(prototype->d.static_metacall);
}
}
@@ -1150,7 +1143,7 @@ static int aggregateParameterCount(const QList<QMetaMethodBuilderPrivate> &metho
// Build a QMetaObject in "buf" based on the information in "d".
// If "buf" is null, then return the number of bytes needed to
// build the QMetaObject. Returns -1 if the metaobject if
-// relocatable is set, but the metaobject contains extradata.
+// relocatable is set, but the metaobject contains relatedMetaObjects.
static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
int expectedSize, bool relocatable)
{
@@ -1174,7 +1167,9 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
ALIGN(size, int);
if (buf) {
if (!relocatable) meta->d.superdata = d->superClass;
+ meta->d.relatedMetaObjects = 0;
meta->d.extradata = 0;
+ meta->d.static_metacall = d->staticMetacallFunction;
}
// Populate the QMetaObjectPrivate structure.
@@ -1446,30 +1441,18 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
if (buf)
data[enumIndex] = 0;
- // Create the extradata block if we need one.
- if (d->relatedMetaObjects.size() > 0 || d->staticMetacallFunction) {
- ALIGN(size, QMetaObject **);
- ALIGN(size, QMetaObjectBuilder::StaticMetacallFunction);
- QMetaObjectExtraData *extra =
- reinterpret_cast<QMetaObjectExtraData *>(buf + size);
- size += sizeof(QMetaObjectExtraData);
+ // Create the relatedMetaObjects block if we need one.
+ if (d->relatedMetaObjects.size() > 0) {
ALIGN(size, QMetaObject *);
const QMetaObject **objects =
reinterpret_cast<const QMetaObject **>(buf + size);
if (buf) {
- if (d->relatedMetaObjects.size() > 0) {
- extra->objects = objects;
- for (index = 0; index < d->relatedMetaObjects.size(); ++index)
- objects[index] = d->relatedMetaObjects[index];
- objects[index] = 0;
- } else {
- extra->objects = 0;
- }
- extra->static_metacall = d->staticMetacallFunction;
- meta->d.extradata = reinterpret_cast<void *>(extra);
+ meta->d.relatedMetaObjects = objects;
+ for (index = 0; index < d->relatedMetaObjects.size(); ++index)
+ objects[index] = d->relatedMetaObjects[index];
+ objects[index] = 0;
}
- if (d->relatedMetaObjects.size() > 0)
- size += sizeof(QMetaObject *) * (d->relatedMetaObjects.size() + 1);
+ size += sizeof(QMetaObject *) * (d->relatedMetaObjects.size() + 1);
}
// Align the final size and return it.
@@ -1552,6 +1535,8 @@ void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output,
output->d.stringdata = reinterpret_cast<const QByteArrayData *>(buf + stringdataOffset);
output->d.data = reinterpret_cast<const uint *>(buf + dataOffset);
output->d.extradata = 0;
+ output->d.relatedMetaObjects = 0;
+ output->d.static_metacall = 0;
}
/*!
diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/corelib/kernel/qmetaobjectbuilder_p.h
index 4d766a9197..7c18298d35 100644
--- a/src/corelib/kernel/qmetaobjectbuilder_p.h
+++ b/src/corelib/kernel/qmetaobjectbuilder_p.h
@@ -165,7 +165,7 @@ public:
int indexOfEnumerator(const QByteArray& name);
int indexOfClassInfo(const QByteArray& name);
- typedef QMetaObjectExtraData::StaticMetacallFunction StaticMetacallFunction;
+ typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **);
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const;
void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value);
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 53b22958c3..2756dd5241 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -125,16 +125,16 @@ struct DefinedTypesFilter {
This example shows a typical use case of Q_DECLARE_METATYPE():
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 0
+ \snippet code/src_corelib_kernel_qmetatype.cpp 0
If \c MyStruct is in a namespace, the Q_DECLARE_METATYPE() macro
has to be outside the namespace:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 1
+ \snippet code/src_corelib_kernel_qmetatype.cpp 1
Since \c{MyStruct} is now known to QMetaType, it can be used in QVariant:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 2
+ \snippet code/src_corelib_kernel_qmetatype.cpp 2
\sa qRegisterMetaType()
*/
@@ -220,21 +220,13 @@ struct DefinedTypesFilter {
\value User Base value for user types
\value UnknownType This is an invalid type id. It is returned from QMetaType for types that are not registered
- \omitvalue FirstGuiType
- \omitvalue FirstWidgetsType
- \omitvalue LastCoreType
- \omitvalue LastGuiType
- \omitvalue LastWidgetsType
- \omitvalue QReal
- \omitvalue HighestInternalId
-
Additional types can be registered using Q_DECLARE_METATYPE().
\sa type(), typeName()
*/
/*!
- \enum QMetaType::TypeFlags
+ \enum QMetaType::TypeFlag
The enum describes attributes of a type supported by QMetaType.
@@ -265,7 +257,7 @@ struct DefinedTypesFilter {
The following code allocates and destructs an instance of
\c{MyClass}:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 3
+ \snippet code/src_corelib_kernel_qmetatype.cpp 3
If we want the stream operators \c operator<<() and \c
operator>>() to work on QVariant objects that store custom types,
@@ -449,16 +441,37 @@ int QMetaType::registerType(const char *typeName, Deleter deleter,
int size, TypeFlags flags, const QMetaObject *metaObject)
{
Q_UNUSED(metaObject);
- QVector<QCustomTypeInfo> *ct = customTypes();
- if (!ct || !typeName || !deleter || !creator || !destructor || !constructor)
- return -1;
-
#ifdef QT_NO_QOBJECT
NS(QByteArray) normalizedTypeName = typeName;
#else
NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
#endif
+ return registerNormalizedType(normalizedTypeName, deleter, creator, destructor, constructor, size, flags, metaObject);
+}
+
+
+/*! \internal
+ \since 5.0
+
+ Registers a user type for marshalling, with \a normalizedTypeName, a \a
+ deleter, a \a creator, a \a destructor, a \a constructor, and
+ a \a size. Returns the type's handle, or -1 if the type could
+ not be registered. Note that normalizedTypeName is not checked for
+ conformance with Qt's normalized format, so it must already
+ conform.
+ */
+int QMetaType::registerNormalizedType(const NS(QByteArray) &normalizedTypeName, Deleter deleter,
+ Creator creator,
+ Destructor destructor,
+ Constructor constructor,
+ int size, TypeFlags flags, const QMetaObject *metaObject)
+{
+ Q_UNUSED(metaObject);
+ QVector<QCustomTypeInfo> *ct = customTypes();
+ if (!ct || normalizedTypeName.isEmpty() || !deleter || !creator || !destructor || !constructor)
+ return -1;
+
int idx = qMetaTypeStaticType(normalizedTypeName.constData(),
normalizedTypeName.size());
@@ -521,16 +534,28 @@ int QMetaType::registerType(const char *typeName, Deleter deleter,
*/
int QMetaType::registerTypedef(const char* typeName, int aliasId)
{
- QVector<QCustomTypeInfo> *ct = customTypes();
- if (!ct || !typeName)
- return -1;
-
#ifdef QT_NO_QOBJECT
NS(QByteArray) normalizedTypeName = typeName;
#else
NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
#endif
+ return registerNormalizedTypedef(normalizedTypeName, aliasId);
+}
+
+/*! \internal
+ \since 5.0
+
+ Registers a user type for marshalling, as an alias of another type (typedef).
+ Note that normalizedTypeName is not checked for conformance with Qt's normalized format,
+ so it must already conform.
+*/
+int QMetaType::registerNormalizedTypedef(const NS(QByteArray) &normalizedTypeName, int aliasId)
+{
+ QVector<QCustomTypeInfo> *ct = customTypes();
+ if (!ct || normalizedTypeName.isEmpty())
+ return -1;
+
int idx = qMetaTypeStaticType(normalizedTypeName.constData(),
normalizedTypeName.size());
@@ -581,26 +606,26 @@ bool QMetaType::isRegistered(int type)
}
/*!
- Returns a handle to the type called \a typeName, or QMetaType::UnknownType if there is
- no such type.
+ \internal
- \sa isRegistered(), typeName(), Type
+ Implementation of QMetaType::type().
*/
-int QMetaType::type(const char *typeName)
+template <int tryNormalizedType>
+static inline int qMetaTypeTypeImpl(const char *typeName)
{
int length = qstrlen(typeName);
if (!length)
- return UnknownType;
+ return QMetaType::UnknownType;
int type = qMetaTypeStaticType(typeName, length);
- if (type == UnknownType) {
+ if (type == QMetaType::UnknownType) {
QReadLocker locker(customTypesLock());
type = qMetaTypeCustomType_unlocked(typeName, length);
#ifndef QT_NO_QOBJECT
- if (type == UnknownType) {
+ if ((type == QMetaType::UnknownType) && tryNormalizedType) {
const NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
type = qMetaTypeStaticType(normalizedTypeName.constData(),
normalizedTypeName.size());
- if (type == UnknownType) {
+ if (type == QMetaType::UnknownType) {
type = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(),
normalizedTypeName.size());
}
@@ -610,6 +635,29 @@ int QMetaType::type(const char *typeName)
return type;
}
+/*!
+ Returns a handle to the type called \a typeName, or QMetaType::UnknownType if there is
+ no such type.
+
+ \sa isRegistered(), typeName(), Type
+*/
+int QMetaType::type(const char *typeName)
+{
+ return qMetaTypeTypeImpl</*tryNormalizedType=*/true>(typeName);
+}
+
+/*!
+ \a internal
+
+ Similar to QMetaType::type(); the only difference is that this function
+ doesn't attempt to normalize the type name (i.e., the lookup will fail
+ for type names in non-normalized form).
+*/
+int qMetaTypeTypeInternal(const char *typeName)
+{
+ return qMetaTypeTypeImpl</*tryNormalizedType=*/false>(typeName);
+}
+
#ifndef QT_NO_DATASTREAM
/*!
Writes the object pointed to by \a data with the ID \a type to
@@ -1486,12 +1534,12 @@ QMetaType::TypeFlags QMetaType::typeFlags(int type)
This example registers the class \c{MyClass}:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 4
+ \snippet code/src_corelib_kernel_qmetatype.cpp 4
This function is useful to register typedefs so they can be used
by QMetaProperty, or in QueuedConnections
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 9
+ \snippet code/src_corelib_kernel_qmetatype.cpp 9
\sa qRegisterMetaTypeStreamOperators(), QMetaType::isRegistered(),
Q_DECLARE_METATYPE()
@@ -1509,11 +1557,11 @@ QMetaType::TypeFlags QMetaType::typeFlags(int type)
QMetaType::save(). These functions are used when streaming a
QVariant.
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 5
+ \snippet code/src_corelib_kernel_qmetatype.cpp 5
The stream operators should have the following signatures:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 6
+ \snippet code/src_corelib_kernel_qmetatype.cpp 6
\sa qRegisterMetaType(), QMetaType::isRegistered(), Q_DECLARE_METATYPE()
*/
@@ -1548,7 +1596,7 @@ QMetaType::TypeFlags QMetaType::typeFlags(int type)
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 7
+ \snippet code/src_corelib_kernel_qmetatype.cpp 7
To use the type \c T in QVariant, using Q_DECLARE_METATYPE() is
sufficient. To use the type \c T in queued signal and slot connections,
@@ -1574,7 +1622,7 @@ QMetaType::TypeFlags QMetaType::typeFlags(int type)
Typical usage:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 8
+ \snippet code/src_corelib_kernel_qmetatype.cpp 8
QMetaType::type() returns the same ID as qMetaTypeId(), but does
a lookup at runtime based on the name of the type.
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 21f4bc7afe..595da53562 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -45,8 +45,11 @@
#include <QtCore/qglobal.h>
#include <QtCore/qatomic.h>
#include <QtCore/qbytearray.h>
+#include <QtCore/qvarlengtharray.h>
#include <QtCore/qisenum.h>
-
+#ifndef QT_NO_QOBJECT
+#include <QtCore/qobjectdefs.h>
+#endif
#include <new>
#ifdef Bool
@@ -195,6 +198,8 @@ class Q_CORE_EXPORT QMetaType {
FlagsEx = 0x100
};
public:
+#ifndef Q_QDOC
+ // The code that actually gets compiled.
enum Type {
// these are merged with QVariant
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
@@ -212,6 +217,29 @@ public:
UnknownType = 0,
User = 1024
};
+#else
+ // If we are using QDoc it fakes the Type enum looks like this.
+ enum Type {
+ Void = 0, Bool = 1, Int = 2, UInt = 3, LongLong = 4, ULongLong = 5,
+ Double = 6, Long = 32, Short = 33, Char = 34, ULong = 35, UShort = 36,
+ UChar = 37, Float = 38,
+ VoidStar = 31,
+ QChar = 7, QString = 10, QStringList = 11, QByteArray = 12,
+ QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17,
+ QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22,
+ QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27,
+ QEasingCurve = 29, QUuid = 30, QVariant = 41, QModelIndex = 42,
+ QObjectStar = 39, QWidgetStar = 40,
+ QVariantMap = 8, QVariantList = 9, QVariantHash = 28,
+ QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
+ QImage = 69, QPolygon = 70, QRegion = 71, QBitmap = 72, QCursor = 73,
+ QKeySequence = 74, QPen = 75, QTextLength = 76, QTextFormat = 77,
+ QMatrix = 78, QTransform = 79, QMatrix4x4 = 80, QVector2D = 81,
+ QVector3D = 82, QVector4D = 83, QQuaternion = 84, QPolygonF = 85,
+ QIcon = 120, QSizePolicy = 121,
+ User = 256
+ };
+#endif
enum TypeFlag {
NeedsConstruction = 0x1,
@@ -245,7 +273,15 @@ public:
int size,
QMetaType::TypeFlags flags,
const QMetaObject *metaObject);
+ static int registerNormalizedType(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, Deleter deleter,
+ Creator creator,
+ Destructor destructor,
+ Constructor constructor,
+ int size,
+ QMetaType::TypeFlags flags,
+ const QMetaObject *metaObject);
static int registerTypedef(const char *typeName, int aliasId);
+ static int registerNormalizedTypedef(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, int aliasId);
static int type(const char *typeName);
static const char *typeName(int type);
static int sizeOf(int type);
@@ -480,7 +516,7 @@ namespace QtPrivate {
}
template <typename T>
-int qRegisterMetaType(const char *typeName
+int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName
#ifndef qdoc
, T * dummy = 0
#endif
@@ -488,10 +524,10 @@ int qRegisterMetaType(const char *typeName
{
const int typedefOf = dummy ? -1 : QtPrivate::QMetaTypeIdHelper<T>::qt_metatype_id();
if (typedefOf != -1)
- return QMetaType::registerTypedef(typeName, typedefOf);
+ return QMetaType::registerNormalizedTypedef(normalizedTypeName, typedefOf);
QMetaType::TypeFlags flags(QtPrivate::QMetaTypeTypeFlags<T>::Flags);
- return QMetaType::registerType(typeName, qMetaTypeDeleteHelper<T>,
+ return QMetaType::registerNormalizedType(normalizedTypeName, qMetaTypeDeleteHelper<T>,
qMetaTypeCreateHelper<T>,
qMetaTypeDestructHelper<T>,
qMetaTypeConstructHelper<T>,
@@ -500,6 +536,21 @@ int qRegisterMetaType(const char *typeName
QtPrivate::MetaObjectForType<T>::value());
}
+template <typename T>
+int qRegisterMetaType(const char *typeName
+#ifndef qdoc
+ , T * dummy = 0
+#endif
+)
+{
+#ifdef QT_NO_QOBJECT
+ QT_PREPEND_NAMESPACE(QByteArray) normalizedTypeName = typeName;
+#else
+ QT_PREPEND_NAMESPACE(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
+#endif
+ return qRegisterNormalizedMetaType<T>(normalizedTypeName, dummy);
+}
+
#ifndef QT_NO_DATASTREAM
template <typename T>
void qRegisterMetaTypeStreamOperators(const char *typeName
@@ -548,9 +599,14 @@ struct QMetaTypeIdQObject<T*, /* isPointerToTypeDerivedFromQObject */ true>
static int qt_metatype_id()
{
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
- if (!metatype_id.load())
- metatype_id.storeRelease(qRegisterMetaType<T*>(QByteArray(T::staticMetaObject.className() + QByteArrayLiteral("*")).constData(),
+ if (!metatype_id.load()) {
+ const int len = int(strlen(T::staticMetaObject.className()));
+ QVarLengthArray<char, 16> classNameStar;
+ classNameStar.append(T::staticMetaObject.className(), len);
+ classNameStar.append("*\0", 2);
+ metatype_id.storeRelease(qRegisterMetaType<T*>(classNameStar.constData(),
reinterpret_cast<T**>(quintptr(-1))));
+ }
return metatype_id.loadAcquire();
}
};
@@ -687,6 +743,7 @@ inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeI
, m_loadOp(loadOp)
, m_constructor(constructor)
, m_destructor(destructor)
+ , m_extension(0)
, m_size(size)
, m_typeFlags(theTypeFlags)
, m_extensionFlags(extensionFlags)
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index 74229d3f3c..b593489963 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
namespace QModulesPrivate {
enum Names { Core, Gui, Widgets, Unknown, ModulesCount /* ModulesCount has to be at the end */ };
-static inline int moduleForType(const int typeId)
+static inline int moduleForType(const uint typeId)
{
if (typeId <= QMetaType::LastCoreType)
return Core;
diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp
index 3a3464e43e..c18ce22247 100644
--- a/src/corelib/kernel/qmimedata.cpp
+++ b/src/corelib/kernel/qmimedata.cpp
@@ -257,7 +257,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
For example, if your write a widget that accepts URL drags, you
would end up writing code like this:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp 0
+ \snippet code/src_corelib_kernel_qmimedata.cpp 0
There are three approaches for storing custom data in a QMimeData
object:
@@ -266,7 +266,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
\li Custom data can be stored directly in a QMimeData object as a
QByteArray using setData(). For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp 1
+ \snippet code/src_corelib_kernel_qmimedata.cpp 1
\li We can subclass QMimeData and reimplement hasFormat(),
formats(), and retrieveData().
@@ -276,7 +276,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
it, and use a qobject_cast() in the receiver's drop event
handler. For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp 2
+ \snippet code/src_corelib_kernel_qmimedata.cpp 2
\endlist
\section1 Platform-Specific MIME Types
@@ -286,11 +286,11 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
indicate that they represent data in non-standard formats.
The formats will take the following form:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp 3
+ \snippet code/src_corelib_kernel_qmimedata.cpp 3
The following are examples of custom MIME types:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp 4
+ \snippet code/src_corelib_kernel_qmimedata.cpp 4
The \c value declaration of each format describes the way in which the
data is encoded.
@@ -458,7 +458,7 @@ bool QMimeData::hasHtml() const
library, whereas QImage belongs to \l QtGui. To convert the
QVariant to a QImage, simply use qvariant_cast(). For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp 5
+ \snippet code/src_corelib_kernel_qmimedata.cpp 5
\sa hasImage()
*/
@@ -475,7 +475,7 @@ QVariant QMimeData::imageData() const
library, whereas QImage belongs to \l QtGui. The conversion
from QImage to QVariant is implicit. For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp 6
+ \snippet code/src_corelib_kernel_qmimedata.cpp 6
\sa hasImage(), setData()
*/
@@ -505,7 +505,7 @@ bool QMimeData::hasImage() const
library, whereas QColor belongs to \l QtGui. To convert the
QVariant to a QColor, simply use qvariant_cast(). For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp 7
+ \snippet code/src_corelib_kernel_qmimedata.cpp 7
\sa hasColor(), setColorData(), data()
*/
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index fb3e4e396b..49a9beb298 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -184,6 +184,7 @@ void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject
void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0;
void (*QAbstractDeclarativeData::objectNameChanged)(QAbstractDeclarativeData *, QObject *) = 0;
void (*QAbstractDeclarativeData::signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **) = 0;
+int (*QAbstractDeclarativeData::receivers)(QAbstractDeclarativeData *, const QObject *, int) = 0;
QObjectData::~QObjectData() {}
@@ -568,9 +569,9 @@ void QMetaCallEvent::placeMetaCall(QObject *object)
\l uic generates code that invokes this function to enable
auto-connection to be performed between widgets on forms created
- with \QD. More information about using auto-connection with \QD is
+ with \e{Qt Designer}. More information about using auto-connection with \e{Qt Designer} is
given in the \l{Using a Designer UI File in Your Application} section of
- the \QD manual.
+ the \e{Qt Designer} manual.
\section1 Dynamic Properties
@@ -606,7 +607,7 @@ void QMetaCallEvent::placeMetaCall(QObject *object)
Returns 0 if there is no such child.
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 0
+ \snippet code/src_corelib_kernel_qobject.cpp 0
*/
void *qt_find_obj_child(QObject *parent, const char *type, const QString &name)
@@ -651,8 +652,8 @@ static bool check_parent_thread(QObject *parent,
Constructs an object with parent object \a parent.
The parent of an object may be viewed as the object's owner. For
- instance, a \l{QDialog}{dialog box} is the parent of the \gui OK
- and \gui Cancel buttons it contains.
+ instance, a \l{QDialog}{dialog box} is the parent of the \uicontrol{OK}
+ and \uicontrol{Cancel} buttons it contains.
The destructor of a parent object destroys all child objects.
@@ -881,7 +882,7 @@ QObjectPrivate::Connection::~Connection()
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 1
+ \snippet code/src_corelib_kernel_qobject.cpp 1
\sa staticMetaObject
*/
@@ -905,7 +906,7 @@ QObjectPrivate::Connection::~Connection()
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 2
+ \snippet code/src_corelib_kernel_qobject.cpp 2
\sa metaObject()
*/
@@ -924,7 +925,7 @@ QObjectPrivate::Connection::~Connection()
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 3
+ \snippet code/src_corelib_kernel_qobject.cpp 3
The qobject_cast() function behaves similarly to the standard C++
\c dynamic_cast(), with the advantages that it doesn't require
@@ -950,7 +951,7 @@ QObjectPrivate::Connection::~Connection()
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 4
+ \snippet code/src_corelib_kernel_qobject.cpp 4
If you need to determine whether an object is an instance of a particular
class for the purpose of casting it, consider using qobject_cast<Type *>(object)
@@ -967,7 +968,7 @@ QObjectPrivate::Connection::~Connection()
You can find an object by name (and type) using findChild().
You can find a set of objects with findChildren().
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 5
+ \snippet code/src_corelib_kernel_qobject.cpp 5
By default, this property contains an empty string.
@@ -988,7 +989,7 @@ void QObject::setObjectName(const QString &name)
Q_D(QObject);
if (d->objectName != name) {
d->objectName = name;
- if (d->declarativeData)
+ if (d->declarativeData && d->declarativeData->objectNameChanged)
d->declarativeData->objectNameChanged(d->declarativeData, this);
emit objectNameChanged(d->objectName);
}
@@ -1155,7 +1156,7 @@ void QObject::customEvent(QEvent * /* event */)
true; otherwise return false.
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 6
+ \snippet code/src_corelib_kernel_qobject.cpp 6
Notice in the example above that unhandled events are passed to
the base class's eventFilter() function, since the base class
@@ -1225,7 +1226,7 @@ QThread *QObject::thread() const
QApplication::thread() to retrieve the thread in which the
application lives. For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 7
+ \snippet code/src_corelib_kernel_qobject.cpp 7
If \a targetThread is zero, all event processing for this object
and its children stops.
@@ -1390,7 +1391,7 @@ void QObjectPrivate::_q_reregisterTimers(void *pointer)
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 8
+ \snippet code/src_corelib_kernel_qobject.cpp 8
Note that QTimer's accuracy depends on the underlying operating system and
hardware. The \a timerType argument allows you to customize the accuracy of
@@ -1472,7 +1473,7 @@ void QObject::killTimer(int id)
The QObjectList class is defined in the \c{<QObject>} header
file as the following:
- \quotefromfile src/corelib/kernel/qobject.h
+ \quotefromfile kernel/qobject.h
\skipto /typedef .*QObjectList/
\printuntil QObjectList
@@ -1507,21 +1508,21 @@ void QObject::killTimer(int id)
named \c{"button1"}, even if the button isn't a direct child of
the parent:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 10
+ \snippet code/src_corelib_kernel_qobject.cpp 10
This example returns a \l{QListWidget} child of \c{parentWidget}:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 11
+ \snippet code/src_corelib_kernel_qobject.cpp 11
This example returns a child \l{QPushButton} of \c{parentWidget}
(its direct parent) named \c{"button1"}:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 41
+ \snippet code/src_corelib_kernel_qobject.cpp 41
This example returns a \l{QListWidget} child of \c{parentWidget},
its direct parent:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 42
+ \snippet code/src_corelib_kernel_qobject.cpp 42
\sa findChildren()
*/
@@ -1538,15 +1539,15 @@ void QObject::killTimer(int id)
The following example shows how to find a list of child \l{QWidget}s of
the specified \c{parentWidget} named \c{widgetname}:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 12
+ \snippet code/src_corelib_kernel_qobject.cpp 12
This example returns all \c{QPushButton}s that are children of \c{parentWidget}:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 13
+ \snippet code/src_corelib_kernel_qobject.cpp 13
This example returns all \c{QPushButton}s that are immediate children of \c{parentWidget}:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 43
+ \snippet code/src_corelib_kernel_qobject.cpp 43
\sa findChild()
*/
@@ -1653,10 +1654,11 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegExp &re,
if (!parent || !list)
return;
const QObjectList &children = parent->children();
+ QRegExp reCopy = re;
QObject *obj;
for (int i = 0; i < children.size(); ++i) {
obj = children.at(i);
- if (mo.cast(obj) && re.indexIn(obj->objectName()) != -1)
+ if (mo.cast(obj) && reCopy.indexIn(obj->objectName()) != -1)
list->append(obj);
if (options & Qt::FindChildrenRecursively)
@@ -1791,7 +1793,7 @@ void QObjectPrivate::setParent_helper(QObject *o)
\fn void QObject::installEventFilter(QObject *filterObj)
Installs an event filter \a filterObj on this object. For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 14
+ \snippet code/src_corelib_kernel_qobject.cpp 14
An event filter is an object that receives all events that are
sent to this object. The filter can either stop the event or
@@ -1806,11 +1808,11 @@ void QObjectPrivate::setParent_helper(QObject *o)
Here's a \c KeyPressEater class that eats the key presses of its
monitored objects:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 15
+ \snippet code/src_corelib_kernel_qobject.cpp 15
And here's how to install it on two widgets:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 16
+ \snippet code/src_corelib_kernel_qobject.cpp 16
The QShortcut class, for example, uses this technique to intercept
shortcut key presses.
@@ -1925,7 +1927,7 @@ void QObject::deleteLater()
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 17
+ \snippet code/src_corelib_kernel_qobject.cpp 17
\dots
See \l{Writing Source Code for Translation} for a detailed description of
@@ -1959,7 +1961,7 @@ void QObject::deleteLater()
escape sequences for specifying non-ASCII characters in string
literals to trUtf8(). For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 20
+ \snippet code/src_corelib_kernel_qobject.cpp 20
\sa tr(), QApplication::translate(), {Internationalization with Qt}
*/
@@ -2153,15 +2155,14 @@ int QObject::senderSignalIndex() const
When calling this function, you can use the \c SIGNAL() macro to
pass a specific signal:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 21
-
- As the code snippet above illustrates, you can use this function
- to avoid emitting a signal that nobody listens to.
+ \snippet code/src_corelib_kernel_qobject.cpp 21
\warning This function violates the object-oriented principle of
modularity. However, it might be useful when you need to perform
expensive initialization only if something is connected to a
signal.
+
+ \sa isSignalConnected()
*/
int QObject::receivers(const char *signal) const
@@ -2181,10 +2182,17 @@ int QObject::receivers(const char *signal) const
#ifndef QT_NO_DEBUG
err_method_notfound(this, signal-1, "receivers");
#endif
- return false;
+ return 0;
}
- Q_D(const QObject);
+ if (d->declarativeData && QAbstractDeclarativeData::receivers) {
+ receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+ metaObject()->indexOfMethod(signal));
+ }
+
+ if (!d->isSignalConnected(signal_index))
+ return receivers;
+
QMutexLocker locker(signalSlotLock(this));
if (d->connectionLists) {
if (signal_index < d->connectionLists->count()) {
@@ -2201,6 +2209,60 @@ int QObject::receivers(const char *signal) const
}
/*!
+ \since 5.0
+ Returns true if the \a signal is connected to at least one receiver,
+ otherwise returns false.
+
+ \a signal must be a signal member of this object, otherwise the behaviour
+ is undefined.
+
+ \snippet code/src_corelib_kernel_qobject.cpp 21
+
+ As the code snippet above illustrates, you can use this function
+ to avoid emitting a signal that nobody listens to.
+
+ \warning This function violates the object-oriented principle of
+ modularity. However, it might be useful when you need to perform
+ expensive initialization only if something is connected to a
+ signal.
+*/
+bool QObject::isSignalConnected(const QMetaMethod &signal) const
+{
+ Q_D(const QObject);
+ if (!signal.mobj)
+ return false;
+
+ Q_ASSERT_X(signal.mobj->cast(this) && signal.methodType() == QMetaMethod::Signal,
+ "QObject::isSignalConnected" , "the parametter must be a signal member of the object");
+ uint signalIndex = (signal.handle - QMetaObjectPrivate::get(signal.mobj)->methodData)/5;
+
+ if (signal.mobj->d.data[signal.handle + 4] & MethodCloned)
+ signalIndex = QMetaObjectPrivate::originalClone(signal.mobj, signalIndex);
+
+ int signalOffset;
+ int methodOffset;
+ computeOffsets(signal.mobj, &signalOffset, &methodOffset);
+ signalIndex += signalOffset;
+
+ if (signalIndex < sizeof(d->connectedSignals) * 8)
+ return d->isSignalConnected(signalIndex);
+
+ QMutexLocker locker(signalSlotLock(this));
+ if (d->connectionLists) {
+ if (signalIndex < uint(d->connectionLists->count())) {
+ const QObjectPrivate::Connection *c =
+ d->connectionLists->at(signalIndex).first;
+ while (c) {
+ if (c->receiver)
+ return true;
+ c = c->nextConnectionList;
+ }
+ }
+ }
+ return false;
+}
+
+/*!
\internal
This helper function calculates signal and method index for the given
@@ -2278,18 +2340,18 @@ static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaM
You must use the \c SIGNAL() and \c SLOT() macros when specifying
the \a signal and the \a method, for example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 22
+ \snippet code/src_corelib_kernel_qobject.cpp 22
This example ensures that the label always displays the current
scroll bar value. Note that the signal and slots parameters must not
contain any variable names, only the type. E.g. the following would
not work and return false:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 23
+ \snippet code/src_corelib_kernel_qobject.cpp 23
A signal can also be connected to another signal:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 24
+ \snippet code/src_corelib_kernel_qobject.cpp 24
In this example, the \c MyWidget constructor relays a signal from
a private member variable, and makes it available under a name
@@ -2326,7 +2388,7 @@ static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaM
scenes. If you try to use a queued connection and get the error
message
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 25
+ \snippet code/src_corelib_kernel_qobject.cpp 25
call qRegisterMetaType() to register the data type before you
establish the connection.
@@ -2376,7 +2438,6 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
int signalOffset, methodOffset;
computeOffsets(smeta, &signalOffset, &methodOffset);
- int signal_absolute_index = signal_index + methodOffset;
signal_index += signalOffset;
QByteArray tmp_method_name;
@@ -2445,12 +2506,12 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
}
#ifndef QT_NO_DEBUG
- QMetaMethod smethod = smeta->method(signal_absolute_index);
+ QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
QMetaMethod rmethod = rmeta->method(method_index_relative + rmeta->methodOffset());
check_and_warn_compat(smeta, smethod, rmeta, rmethod);
#endif
QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
- sender, signal_index, receiver, method_index_relative, rmeta ,type, types));
+ sender, signal_index, smeta, receiver, method_index_relative, rmeta ,type, types));
if (handle)
const_cast<QObject*>(sender)->connectNotify(signal - 1);
return handle;
@@ -2538,7 +2599,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
check_and_warn_compat(smeta, signal, rmeta, method);
#endif
QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
- sender, signal_index, receiver, method_index, 0, type, types));
+ sender, signal_index, signal.enclosingMetaObject(), receiver, method_index, 0, type, types));
if (handle)
const_cast<QObject*>(sender)->connectNotify(signalSignature.constData());
return handle;
@@ -2575,27 +2636,27 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
\list 1
\li Disconnect everything connected to an object's signals:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 26
+ \snippet code/src_corelib_kernel_qobject.cpp 26
equivalent to the non-static overloaded function
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 27
+ \snippet code/src_corelib_kernel_qobject.cpp 27
\li Disconnect everything connected to a specific signal:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 28
+ \snippet code/src_corelib_kernel_qobject.cpp 28
equivalent to the non-static overloaded function
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 29
+ \snippet code/src_corelib_kernel_qobject.cpp 29
\li Disconnect a specific receiver:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 30
+ \snippet code/src_corelib_kernel_qobject.cpp 30
equivalent to the non-static overloaded function
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 31
+ \snippet code/src_corelib_kernel_qobject.cpp 31
\endlist
@@ -2697,7 +2758,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
}
if (!method) {
- res |= QMetaObjectPrivate::disconnect(sender, signal_index, receiver, -1, 0);
+ res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, -1, 0);
} else {
const QMetaObject *rmeta = receiver->metaObject();
do {
@@ -2708,7 +2769,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
rmeta = rmeta->superClass();
if (method_index < 0)
break;
- res |= QMetaObjectPrivate::disconnect(sender, signal_index, receiver, method_index, 0);
+ res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0);
method_found = true;
} while ((rmeta = rmeta->superClass()));
}
@@ -2721,8 +2782,11 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
err_method_notfound(receiver, method_arg, "disconnect");
err_info_about_objects("disconnect", sender, receiver);
}
- if (res)
+ if (res) {
+ if (!signal)
+ const_cast<QObject*>(sender)->disconnectNotify(QMetaMethod());
const_cast<QObject*>(sender)->disconnectNotify(signal ? (signal - 1) : 0);
+ }
return res;
}
@@ -2807,9 +2871,16 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
return false;
}
- if (!QMetaObjectPrivate::disconnect(sender, signal_index, receiver, method_index, 0))
+ if (!QMetaObjectPrivate::disconnect(sender, signal_index, signal.mobj, receiver, method_index, 0))
return false;
+ if (!signal.isValid()) {
+ // The signal is a wildcard, meaning all signals were disconnected.
+ // QMetaObjectPrivate::disconnect() doesn't call disconnectNotify()
+ // per connection in this case. Call it once now, with an invalid
+ // QMetaMethod as argument, as documented.
+ const_cast<QObject*>(sender)->disconnectNotify(signal);
+ }
const_cast<QObject*>(sender)->disconnectNotify(method.mobj ? signalSignature.constData() : 0);
return true;
}
@@ -2840,18 +2911,30 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
/*!
\fn void QObject::connectNotify(const char *signal)
+ \obsolete
+*/
+void QObject::connectNotify(const char *)
+{
+}
+
+/*!
+ \fn void QObject::disconnectNotify(const char *signal)
+ \obsolete
+*/
+void QObject::disconnectNotify(const char *)
+{
+}
+
+/*!
+ \since 5.0
This virtual function is called when something has been connected
to \a signal in this object.
- If you want to compare \a signal with a specific signal, use
- QLatin1String and the \c SIGNAL() macro as follows:
-
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 32
+ If you want to compare \a signal with a specific signal, you can
+ use QMetaMethod::fromSignal() as follows:
- If the signal contains multiple parameters or parameters that
- contain spaces, call QMetaObject::normalizedSignature() on
- the result of the \c SIGNAL() macro.
+ \snippet code/src_corelib_kernel_qobject.cpp 32
\warning This function violates the object-oriented principle of
modularity. However, it might be useful when you need to perform
@@ -2861,12 +2944,13 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
\sa connect(), disconnectNotify()
*/
-void QObject::connectNotify(const char *)
+void QObject::connectNotify(const QMetaMethod &signal)
{
+ Q_UNUSED(signal);
}
/*!
- \fn void QObject::disconnectNotify(const char *signal)
+ \since 5.0
This virtual function is called when something has been
disconnected from \a signal in this object.
@@ -2874,6 +2958,11 @@ void QObject::connectNotify(const char *)
See connectNotify() for an example of how to compare
\a signal with a specific signal.
+ If all signals were disconnected from this object (e.g., the
+ signal argument to disconnect() was 0), disconnectNotify()
+ is only called once, and the \a signal will be an invalid
+ QMetaMethod (QMetaMethod::isValid() returns false).
+
\warning This function violates the object-oriented principle of
modularity. However, it might be useful for optimizing access to
expensive resources.
@@ -2881,17 +2970,19 @@ void QObject::connectNotify(const char *)
\sa disconnect(), connectNotify()
*/
-void QObject::disconnectNotify(const char *)
+void QObject::disconnectNotify(const QMetaMethod &signal)
{
+ Q_UNUSED(signal);
}
/* \internal
convert a signal index from the method range to the signal range
*/
-static int methodIndexToSignalIndex(const QMetaObject *metaObject, int signal_index)
+static int methodIndexToSignalIndex(const QMetaObject **base, int signal_index)
{
if (signal_index < 0)
return signal_index;
+ const QMetaObject *metaObject = *base;
while (metaObject && metaObject->methodOffset() > signal_index)
metaObject = metaObject->superClass();
@@ -2902,6 +2993,7 @@ static int methodIndexToSignalIndex(const QMetaObject *metaObject, int signal_in
signal_index = QMetaObjectPrivate::originalClone(metaObject, signal_index - methodOffset) + signalOffset;
else
signal_index = signal_index - methodOffset + signalOffset;
+ *base = metaObject;
}
return signal_index;
}
@@ -2916,8 +3008,9 @@ static int methodIndexToSignalIndex(const QMetaObject *metaObject, int signal_in
QMetaObject::Connection QMetaObject::connect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index, int type, int *types)
{
- signal_index = methodIndexToSignalIndex(sender->metaObject(), signal_index);
- return Connection(QMetaObjectPrivate::connect(sender, signal_index,
+ const QMetaObject *smeta = sender->metaObject();
+ signal_index = methodIndexToSignalIndex(&smeta, signal_index);
+ return Connection(QMetaObjectPrivate::connect(sender, signal_index, smeta,
receiver, method_index,
0, //FIXME, we could speed this connection up by computing the relative index
type, types));
@@ -2930,7 +3023,8 @@ QMetaObject::Connection QMetaObject::connect(const QObject *sender, int signal_i
the QObjectPrivate::Connection* has a refcount of 2, so it must be passed to a QMetaObject::Connection
*/
-QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, int signal_index,
+QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender,
+ int signal_index, const QMetaObject *smeta,
const QObject *receiver, int method_index,
const QMetaObject *rmeta, int type, int *types)
{
@@ -2940,8 +3034,7 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, i
int method_offset = rmeta ? rmeta->methodOffset() : 0;
Q_ASSERT(!rmeta || QMetaObjectPrivate::get(rmeta)->revision >= 6);
QObjectPrivate::StaticMetaCallFunction callFunction =
- (rmeta && rmeta->d.extradata)
- ? reinterpret_cast<const QMetaObjectExtraData *>(rmeta->d.extradata)->static_metacall : 0;
+ rmeta ? rmeta->d.static_metacall : 0;
QOrderedMutexLocker locker(signalSlotLock(sender),
signalSlotLock(receiver));
@@ -2975,6 +3068,12 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, i
c->callFunction = callFunction;
QObjectPrivate::get(s)->addConnection(signal_index, c.data());
+
+ locker.unlock();
+ QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
+ if (smethod.isValid())
+ s->connectNotify(smethod);
+
return c.take();
}
@@ -2983,8 +3082,9 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, i
bool QMetaObject::disconnect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index)
{
- signal_index = methodIndexToSignalIndex(sender->metaObject(), signal_index);
- return QMetaObjectPrivate::disconnect(sender, signal_index,
+ const QMetaObject *smeta = sender->metaObject();
+ signal_index = methodIndexToSignalIndex(&smeta, signal_index);
+ return QMetaObjectPrivate::disconnect(sender, signal_index, smeta,
receiver, method_index, 0);
}
@@ -2997,8 +3097,9 @@ one of these connections will be removed.
bool QMetaObject::disconnectOne(const QObject *sender, int signal_index,
const QObject *receiver, int method_index)
{
- signal_index = methodIndexToSignalIndex(sender->metaObject(), signal_index);
- return QMetaObjectPrivate::disconnect(sender, signal_index,
+ const QMetaObject *smeta = sender->metaObject();
+ signal_index = methodIndexToSignalIndex(&smeta, signal_index);
+ return QMetaObjectPrivate::disconnect(sender, signal_index, smeta,
receiver, method_index, 0,
QMetaObjectPrivate::DisconnectOne);
}
@@ -3047,7 +3148,8 @@ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c,
/*! \internal
Same as the QMetaObject::disconnect, but \a signal_index must be the result of QObjectPrivate::signalIndex
*/
-bool QMetaObjectPrivate::disconnect(const QObject *sender, int signal_index,
+bool QMetaObjectPrivate::disconnect(const QObject *sender,
+ int signal_index, const QMetaObject *smeta,
const QObject *receiver, int method_index, void **slot,
DisconnectType disconnectType)
{
@@ -3070,9 +3172,9 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, int signal_index,
bool success = false;
if (signal_index < 0) {
// remove from all connection lists
- for (signal_index = -1; signal_index < connectionLists->count(); ++signal_index) {
+ for (int sig_index = -1; sig_index < connectionLists->count(); ++sig_index) {
QObjectPrivate::Connection *c =
- (*connectionLists)[signal_index].first;
+ (*connectionLists)[sig_index].first;
if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) {
success = true;
connectionLists->dirty = true;
@@ -3092,6 +3194,13 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, int signal_index,
if (connectionLists->orphaned && !connectionLists->inUse)
delete connectionLists;
+ locker.unlock();
+ if (success) {
+ QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
+ if (smethod.isValid())
+ s->disconnectNotify(smethod);
+ }
+
return success;
}
@@ -3101,13 +3210,13 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, int signal_index,
Searches recursively for all child objects of the given \a object, and connects
matching signals from them to slots of \a object that follow the following form:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 33
+ \snippet code/src_corelib_kernel_qobject.cpp 33
Let's assume our object has a child object of type QPushButton with
the \l{QObject::objectName}{object name} \c{button1}. The slot to catch the
button's \c{clicked()} signal would be:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 34
+ \snippet code/src_corelib_kernel_qobject.cpp 34
\sa QObject::setObjectName()
*/
@@ -3131,7 +3240,8 @@ void QMetaObject::connectSlotsByName(QObject *o)
int len = objName.length();
if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
continue;
- int sigIndex = co->d_func()->signalIndex(slot + len + 4);
+ const QMetaObject *smeta;
+ int sigIndex = co->d_func()->signalIndex(slot + len + 4, &smeta);
if (sigIndex < 0) { // search for compatible signals
const QMetaObject *smo = co->metaObject();
int slotlen = qstrlen(slot + len + 4) - 1;
@@ -3141,8 +3251,9 @@ void QMetaObject::connectSlotsByName(QObject *o)
continue;
if (!qstrncmp(method.methodSignature().constData(), slot + len + 4, slotlen)) {
+ smeta = method.enclosingMetaObject();
int signalOffset, methodOffset;
- computeOffsets(method.enclosingMetaObject(), &signalOffset, &methodOffset);
+ computeOffsets(smeta, &signalOffset, &methodOffset);
sigIndex = k + - methodOffset + signalOffset;
break;
}
@@ -3150,7 +3261,8 @@ void QMetaObject::connectSlotsByName(QObject *o)
}
if (sigIndex < 0)
continue;
- if (Connection(QMetaObjectPrivate::connect(co, sigIndex, o, i))) {
+
+ if (Connection(QMetaObjectPrivate::connect(co, sigIndex, smeta, o, i))) {
foundIt = true;
break;
}
@@ -3381,8 +3493,11 @@ void QMetaObject::activate(QObject *sender, int signal_index, void **argv)
It is different from QMetaObject::indexOfSignal(): indexOfSignal is the same as indexOfMethod
while QObjectPrivate::signalIndex is smaller because it doesn't give index to slots.
+
+ If \a meta is not 0, it is set to the meta-object where the signal was found.
*/
-int QObjectPrivate::signalIndex(const char *signalName) const
+int QObjectPrivate::signalIndex(const char *signalName,
+ const QMetaObject **meta) const
{
Q_Q(const QObject);
const QMetaObject *base = q->metaObject();
@@ -3396,6 +3511,8 @@ int QObjectPrivate::signalIndex(const char *signalName) const
relative_index = QMetaObjectPrivate::originalClone(base, relative_index);
int signalOffset, methodOffset;
computeOffsets(base, &signalOffset, &methodOffset);
+ if (meta)
+ *meta = base;
return relative_index + signalOffset;
}
@@ -3722,7 +3839,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 35
+ \snippet code/src_corelib_kernel_qobject.cpp 35
\sa QMetaObject::classInfo()
*/
@@ -3736,9 +3853,9 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
Example:
- \snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.h 1
+ \snippet tools/plugandpaintplugins/basictools/basictoolsplugin.h 1
\dots
- \snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.h 3
+ \snippet tools/plugandpaintplugins/basictools/basictoolsplugin.h 3
See the \l{tools/plugandpaintplugins/basictools}{Plug & Paint
Basic Tools} example for details.
@@ -3755,7 +3872,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
they have additional features accessible through the \l
{Meta-Object System}.
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 36
+ \snippet code/src_corelib_kernel_qobject.cpp 36
The property name and type and the \c READ function are required.
The type can be any type supported by QVariant, or it can be a
@@ -3765,7 +3882,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 37
+ \snippet code/src_corelib_kernel_qobject.cpp 37
For more details about how to use this macro, and a more detailed
example of its use, see the discussion on \l {Qt's Property System}.
@@ -3782,7 +3899,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 38
+ \snippet code/src_corelib_kernel_qobject.cpp 38
If you want to register an enum that is declared in another class,
the enum must be fully qualified with the name of the class
@@ -3804,12 +3921,12 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
For example, in QLibrary, the \l{QLibrary::LoadHints}{LoadHints} flag is
declared in the following way:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 39a
+ \snippet code/src_corelib_kernel_qobject.cpp 39a
The declaration of the flags themselves is performed in the public section
of the QLibrary class itself, using the \l Q_DECLARE_FLAGS() macro:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 39b
+ \snippet code/src_corelib_kernel_qobject.cpp 39b
\note This macro takes care of registering individual flag values
with the meta-object system, so it is unnecessary to use Q_ENUMS()
@@ -3828,10 +3945,10 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
For example:
- \snippet doc/src/snippets/signalsandslots/signalsandslots.h 1
+ \snippet signalsandslots/signalsandslots.h 1
\codeline
- \snippet doc/src/snippets/signalsandslots/signalsandslots.h 2
- \snippet doc/src/snippets/signalsandslots/signalsandslots.h 3
+ \snippet signalsandslots/signalsandslots.h 2
+ \snippet signalsandslots/signalsandslots.h 3
\note This macro requires the class to be a subclass of QObject. Use
Q_GADGET instead of Q_OBJECT to enable the meta object system's support
@@ -3927,7 +4044,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
be invoked via the meta-object system. The macro is written before
the return type, as shown in the following example:
- \snippet snippets/qmetaobject-invokable/window.h Window class with invokable method
+ \snippet qmetaobject-invokable/window.h Window class with invokable method
The \c invokableMethod() function is marked up using Q_INVOKABLE, causing
it to be registered with the meta-object system and enabling it to be
@@ -3968,7 +4085,7 @@ void qDeleteInEventHandler(QObject *o)
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 44
+ \snippet code/src_corelib_kernel_qobject.cpp 44
This example ensures that the label always displays the current
line edit text.
@@ -4003,7 +4120,7 @@ void qDeleteInEventHandler(QObject *o)
scenes. If you try to use a queued connection and get the error
message
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 25
+ \snippet code/src_corelib_kernel_qobject.cpp 25
make sure to declare the argument type with Q_DECLARE_METATYPE
*/
@@ -4029,11 +4146,11 @@ void qDeleteInEventHandler(QObject *o)
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 45
+ \snippet code/src_corelib_kernel_qobject.cpp 45
If your compiler support C++11 lambda expressions, you can use them:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 46
+ \snippet code/src_corelib_kernel_qobject.cpp 46
The connection will automatically disconnect if the sender is destroyed.
*/
@@ -4120,9 +4237,13 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa
QMetaObject::Connection ret(c.take());
locker.unlock();
+ QMetaMethod method = QMetaObjectPrivate::signal(senderMetaObject, signal_index);
+ Q_ASSERT(method.isValid());
+ s->connectNotify(method);
+
// reconstruct the signature to call connectNotify
const char *sig;
- QByteArray tmp_sig = senderMetaObject->method(signal_index - signalOffset + methodOffset).methodSignature();
+ QByteArray tmp_sig = method.methodSignature();
sig = tmp_sig.constData();
QVarLengthArray<char> signalSignature(qstrlen(sig) + 2);
signalSignature.data()[0] = char(QSIGNAL_CODE + '0');
@@ -4159,6 +4280,8 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
if (c->next)
c->next->prev = c->prev;
c->receiver = 0;
+ // disconnectNotify() not called (the signal index is unknown).
+
return true;
}
@@ -4178,19 +4301,19 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
\list 1
\li Disconnect everything connected to an object's signals:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 26
+ \snippet code/src_corelib_kernel_qobject.cpp 26
\li Disconnect everything connected to a specific signal:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 47
+ \snippet code/src_corelib_kernel_qobject.cpp 47
\li Disconnect a specific receiver:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 30
+ \snippet code/src_corelib_kernel_qobject.cpp 30
\li Disconnect a connection from one specific signal to a specific slot:
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 48
+ \snippet code/src_corelib_kernel_qobject.cpp 48
\endlist
@@ -4242,7 +4365,7 @@ bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject
signal_index += signalOffset;
}
- return QMetaObjectPrivate::disconnect(sender, signal_index, receiver, -1, slot);
+ return QMetaObjectPrivate::disconnect(sender, signal_index, senderMetaObject, receiver, -1, slot);
}
/*! \class QMetaObject::Connection
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 11b1a19e0b..5e969d67f6 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -365,11 +365,15 @@ protected:
QObject *sender() const;
int senderSignalIndex() const;
int receivers(const char* signal) const;
+ bool isSignalConnected(const QMetaMethod &signal) const;
virtual void timerEvent(QTimerEvent *);
virtual void childEvent(QChildEvent *);
virtual void customEvent(QEvent *);
+ virtual void connectNotify(const QMetaMethod &signal);
+ virtual void disconnectNotify(const QMetaMethod &signal);
+ // Deprecated; to be removed before Qt 5.0
virtual void connectNotify(const char *signal);
virtual void disconnectNotify(const char *signal);
@@ -382,6 +386,7 @@ protected:
static const QMetaObject staticQtMetaObject;
friend struct QMetaObject;
+ friend struct QMetaObjectPrivate;
friend class QMetaCallEvent;
friend class QApplication;
friend class QApplicationPrivate;
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index 419fcc1dd4..e016002afa 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -51,431 +51,6 @@ QT_BEGIN_NAMESPACE
namespace QtPrivate {
- template <typename T> struct RemoveRef { typedef T Type; };
- template <typename T> struct RemoveRef<T&> { typedef T Type; };
- template <typename T> struct RemoveConstRef { typedef T Type; };
- template <typename T> struct RemoveConstRef<const T&> { typedef T Type; };
-
- /*
- The following List classes are used to help to handle the list of arguments.
- It follow the same principles as the lisp lists.
- List_Left<L,N> take a list and a number as a parametter and returns (via the Value typedef,
- the list composed of the first N element of the list
- */
-#ifndef Q_COMPILER_VARIADIC_TEMPLATES
- template <typename Head, typename Tail> struct List { typedef Head Car; typedef Tail Cdr; };
- template <typename L, int N> struct List_Left { typedef List<typename L::Car, typename List_Left<typename L::Cdr, N - 1>::Value > Value; };
- template <typename L> struct List_Left<L,0> { typedef void Value; };
-#else
- // With variadic template, lists are represented using a variadic template argument instead of the lisp way
- template <typename...> struct List {};
- template <typename Head, typename... Tail> struct List<Head, Tail...> { typedef Head Car; typedef List<Tail...> Cdr; };
- template <typename, typename> struct List_Append;
- template <typename... L1, typename...L2> struct List_Append<List<L1...>, List<L2...>> { typedef List<L1..., L2...> Value; };
- template <typename L, int N> struct List_Left {
- typedef typename List_Append<List<typename L::Car>,typename List_Left<typename L::Cdr, N - 1>::Value>::Value Value;
- };
- template <typename L> struct List_Left<L, 0> { typedef List<> Value; };
-#endif
- // List_Select<L,N> returns (via typedef Value) the Nth element of the list L
- template <typename L, int N> struct List_Select { typedef typename List_Select<typename L::Cdr, N - 1>::Value Value; };
- template <typename L> struct List_Select<L,0> { typedef typename L::Car Value; };
-
- /*
- trick to set the return value of a slot that works even if the signal or the slot returns void
- to be used like function(), ApplyReturnValue<ReturnType>(&return_value)
- if function() returns a value, the operator,(T, ApplyReturnValue<ReturnType>) is called, but if it
- returns void, the builtin one is used without an error.
- */
- template <typename T>
- struct ApplyReturnValue {
- void *data;
- ApplyReturnValue(void *data_) : data(data_) {}
- };
- template<typename T, typename U>
- void operator,(const T &value, const ApplyReturnValue<U> &container) {
- if (container.data)
- *reinterpret_cast<U*>(container.data) = value;
- }
-#ifdef Q_COMPILER_RVALUE_REFS
- template<typename T, typename U>
- void operator,(T &&value, const ApplyReturnValue<U> &container) {
- if (container.data)
- *reinterpret_cast<U*>(container.data) = value;
- }
-#endif
- template<typename T>
- void operator,(T, const ApplyReturnValue<void> &) {}
-
-
- /*
- The FunctionPointer<Func> struct is a type trait for function pointer.
- - ArgumentCount is the number of argument, or -1 if it is unknown
- - the Object typedef is the Object of a pointer to member function
- - the Arguments typedef is the list of argument (in a QtPrivate::List)
- - the Function typedef is an alias to the template parametter Func
- - the call<Args, R>(f,o,args) method is used to call that slot
- Args is the list of argument of the signal
- R is the return type of the signal
- f is the function pointer
- o is the receiver object
- and args is the array of pointer to arguments, as used in qt_metacall
-
- The Functor<Func,N> struct is the helper to call a functor of N argument.
- its call function is the same as the FunctionPointer::call function.
- */
-#ifndef Q_COMPILER_VARIADIC_TEMPLATES
- template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1}; };
- template<class Obj, typename Ret> struct FunctionPointer<Ret (Obj::*) ()>
- {
- typedef Obj Object;
- typedef void Arguments;
- typedef Ret ReturnType;
- typedef Ret (Obj::*Function) ();
- enum {ArgumentCount = 0};
- template <typename Args, typename R>
- static void call(Function f, Obj *o, void **arg) { (o->*f)(), ApplyReturnValue<R>(arg[0]); }
- };
- template<class Obj, typename Ret, typename Arg1> struct FunctionPointer<Ret (Obj::*) (Arg1)>
- {
- typedef Obj Object;
- typedef List<Arg1, void> Arguments;
- typedef Ret ReturnType;
- typedef Ret (Obj::*Function) (Arg1);
- enum {ArgumentCount = 1};
- template <typename Args, typename R>
- static void call(Function f, Obj *o, void **arg) {
- (o->*f)((*reinterpret_cast<typename RemoveRef<typename Args::Car>::Type *>(arg[1]))), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<class Obj, typename Ret, typename Arg1, typename Arg2> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2)>
- {
- typedef Obj Object;
- typedef List<Arg1, List<Arg2, void> > Arguments;
- typedef Ret ReturnType;
- typedef Ret (Obj::*Function) (Arg1, Arg2);
- enum {ArgumentCount = 2};
- template <typename Args, typename R>
- static void call(Function f, Obj *o, void **arg) {
- (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3)>
- {
- typedef Obj Object;
- typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
- typedef Ret ReturnType;
- typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3);
- enum {ArgumentCount = 3};
- template <typename Args, typename R>
- static void call(Function f, Obj *o, void **arg) {
- (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4)>
- {
- typedef Obj Object;
- typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
- typedef Ret ReturnType;
- typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4);
- enum {ArgumentCount = 4};
- template <typename Args, typename R>
- static void call(Function f, Obj *o, void **arg) {
- (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4, Arg5)>
- {
- typedef Obj Object;
- typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, void> > > > > Arguments;
- typedef Ret ReturnType;
- typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5);
- enum {ArgumentCount = 5};
- template <typename Args, typename R>
- static void call(Function f, Obj *o, void **arg) {
- (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6>
- struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)>
- {
- typedef Obj Object;
- typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
- typedef Ret ReturnType;
- typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
- enum {ArgumentCount = 6};
- template <typename Args, typename R>
- static void call(Function f, Obj *o, void **arg) {
- (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
- }
- };
-
- template<typename Ret> struct FunctionPointer<Ret (*) ()>
- {
- typedef void Arguments;
- typedef Ret (*Function) ();
- typedef Ret ReturnType;
- enum {ArgumentCount = 0};
- template <typename Args, typename R>
- static void call(Function f, void *, void **arg) { f(), ApplyReturnValue<R>(arg[0]); }
- };
- template<typename Ret, typename Arg1> struct FunctionPointer<Ret (*) (Arg1)>
- {
- typedef List<Arg1, void> Arguments;
- typedef Ret ReturnType;
- typedef Ret (*Function) (Arg1);
- enum {ArgumentCount = 1};
- template <typename Args, typename R>
- static void call(Function f, void *, void **arg)
- { f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1])), ApplyReturnValue<R>(arg[0]); }
- };
- template<typename Ret, typename Arg1, typename Arg2> struct FunctionPointer<Ret (*) (Arg1, Arg2)>
- {
- typedef List<Arg1, List<Arg2, void> > Arguments;
- typedef Ret ReturnType;
- typedef Ret (*Function) (Arg1, Arg2);
- enum {ArgumentCount = 2};
- template <typename Args, typename R>
- static void call(Function f, void *, void **arg) {
- f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]); }
- };
- template<typename Ret, typename Arg1, typename Arg2, typename Arg3> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3)>
- {
- typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
- typedef Ret ReturnType;
- typedef Ret (*Function) (Arg1, Arg2, Arg3);
- enum {ArgumentCount = 3};
- template <typename Args, typename R>
- static void call(Function f, void *, void **arg) {
- f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3, Arg4)>
- {
- typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
- typedef Ret ReturnType;
- typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4);
- enum {ArgumentCount = 4};
- template <typename Args, typename R>
- static void call(Function f, void *, void **arg) {
- f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3, Arg4, Arg5)>
- {
- typedef List<Arg1, List<Arg2, List<Arg3,
- List<Arg4, List<Arg5, void > > > > > Arguments;
- typedef Ret ReturnType;
- typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4, Arg5);
- enum {ArgumentCount = 5};
- template <typename Args, typename R>
- static void call(Function f, void *, void **arg) {
- f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)>
- {
- typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
- typedef Ret ReturnType;
- typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
- enum {ArgumentCount = 6};
- template <typename Args, typename R>
- static void call(Function f, void *, void **arg) {
- f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
- }
- };
-
- template<typename F, int N> struct Functor;
- template<typename Function> struct Functor<Function, 0>
- {
- template <typename Args, typename R>
- static void call(Function &f, void *, void **arg) { f(), ApplyReturnValue<R>(arg[0]); }
- };
- template<typename Function> struct Functor<Function, 1>
- {
- template <typename Args, typename R>
- static void call(Function &f, void *, void **arg) {
- f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<typename Function> struct Functor<Function, 2>
- {
- template <typename Args, typename R>
- static void call(Function &f, void *, void **arg) {
- f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<typename Function> struct Functor<Function, 3>
- {
- template <typename Args, typename R>
- static void call(Function &f, void *, void **arg) {
- f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<typename Function> struct Functor<Function, 4>
- {
- template <typename Args, typename R>
- static void call(Function &f, void *, void **arg) {
- f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<typename Function> struct Functor<Function, 5>
- {
- template <typename Args, typename R>
- static void call(Function &f, void *, void **arg) {
- f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
- }
- };
- template<typename Function> struct Functor<Function, 6>
- {
- template <typename Args, typename R>
- static void call(Function &f, void *, void **arg) {
- f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
- *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
- }
- };
-#else
- template <int...> struct IndexesList {};
- template <typename IndexList, int Right> struct IndexesAppend;
- template <int... Left, int Right> struct IndexesAppend<IndexesList<Left...>, Right>
- { typedef IndexesList<Left..., Right> Value; };
- template <int N> struct Indexes
- { typedef typename IndexesAppend<typename Indexes<N - 1>::Value, N - 1>::Value Value; };
- template <> struct Indexes<0> { typedef IndexesList<> Value; };
- template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1}; };
-
- template <typename, typename, typename, typename> struct FunctorCall;
- template <int... I, typename... SignalArgs, typename R, typename Function>
- struct FunctorCall<IndexesList<I...>, List<SignalArgs...>, R, Function> {
- static void call(Function f, void **arg) {
- f((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[I+1]))...), ApplyReturnValue<R>(arg[0]);
- }
- };
- template <int... I, typename... SignalArgs, typename R, typename... SlotArgs, typename SlotRet, class Obj>
- struct FunctorCall<IndexesList<I...>, List<SignalArgs...>, R, SlotRet (Obj::*)(SlotArgs...)> {
- static void call(SlotRet (Obj::*f)(SlotArgs...), Obj *o, void **arg) {
- (o->*f)((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[I+1]))...), ApplyReturnValue<R>(arg[0]);
- }
- };
-
- template<class Obj, typename Ret, typename... Args> struct FunctionPointer<Ret (Obj::*) (Args...)>
- {
- typedef Obj Object;
- typedef List<Args...> Arguments;
- typedef Ret ReturnType;
- typedef Ret (Obj::*Function) (Args...);
- enum {ArgumentCount = sizeof...(Args)};
- template <typename SignalArgs, typename R>
- static void call(Function f, Obj *o, void **arg) {
- FunctorCall<typename Indexes<ArgumentCount>::Value, SignalArgs, R, Function>::call(f, o, arg);
- }
- };
-
- template<typename Ret, typename... Args> struct FunctionPointer<Ret (*) (Args...)>
- {
- typedef List<Args...> Arguments;
- typedef Ret ReturnType;
- typedef Ret (*Function) (Args...);
- enum {ArgumentCount = sizeof...(Args)};
- template <typename SignalArgs, typename R>
- static void call(Function f, void *, void **arg) {
- FunctorCall<typename Indexes<ArgumentCount>::Value, SignalArgs, R, Function>::call(f, arg);
- }
- };
-
- template<typename Function, int N> struct Functor
- {
- template <typename SignalArgs, typename R>
- static void call(Function &f, void *, void **arg) {
- FunctorCall<typename Indexes<N>::Value, SignalArgs, R, Function>::call(f, arg);
- }
- };
-#endif
-
- /*
- Logic that check if the arguments of the slot matches the argument of the signal.
- To be used like this:
- Q_STATIC_ASSERT(CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::value)
- */
- template<typename A1, typename A2> struct AreArgumentsCompatible {
- static int test(A2);
- static char test(...);
- 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 { 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> >
- {
- enum { value = AreArgumentsCompatible<typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value
- && CheckCompatibleArguments<Tail1, Tail2>::value };
- };
-#else
- 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...>>
- {
- enum { value = AreArgumentsCompatible<typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value
- && CheckCompatibleArguments<List<Tail1...>, List<Tail2...>>::value };
- };
-
-#endif
-
/*
Logic to statically generate the array of qMetaTypeId
ConnectionTypes<FunctionPointer<Signal>::Arguments>::types() returns an array
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index c8edadce9d..a31e091ae8 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -91,6 +91,7 @@ public:
static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *);
static void (*objectNameChanged)(QAbstractDeclarativeData *, QObject *);
static void (*signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **);
+ static int (*receivers)(QAbstractDeclarativeData *, const QObject *, int);
};
class Q_CORE_EXPORT QObjectPrivate : public QObjectData
@@ -175,7 +176,7 @@ public:
return o->d_func();
}
- int signalIndex(const char *signalName) const;
+ int signalIndex(const char *signalName, const QMetaObject **meta = 0) const;
inline bool isSignalConnected(uint signalIdx) const;
public:
diff --git a/src/corelib/kernel/qobjectcleanuphandler.cpp b/src/corelib/kernel/qobjectcleanuphandler.cpp
index 166a90a74f..f165ec96ca 100644
--- a/src/corelib/kernel/qobjectcleanuphandler.cpp
+++ b/src/corelib/kernel/qobjectcleanuphandler.cpp
@@ -121,7 +121,7 @@ void QObjectCleanupHandler::remove(QObject *object)
Returns true if this cleanup handler is empty or if all objects in
this cleanup handler have been destroyed; otherwise return false.
- \sa add() remove() clear()
+ \sa add(), remove(), clear()
*/
bool QObjectCleanupHandler::isEmpty() const
{
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 9bcb8b9211..cc442457b0 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -44,6 +44,8 @@
#include <QtCore/qnamespace.h>
+#include <QtCore/qobjectdefs_impl.h>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -55,7 +57,7 @@ struct QByteArrayData;
class QString;
#ifndef Q_MOC_OUTPUT_REVISION
-#define Q_MOC_OUTPUT_REVISION 65
+#define Q_MOC_OUTPUT_REVISION 66
#endif
// The following macros are our "extensions" to C++
@@ -158,7 +160,6 @@ public: \
QT_TR_FUNCTIONS \
virtual int qt_metacall(QMetaObject::Call, int, void **); \
private: \
- Q_DECL_HIDDEN static const QMetaObjectExtraData staticMetaObjectExtraData; \
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);
/* tmake ignore Q_OBJECT */
@@ -451,7 +452,10 @@ struct Q_CORE_EXPORT QMetaObject
const QMetaObject *superdata;
const QByteArrayData *stringdata;
const uint *data;
- const void *extradata;
+ typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **);
+ StaticMetacallFunction static_metacall;
+ const QMetaObject **relatedMetaObjects;
+ void *extradata; //reserved for future use
} d;
};
@@ -479,17 +483,6 @@ public:
#endif
};
-typedef const QMetaObject& (*QMetaObjectAccessor)();
-
-struct QMetaObjectExtraData
-{
- const QMetaObject **objects;
-
- 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
- StaticMetacallFunction static_metacall;
-};
-
inline const QMetaObject *QMetaObject::superClass() const
{ return d.superdata; }
diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
new file mode 100644
index 0000000000..5efe08b3e5
--- /dev/null
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -0,0 +1,485 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 Q_QDOC
+
+#ifndef QOBJECTDEFS_H
+#error Do not include qobjectdefs_impl.h directly
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+namespace QtPrivate {
+ template <typename T> struct RemoveRef { typedef T Type; };
+ template <typename T> struct RemoveRef<T&> { typedef T Type; };
+ template <typename T> struct RemoveConstRef { typedef T Type; };
+ template <typename T> struct RemoveConstRef<const T&> { typedef T Type; };
+
+ /*
+ The following List classes are used to help to handle the list of arguments.
+ It follow the same principles as the lisp lists.
+ List_Left<L,N> take a list and a number as a parametter and returns (via the Value typedef,
+ the list composed of the first N element of the list
+ */
+#ifndef Q_COMPILER_VARIADIC_TEMPLATES
+ template <typename Head, typename Tail> struct List { typedef Head Car; typedef Tail Cdr; };
+ template <typename L, int N> struct List_Left { typedef List<typename L::Car, typename List_Left<typename L::Cdr, N - 1>::Value > Value; };
+ template <typename L> struct List_Left<L,0> { typedef void Value; };
+#else
+ // With variadic template, lists are represented using a variadic template argument instead of the lisp way
+ template <typename...> struct List {};
+ template <typename Head, typename... Tail> struct List<Head, Tail...> { typedef Head Car; typedef List<Tail...> Cdr; };
+ template <typename, typename> struct List_Append;
+ template <typename... L1, typename...L2> struct List_Append<List<L1...>, List<L2...>> { typedef List<L1..., L2...> Value; };
+ template <typename L, int N> struct List_Left {
+ typedef typename List_Append<List<typename L::Car>,typename List_Left<typename L::Cdr, N - 1>::Value>::Value Value;
+ };
+ template <typename L> struct List_Left<L, 0> { typedef List<> Value; };
+#endif
+ // List_Select<L,N> returns (via typedef Value) the Nth element of the list L
+ template <typename L, int N> struct List_Select { typedef typename List_Select<typename L::Cdr, N - 1>::Value Value; };
+ template <typename L> struct List_Select<L,0> { typedef typename L::Car Value; };
+
+ /*
+ trick to set the return value of a slot that works even if the signal or the slot returns void
+ to be used like function(), ApplyReturnValue<ReturnType>(&return_value)
+ if function() returns a value, the operator,(T, ApplyReturnValue<ReturnType>) is called, but if it
+ returns void, the builtin one is used without an error.
+ */
+ template <typename T>
+ struct ApplyReturnValue {
+ void *data;
+ ApplyReturnValue(void *data_) : data(data_) {}
+ };
+ template<typename T, typename U>
+ void operator,(const T &value, const ApplyReturnValue<U> &container) {
+ if (container.data)
+ *reinterpret_cast<U*>(container.data) = value;
+ }
+#ifdef Q_COMPILER_RVALUE_REFS
+ template<typename T, typename U>
+ void operator,(T &&value, const ApplyReturnValue<U> &container) {
+ if (container.data)
+ *reinterpret_cast<U*>(container.data) = value;
+ }
+#endif
+ template<typename T>
+ void operator,(T, const ApplyReturnValue<void> &) {}
+
+
+ /*
+ The FunctionPointer<Func> struct is a type trait for function pointer.
+ - ArgumentCount is the number of argument, or -1 if it is unknown
+ - the Object typedef is the Object of a pointer to member function
+ - the Arguments typedef is the list of argument (in a QtPrivate::List)
+ - the Function typedef is an alias to the template parametter Func
+ - the call<Args, R>(f,o,args) method is used to call that slot
+ Args is the list of argument of the signal
+ R is the return type of the signal
+ f is the function pointer
+ o is the receiver object
+ and args is the array of pointer to arguments, as used in qt_metacall
+
+ The Functor<Func,N> struct is the helper to call a functor of N argument.
+ its call function is the same as the FunctionPointer::call function.
+ */
+#ifndef Q_COMPILER_VARIADIC_TEMPLATES
+ template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1}; };
+ template<class Obj, typename Ret> struct FunctionPointer<Ret (Obj::*) ()>
+ {
+ typedef Obj Object;
+ typedef void Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (Obj::*Function) ();
+ enum {ArgumentCount = 0};
+ template <typename Args, typename R>
+ static void call(Function f, Obj *o, void **arg) { (o->*f)(), ApplyReturnValue<R>(arg[0]); }
+ };
+ template<class Obj, typename Ret, typename Arg1> struct FunctionPointer<Ret (Obj::*) (Arg1)>
+ {
+ typedef Obj Object;
+ typedef List<Arg1, void> Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (Obj::*Function) (Arg1);
+ enum {ArgumentCount = 1};
+ template <typename Args, typename R>
+ static void call(Function f, Obj *o, void **arg) {
+ (o->*f)((*reinterpret_cast<typename RemoveRef<typename Args::Car>::Type *>(arg[1]))), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<class Obj, typename Ret, typename Arg1, typename Arg2> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2)>
+ {
+ typedef Obj Object;
+ typedef List<Arg1, List<Arg2, void> > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (Obj::*Function) (Arg1, Arg2);
+ enum {ArgumentCount = 2};
+ template <typename Args, typename R>
+ static void call(Function f, Obj *o, void **arg) {
+ (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3)>
+ {
+ typedef Obj Object;
+ typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3);
+ enum {ArgumentCount = 3};
+ template <typename Args, typename R>
+ static void call(Function f, Obj *o, void **arg) {
+ (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4)>
+ {
+ typedef Obj Object;
+ typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4);
+ enum {ArgumentCount = 4};
+ template <typename Args, typename R>
+ static void call(Function f, Obj *o, void **arg) {
+ (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4, Arg5)>
+ {
+ typedef Obj Object;
+ typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, void> > > > > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5);
+ enum {ArgumentCount = 5};
+ template <typename Args, typename R>
+ static void call(Function f, Obj *o, void **arg) {
+ (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6>
+ struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)>
+ {
+ typedef Obj Object;
+ typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
+ enum {ArgumentCount = 6};
+ template <typename Args, typename R>
+ static void call(Function f, Obj *o, void **arg) {
+ (o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+
+ template<typename Ret> struct FunctionPointer<Ret (*) ()>
+ {
+ typedef void Arguments;
+ typedef Ret (*Function) ();
+ typedef Ret ReturnType;
+ enum {ArgumentCount = 0};
+ template <typename Args, typename R>
+ static void call(Function f, void *, void **arg) { f(), ApplyReturnValue<R>(arg[0]); }
+ };
+ template<typename Ret, typename Arg1> struct FunctionPointer<Ret (*) (Arg1)>
+ {
+ typedef List<Arg1, void> Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (*Function) (Arg1);
+ enum {ArgumentCount = 1};
+ template <typename Args, typename R>
+ static void call(Function f, void *, void **arg)
+ { f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1])), ApplyReturnValue<R>(arg[0]); }
+ };
+ template<typename Ret, typename Arg1, typename Arg2> struct FunctionPointer<Ret (*) (Arg1, Arg2)>
+ {
+ typedef List<Arg1, List<Arg2, void> > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (*Function) (Arg1, Arg2);
+ enum {ArgumentCount = 2};
+ template <typename Args, typename R>
+ static void call(Function f, void *, void **arg) {
+ f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]); }
+ };
+ template<typename Ret, typename Arg1, typename Arg2, typename Arg3> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3)>
+ {
+ typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (*Function) (Arg1, Arg2, Arg3);
+ enum {ArgumentCount = 3};
+ template <typename Args, typename R>
+ static void call(Function f, void *, void **arg) {
+ f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3, Arg4)>
+ {
+ typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4);
+ enum {ArgumentCount = 4};
+ template <typename Args, typename R>
+ static void call(Function f, void *, void **arg) {
+ f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3, Arg4, Arg5)>
+ {
+ typedef List<Arg1, List<Arg2, List<Arg3,
+ List<Arg4, List<Arg5, void > > > > > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4, Arg5);
+ enum {ArgumentCount = 5};
+ template <typename Args, typename R>
+ static void call(Function f, void *, void **arg) {
+ f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)>
+ {
+ typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
+ enum {ArgumentCount = 6};
+ template <typename Args, typename R>
+ static void call(Function f, void *, void **arg) {
+ f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+
+ template<typename F, int N> struct Functor;
+ template<typename Function> struct Functor<Function, 0>
+ {
+ template <typename Args, typename R>
+ static void call(Function &f, void *, void **arg) { f(), ApplyReturnValue<R>(arg[0]); }
+ };
+ template<typename Function> struct Functor<Function, 1>
+ {
+ template <typename Args, typename R>
+ static void call(Function &f, void *, void **arg) {
+ f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<typename Function> struct Functor<Function, 2>
+ {
+ template <typename Args, typename R>
+ static void call(Function &f, void *, void **arg) {
+ f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<typename Function> struct Functor<Function, 3>
+ {
+ template <typename Args, typename R>
+ static void call(Function &f, void *, void **arg) {
+ f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<typename Function> struct Functor<Function, 4>
+ {
+ template <typename Args, typename R>
+ static void call(Function &f, void *, void **arg) {
+ f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<typename Function> struct Functor<Function, 5>
+ {
+ template <typename Args, typename R>
+ static void call(Function &f, void *, void **arg) {
+ f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template<typename Function> struct Functor<Function, 6>
+ {
+ template <typename Args, typename R>
+ static void call(Function &f, void *, void **arg) {
+ f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
+ *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+#else
+ template <int...> struct IndexesList {};
+ template <typename IndexList, int Right> struct IndexesAppend;
+ template <int... Left, int Right> struct IndexesAppend<IndexesList<Left...>, Right>
+ { typedef IndexesList<Left..., Right> Value; };
+ template <int N> struct Indexes
+ { typedef typename IndexesAppend<typename Indexes<N - 1>::Value, N - 1>::Value Value; };
+ template <> struct Indexes<0> { typedef IndexesList<> Value; };
+ template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1}; };
+
+ template <typename, typename, typename, typename> struct FunctorCall;
+ template <int... I, typename... SignalArgs, typename R, typename Function>
+ struct FunctorCall<IndexesList<I...>, List<SignalArgs...>, R, Function> {
+ static void call(Function f, void **arg) {
+ f((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[I+1]))...), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+ template <int... I, typename... SignalArgs, typename R, typename... SlotArgs, typename SlotRet, class Obj>
+ struct FunctorCall<IndexesList<I...>, List<SignalArgs...>, R, SlotRet (Obj::*)(SlotArgs...)> {
+ static void call(SlotRet (Obj::*f)(SlotArgs...), Obj *o, void **arg) {
+ (o->*f)((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[I+1]))...), ApplyReturnValue<R>(arg[0]);
+ }
+ };
+
+ template<class Obj, typename Ret, typename... Args> struct FunctionPointer<Ret (Obj::*) (Args...)>
+ {
+ typedef Obj Object;
+ typedef List<Args...> Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (Obj::*Function) (Args...);
+ enum {ArgumentCount = sizeof...(Args)};
+ template <typename SignalArgs, typename R>
+ static void call(Function f, Obj *o, void **arg) {
+ FunctorCall<typename Indexes<ArgumentCount>::Value, SignalArgs, R, Function>::call(f, o, arg);
+ }
+ };
+
+ template<typename Ret, typename... Args> struct FunctionPointer<Ret (*) (Args...)>
+ {
+ typedef List<Args...> Arguments;
+ typedef Ret ReturnType;
+ typedef Ret (*Function) (Args...);
+ enum {ArgumentCount = sizeof...(Args)};
+ template <typename SignalArgs, typename R>
+ static void call(Function f, void *, void **arg) {
+ FunctorCall<typename Indexes<ArgumentCount>::Value, SignalArgs, R, Function>::call(f, arg);
+ }
+ };
+
+ template<typename Function, int N> struct Functor
+ {
+ template <typename SignalArgs, typename R>
+ static void call(Function &f, void *, void **arg) {
+ FunctorCall<typename Indexes<N>::Value, SignalArgs, R, Function>::call(f, arg);
+ }
+ };
+#endif
+
+ /*
+ Logic that check if the arguments of the slot matches the argument of the signal.
+ To be used like this:
+ Q_STATIC_ASSERT(CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::value)
+ */
+ template<typename A1, typename A2> struct AreArgumentsCompatible {
+ static int test(A2);
+ static char test(...);
+ 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 { 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> >
+ {
+ enum { value = AreArgumentsCompatible<typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value
+ && CheckCompatibleArguments<Tail1, Tail2>::value };
+ };
+#else
+ 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...>>
+ {
+ enum { value = AreArgumentsCompatible<typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value
+ && CheckCompatibleArguments<List<Tail1...>, List<Tail2...>>::value };
+ };
+
+#endif
+}
+
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp
index e0e14e5b79..cd88baf9bf 100644
--- a/src/corelib/kernel/qpointer.cpp
+++ b/src/corelib/kernel/qpointer.cpp
@@ -74,10 +74,10 @@
Example:
- \snippet doc/src/snippets/pointer/pointer.cpp 0
+ \snippet pointer/pointer.cpp 0
\dots
- \snippet doc/src/snippets/pointer/pointer.cpp 1
- \snippet doc/src/snippets/pointer/pointer.cpp 2
+ \snippet pointer/pointer.cpp 1
+ \snippet pointer/pointer.cpp 2
If the QLabel is deleted in the meantime, the \c label variable
will hold 0 instead of an invalid address, and the last line will
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index d8578a8059..50c24ba169 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -174,7 +174,7 @@ QSharedMemory::QSharedMemory(const QString &key, QObject *parent)
the shared memory segment, the detach() operation destroys the
shared memory segment.
- \sa detach() isAttached()
+ \sa detach(), isAttached()
*/
QSharedMemory::~QSharedMemory()
{
@@ -193,7 +193,7 @@ QSharedMemory::~QSharedMemory()
segment, it will \l {detach()} {detach} from it before setting the new key.
This function does not do an attach().
- \sa key() nativeKey() isAttached()
+ \sa key(), nativeKey(), isAttached()
*/
void QSharedMemory::setKey(const QString &key)
{
@@ -225,7 +225,7 @@ void QSharedMemory::setKey(const QString &key)
The application will not be portable if you set a native key.
- \sa nativeKey() key() isAttached()
+ \sa nativeKey(), key(), isAttached()
*/
void QSharedMemory::setNativeKey(const QString &key)
{
@@ -288,7 +288,7 @@ bool QSharedMemoryPrivate::initKey()
You can find the native, platform specific, key used by the operating system
by calling nativeKey().
- \sa setKey() setNativeKey()
+ \sa setKey(), setNativeKey()
*/
QString QSharedMemory::key() const
{
@@ -306,7 +306,7 @@ QString QSharedMemory::key() const
You can use the native key to access shared memory segments that have not
been created by Qt, or to grant shared memory access to non-Qt applications.
- \sa setKey() setNativeKey()
+ \sa setKey(), setNativeKey()
*/
QString QSharedMemory::nativeKey() const
{
@@ -363,7 +363,7 @@ bool QSharedMemory::create(int size, AccessMode mode)
Returns the size of the attached shared memory segment. If no shared
memory segment is attached, 0 is returned.
- \sa create() attach()
+ \sa create(), attach()
*/
int QSharedMemory::size() const
{
@@ -472,7 +472,7 @@ void *QSharedMemory::data()
the shared memory, and remember to release the lock with unlock()
after you are done.
- \sa attach() create()
+ \sa attach(), create()
*/
const void* QSharedMemory::constData() const
{
diff --git a/src/corelib/kernel/qsignalmapper.cpp b/src/corelib/kernel/qsignalmapper.cpp
index 27340020d8..c668047bd2 100644
--- a/src/corelib/kernel/qsignalmapper.cpp
+++ b/src/corelib/kernel/qsignalmapper.cpp
@@ -91,14 +91,14 @@ public:
signal, \c clicked(), which is emitted with the text of the button
that was clicked:
- \snippet doc/src/snippets/qsignalmapper/buttonwidget.h 0
- \snippet doc/src/snippets/qsignalmapper/buttonwidget.h 1
+ \snippet qsignalmapper/buttonwidget.h 0
+ \snippet qsignalmapper/buttonwidget.h 1
The only function that we need to implement is the constructor:
- \snippet doc/src/snippets/qsignalmapper/buttonwidget.cpp 0
- \snippet doc/src/snippets/qsignalmapper/buttonwidget.cpp 1
- \snippet doc/src/snippets/qsignalmapper/buttonwidget.cpp 2
+ \snippet qsignalmapper/buttonwidget.cpp 0
+ \snippet qsignalmapper/buttonwidget.cpp 1
+ \snippet qsignalmapper/buttonwidget.cpp 2
A list of texts is passed to the constructor. A signal mapper is
constructed and for each text in the list a QPushButton is
diff --git a/src/corelib/kernel/qsystemsemaphore.cpp b/src/corelib/kernel/qsystemsemaphore.cpp
index 0558f3cb59..70e75b54b9 100644
--- a/src/corelib/kernel/qsystemsemaphore.cpp
+++ b/src/corelib/kernel/qsystemsemaphore.cpp
@@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE
can use to use the same semaphore.
Example: Create a system semaphore
- \snippet doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp 0
+ \snippet code/src_corelib_kernel_qsystemsemaphore.cpp 0
A typical application of system semaphores is for controlling access
to a circular buffer shared by a producer process and a consumer
@@ -283,13 +283,13 @@ bool QSystemSemaphore::acquire()
Example: Create a system semaphore having five resources; acquire
them all and then release them all.
- \snippet doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp 1
+ \snippet code/src_corelib_kernel_qsystemsemaphore.cpp 1
This function can also "create" resources. For example, immediately
following the sequence of statements above, suppose we add the
statement:
- \snippet doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp 2
+ \snippet code/src_corelib_kernel_qsystemsemaphore.cpp 2
Ten new resources are now guarded by the semaphore, in addition to
the five that already existed. You would not normally use this
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 2131188439..23e1826006 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -61,9 +61,9 @@ QT_BEGIN_NAMESPACE
Example for a one second (1000 millisecond) timer (from the
\l{widgets/analogclock}{Analog Clock} example):
- \snippet examples/widgets/analogclock/analogclock.cpp 4
- \snippet examples/widgets/analogclock/analogclock.cpp 5
- \snippet examples/widgets/analogclock/analogclock.cpp 6
+ \snippet widgets/analogclock/analogclock.cpp 4
+ \snippet widgets/analogclock/analogclock.cpp 5
+ \snippet widgets/analogclock/analogclock.cpp 6
From then on, the \c update() slot is called every second.
@@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE
QTimer::singleShot() function to call a slot after a specified
interval:
- \snippet doc/src/snippets/timers/timers.cpp 3
+ \snippet timers/timers.cpp 3
In multithreaded applications, you can use QTimer in any thread
that has an event loop. To start an event loop from a non-GUI
@@ -87,9 +87,9 @@ QT_BEGIN_NAMESPACE
been processed. This can be used to do heavy work while providing
a snappy user interface:
- \snippet doc/src/snippets/timers/timers.cpp 4
- \snippet doc/src/snippets/timers/timers.cpp 5
- \snippet doc/src/snippets/timers/timers.cpp 6
+ \snippet timers/timers.cpp 4
+ \snippet timers/timers.cpp 5
+ \snippet timers/timers.cpp 6
\c processOneThing() will from then on be called repeatedly. It
should be written in such a way that it always returns quickly
@@ -304,7 +304,7 @@ QT_END_INCLUDE_NAMESPACE
create a local QTimer object.
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qtimer.cpp 0
+ \snippet code/src_corelib_kernel_qtimer.cpp 0
This sample program automatically terminates after 10 minutes
(600,000 milliseconds).
@@ -343,7 +343,7 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, QObject *receiver, co
if (msec == 0) {
// special code shortpath for 0-timers
const char* bracketPosition = strchr(member, '(');
- if (!bracketPosition || !(member[0] >= '0' && member[0] <= '3')) {
+ if (!bracketPosition || !(member[0] >= '0' && member[0] <= '2')) {
qWarning("QTimer::singleShot: Invalid slot specification");
return;
}
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 892883bacd..c34a3acb70 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -338,7 +338,7 @@ public:
it via QObject::tr(). Here's the \c main() function from the
\l{linguist/hellotr}{Hello tr()} example:
- \snippet examples/linguist/hellotr/main.cpp 2
+ \snippet linguist/hellotr/main.cpp 2
Note that the translator must be created \e before the
application's widgets.
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 10b86bcb48..7ccc5e500e 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -87,7 +87,7 @@ class HandlersManager
{
static const QVariant::Handler *Handlers[QModulesPrivate::ModulesCount];
public:
- const QVariant::Handler *operator[] (const int typeId) const
+ const QVariant::Handler *operator[] (const uint typeId) const
{
return Handlers[QModulesPrivate::moduleForType(typeId)];
}
@@ -776,6 +776,7 @@ static void customConstruct(QVariant::Private *d, const void *copy)
const QMetaType type(d->type);
const uint size = type.sizeOf();
if (!size) {
+ qWarning("Trying to construct an instance of an invalid type, type id: %i", d->type);
d->type = QVariant::Invalid;
return;
}
@@ -839,6 +840,9 @@ static void customStreamDebug(QDebug dbg, const QVariant &variant) {
QMetaType::TypeFlags flags = QMetaType::typeFlags(variant.userType());
if (flags & QMetaType::PointerToQObject)
dbg.nospace() << variant.value<QObject*>();
+#else
+ Q_UNUSED(dbg);
+ Q_UNUSED(variant);
#endif
}
#endif
@@ -909,7 +913,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names
Here is some example code to demonstrate the use of QVariant:
- \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 0
+ \snippet code/src_corelib_kernel_qvariant.cpp 0
You can even store QList<QVariant> and QMap<QString, QVariant>
values in a variant, so you can easily construct arbitrarily
@@ -921,7 +925,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names
have a defined type with no value set. However, note that QVariant
types can only be cast when they have had a value set.
- \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 1
+ \snippet code/src_corelib_kernel_qvariant.cpp 1
QVariant can be extended to support other types than those
mentioned in the \l Type enum. See the \l QMetaType documentation
@@ -935,13 +939,13 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names
toColor() function. Instead, you can use the QVariant::value() or
the qvariant_cast() template function. For example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 2
+ \snippet code/src_corelib_kernel_qvariant.cpp 2
The inverse conversion (e.g., from QColor to QVariant) is
automatic for all data types supported by QVariant, including
GUI-related types:
- \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 3
+ \snippet code/src_corelib_kernel_qvariant.cpp 3
\section1 Using canConvert() and convert() Consecutively
@@ -1677,13 +1681,15 @@ void QVariant::load(QDataStream &s)
return;
}
}
- create(static_cast<int>(typeId), 0);
+ create(typeId, 0);
d.is_null = is_null;
if (!isValid()) {
+ if (s.version() < QDataStream::Qt_5_0) {
// Since we wrote something, we should read something
- QString x;
- s >> x;
+ QString x;
+ s >> x;
+ }
d.is_null = true;
return;
}
@@ -1745,7 +1751,8 @@ void QVariant::save(QDataStream &s) const
}
if (!isValid()) {
- s << QString();
+ if (s.version() < QDataStream::Qt_5_0)
+ s << QString();
return;
}
@@ -2172,7 +2179,6 @@ inline T qNumVariantToHelper(const QVariant::Private &d,
\b{Warning:} If the value is convertible to a \l LongLong but is too
large to be represented in an int, the resulting arithmetic overflow will
not be reflected in \a ok. A simple workaround is to use QString::toInt().
- Fixing this bug has been postponed to Qt 5 in order to avoid breaking existing code.
\sa canConvert(), convert()
*/
@@ -2192,7 +2198,6 @@ int QVariant::toInt(bool *ok) const
\b{Warning:} If the value is convertible to a \l ULongLong but is too
large to be represented in an unsigned int, the resulting arithmetic overflow will
not be reflected in \a ok. A simple workaround is to use QString::toUInt().
- Fixing this bug has been postponed to Qt 5 in order to avoid breaking existing code.
\sa canConvert(), convert()
*/
@@ -2527,7 +2532,7 @@ bool QVariant::convert(int targetTypeId)
}
/*!
- \fn convert(const int type, void *ptr) const
+ \fn bool QVariant::convert(const int type, void *ptr) const
\internal
Created for qvariant_cast() usage
*/
@@ -2671,7 +2676,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 4
+ \snippet code/src_corelib_kernel_qvariant.cpp 4
\sa value(), fromValue(), canConvert()
*/
@@ -2688,7 +2693,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 5
+ \snippet code/src_corelib_kernel_qvariant.cpp 5
\sa setValue(), fromValue(), canConvert()
*/
@@ -2700,7 +2705,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 6
+ \snippet code/src_corelib_kernel_qvariant.cpp 6
\sa convert()
*/
@@ -2712,7 +2717,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
Example:
- \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 7
+ \snippet code/src_corelib_kernel_qvariant.cpp 7
\note If you are working with custom types, you should use
the Q_DECLARE_METATYPE() macro to register your custom type.
@@ -2737,7 +2742,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
For example, a QObject pointer can be stored in a variant with the
following code:
- \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 8
+ \snippet code/src_corelib_kernel_qvariant.cpp 8
\sa QVariant::fromValue()
*/
diff --git a/src/corelib/kernel/qwineventnotifier.cpp b/src/corelib/kernel/qwineventnotifier.cpp
index 8af1ab2161..b48bd0c8cc 100644
--- a/src/corelib/kernel/qwineventnotifier.cpp
+++ b/src/corelib/kernel/qwineventnotifier.cpp
@@ -48,6 +48,19 @@
QT_BEGIN_NAMESPACE
+class QWinEventNotifierPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QWinEventNotifier)
+public:
+ QWinEventNotifierPrivate()
+ : handleToEvent(0), enabled(false) {}
+ QWinEventNotifierPrivate(HANDLE h, bool e)
+ : handleToEvent(h), enabled(e) {}
+
+ HANDLE handleToEvent;
+ bool enabled;
+};
+
/*!
\class QWinEventNotifier
\since 5.0
@@ -103,7 +116,7 @@ QT_BEGIN_NAMESPACE
*/
QWinEventNotifier::QWinEventNotifier(QObject *parent)
- : QObject(parent), handleToEvent(0), enabled(false)
+ : QObject(*new QWinEventNotifierPrivate, parent)
{}
/*!
@@ -118,14 +131,14 @@ QWinEventNotifier::QWinEventNotifier(QObject *parent)
*/
QWinEventNotifier::QWinEventNotifier(HANDLE hEvent, QObject *parent)
- : QObject(parent), handleToEvent(hEvent), enabled(false)
+ : QObject(*new QWinEventNotifierPrivate(hEvent, false), parent)
{
- Q_D(QObject);
+ Q_D(QWinEventNotifier);
QEventDispatcherWin32 *eventDispatcher = qobject_cast<QEventDispatcherWin32 *>(d->threadData->eventDispatcher);
Q_ASSERT_X(eventDispatcher, "QWinEventNotifier::QWinEventNotifier()",
"Cannot create a win event notifier without a QEventDispatcherWin32");
eventDispatcher->registerEventNotifier(this);
- enabled = true;
+ d->enabled = true;
}
/*!
@@ -149,8 +162,9 @@ QWinEventNotifier::~QWinEventNotifier()
void QWinEventNotifier::setHandle(HANDLE hEvent)
{
+ Q_D(QWinEventNotifier);
setEnabled(false);
- handleToEvent = hEvent;
+ d->handleToEvent = hEvent;
}
/*!
@@ -161,7 +175,8 @@ void QWinEventNotifier::setHandle(HANDLE hEvent)
HANDLE QWinEventNotifier::handle() const
{
- return handleToEvent;
+ Q_D(const QWinEventNotifier);
+ return d->handleToEvent;
}
/*!
@@ -172,7 +187,8 @@ HANDLE QWinEventNotifier::handle() const
bool QWinEventNotifier::isEnabled() const
{
- return enabled;
+ Q_D(const QWinEventNotifier);
+ return d->enabled;
}
/*!
@@ -184,16 +200,16 @@ bool QWinEventNotifier::isEnabled() const
void QWinEventNotifier::setEnabled(bool enable)
{
- if (enabled == enable) // no change
+ Q_D(QWinEventNotifier);
+ if (d->enabled == enable) // no change
return;
- enabled = enable;
+ d->enabled = enable;
- Q_D(QObject);
QEventDispatcherWin32 *eventDispatcher = qobject_cast<QEventDispatcherWin32 *>(d->threadData->eventDispatcher);
if (!eventDispatcher) // perhaps application is shutting down
return;
- if (enabled)
+ if (enable)
eventDispatcher->registerEventNotifier(this);
else
eventDispatcher->unregisterEventNotifier(this);
@@ -205,16 +221,17 @@ void QWinEventNotifier::setEnabled(bool enable)
bool QWinEventNotifier::event(QEvent * e)
{
+ Q_D(QWinEventNotifier);
if (e->type() == QEvent::ThreadChange) {
- if (enabled) {
+ if (d->enabled) {
QMetaObject::invokeMethod(this, "setEnabled", Qt::QueuedConnection,
- Q_ARG(bool, enabled));
+ Q_ARG(bool, true));
setEnabled(false);
}
}
QObject::event(e); // will activate filters
if (e->type() == QEvent::WinEventAct) {
- emit activated(handleToEvent);
+ emit activated(d->handleToEvent);
return true;
}
return false;
diff --git a/src/corelib/kernel/qwineventnotifier.h b/src/corelib/kernel/qwineventnotifier.h
index b364c68e05..36ec415124 100644
--- a/src/corelib/kernel/qwineventnotifier.h
+++ b/src/corelib/kernel/qwineventnotifier.h
@@ -54,11 +54,11 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-
+class QWinEventNotifierPrivate;
class Q_CORE_EXPORT QWinEventNotifier : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QObject)
+ Q_DECLARE_PRIVATE(QWinEventNotifier)
public:
explicit QWinEventNotifier(QObject *parent = 0);
@@ -78,10 +78,6 @@ Q_SIGNALS:
protected:
bool event(QEvent * e);
-
-private:
- HANDLE handleToEvent;
- bool enabled;
};
QT_END_NAMESPACE
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index 2c84a937d5..2ac1978c2a 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -289,7 +289,7 @@ bool QMimeDatabasePrivate::inherits(const QString &mime, const QString &parent)
\threadsafe
- \snippet doc/src/snippets/code/src_corelib_mimetype_qmimedatabase.cpp 0
+ \snippet code/src_corelib_mimetype_qmimedatabase.cpp 0
\sa QMimeType
*/
diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp
index de26dbaf15..77d688d5bf 100644
--- a/src/corelib/mimetypes/qmimeglobpattern.cpp
+++ b/src/corelib/mimetypes/qmimeglobpattern.cpp
@@ -135,7 +135,7 @@ bool QMimeGlobPattern::matchFileName(const QString &inputFilename) const
return (m_pattern == filename);
// Other (quite rare) patterns, like "*.anim[1-9j]": use slow but correct method
- const QRegExp rx(m_pattern, Qt::CaseSensitive, QRegExp::WildcardUnix);
+ QRegExp rx(m_pattern, Qt::CaseSensitive, QRegExp::WildcardUnix);
return rx.exactMatch(filename);
}
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 3f192ea477..fc9e94037f 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -326,20 +326,29 @@ QObject *QFactoryLoader::instance(const QString &key) const
QObject *QFactoryLoader::instance(int index) const
{
Q_D(const QFactoryLoader);
- if (index < 0 || index >= d->libraryList.size())
+ if (index < 0)
return 0;
- QLibraryPrivate *library = d->libraryList.at(index);
- if (library->instance || library->loadPlugin()) {
- if (!library->inst)
- library->inst = library->instance();
- QObject *obj = library->inst.data();
- if (obj) {
- if (!obj->parent())
- obj->moveToThread(QCoreApplicationPrivate::mainThread());
- return obj;
+ if (index < d->libraryList.size()) {
+ QLibraryPrivate *library = d->libraryList.at(index);
+ if (library->instance || library->loadPlugin()) {
+ if (!library->inst)
+ library->inst = library->instance();
+ QObject *obj = library->inst.data();
+ if (obj) {
+ if (!obj->parent())
+ obj->moveToThread(QCoreApplicationPrivate::mainThread());
+ return obj;
+ }
}
+ return 0;
}
+
+ index -= d->libraryList.size();
+ QVector<QStaticPlugin> staticPlugins = QLibraryPrivate::staticPlugins();
+ if (index < staticPlugins.size())
+ return staticPlugins.at(index).instance();
+
return 0;
}
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 216e6e1e7c..a704b8f02d 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -127,7 +127,7 @@ static QBasicMutex qt_library_mutex;
symbol is not defined, the function pointer will be 0 and won't be
called.
- \snippet doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp 0
+ \snippet code/src_corelib_plugin_qlibrary.cpp 0
The symbol must be exported as a C function from the library for
resolve() to work. This means that the function must be wrapped in
@@ -138,7 +138,7 @@ static QBasicMutex qt_library_mutex;
use if you just want to call a function in a library without
explicitly loading the library first:
- \snippet doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp 1
+ \snippet code/src_corelib_plugin_qlibrary.cpp 1
\sa QPluginLoader
*/
@@ -163,6 +163,10 @@ static QBasicMutex qt_library_mutex;
If this hint is given, the filename of the library consists of
a path, which is a reference to an archive file, followed by
a reference to the archive member.
+ \value PreventUnloadHint
+ Prevents the library from being unloaded from the address space if close()
+ is called. The library's static variables are not reinitialized if open()
+ is called at a later time.
\sa loadHints
*/
@@ -1118,7 +1122,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver
not be resolved or if the library could not be loaded.
Example:
- \snippet doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp 2
+ \snippet code/src_corelib_plugin_qlibrary.cpp 2
The symbol must be exported as a C function from the library. This
means that the function must be wrapped in an \c{extern "C"} if
@@ -1126,11 +1130,11 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver
also explicitly export the function from the DLL using the
\c{__declspec(dllexport)} compiler directive, for example:
- \snippet doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp 3
+ \snippet code/src_corelib_plugin_qlibrary.cpp 3
with \c MY_EXPORT defined as
- \snippet doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp 4
+ \snippet code/src_corelib_plugin_qlibrary.cpp 4
*/
QFunctionPointer QLibrary::resolve(const char *symbol)
{
@@ -1230,6 +1234,8 @@ QString QLibrary::errorString() const
to the library \c shr_64.o in the archive file named \c libGL.a. This
is only supported on the AIX platform.
+ Setting PreventUnloadHint will only apply on Unix platforms.
+
The interpretation of the load hints is platform dependent, and if
you use it you are probably making some assumptions on which platform
you are compiling for, so use them only if you understand the consequences
diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h
index f373ad06b6..80e6fd3d4c 100644
--- a/src/corelib/plugin/qlibrary.h
+++ b/src/corelib/plugin/qlibrary.h
@@ -68,7 +68,8 @@ public:
enum LoadHint {
ResolveAllSymbolsHint = 0x01,
ExportExternalSymbolsHint = 0x02,
- LoadArchiveMemberHint = 0x04
+ LoadArchiveMemberHint = 0x04,
+ PreventUnloadHint = 0x08
};
Q_DECLARE_FLAGS(LoadHints, LoadHint)
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index cb81440c7e..0ad7a87c97 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -167,6 +167,18 @@ bool QLibraryPrivate::load_sys()
dlFlags |= RTLD_LOCAL;
}
#endif
+
+ // Provide access to RTLD_NODELETE flag on Unix
+ // From GNU documentation on RTLD_NODELETE:
+ // Do not unload the library during dlclose(). Consequently, the
+ // library's specific static variables are not reinitialized if the
+ // library is reloaded with dlopen() at a later time.
+#ifdef RTLD_NODELETE
+ if (loadHints & QLibrary::PreventUnloadHint) {
+ dlFlags |= RTLD_NODELETE;
+ }
+#endif
+
#if defined(Q_OS_AIX) // Not sure if any other platform actually support this thing.
if (loadHints & QLibrary::LoadArchiveMemberHint) {
dlFlags |= RTLD_MEMBER;
diff --git a/src/corelib/plugin/qplugin.qdoc b/src/corelib/plugin/qplugin.qdoc
index 77069e6dfd..001b0d5932 100644
--- a/src/corelib/plugin/qplugin.qdoc
+++ b/src/corelib/plugin/qplugin.qdoc
@@ -42,7 +42,7 @@
to the interface class called \a ClassName. The \a Identifier must
be unique. For example:
- \snippet examples/tools/plugandpaint/interfaces.h 3
+ \snippet tools/plugandpaint/interfaces.h 3
This macro is normally used right after the class definition for
\a ClassName, in a header file. See the
@@ -51,7 +51,7 @@
If you want to use Q_DECLARE_INTERFACE with interface classes
declared in a namespace then you have to make sure the Q_DECLARE_INTERFACE
is not inside a namespace though. For example:
- \snippet doc/src/snippets/code/doc_src_qplugin.cpp 0
+ \snippet code/doc_src_qplugin.cpp 0
\sa Q_INTERFACES(), Q_EXPORT_PLUGIN2(), {How to Create Qt Plugins}
*/
@@ -82,7 +82,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qplugin.cpp 1
+ \snippet code/doc_src_qplugin.cpp 1
See the \l{tools/plugandpaint}{Plug & Paint} example for details.
@@ -102,14 +102,14 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qplugin.cpp 2
+ \snippet code/doc_src_qplugin.cpp 2
Static plugins must also be included by the linker when your
application is built. For Qt's predefined plugins,
you can use the \c QTPLUGIN to add
the required plugins to your build. For example:
- \snippet doc/src/snippets/code/doc_src_qplugin.pro 3
+ \snippet code/doc_src_qplugin.pro 3
\sa {Static Plugins}, {How to Create Qt Plugins}, {Using qmake}
*/
diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h
index 6ca1892fa9..0e62d3660b 100644
--- a/src/corelib/plugin/qpluginloader.h
+++ b/src/corelib/plugin/qpluginloader.h
@@ -69,7 +69,7 @@ public:
QObject *instance();
- QT_DEPRECATED static QObjectList staticInstances();
+ static QObjectList staticInstances();
bool load();
bool unload();
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 26032323e0..b1805afd53 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -337,7 +337,7 @@ static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCrypto
b8.
Example:
- \snippet doc/src/snippets/code/src_corelib_plugin_quuid.cpp 0
+ \snippet code/src_corelib_plugin_quuid.cpp 0
*/
#ifndef QT_NO_QUUID_STRING
@@ -425,7 +425,7 @@ QUuid::QUuid(const QByteArray &text)
/*!
\since 5.0
- \fn QUuid::createUuidV3()
+ \fn QUuid QUuid::createUuidV3(const QUuid &ns, const QByteArray &baseData);
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.
@@ -435,7 +435,7 @@ QUuid::QUuid(const QByteArray &text)
/*!
\since 5.0
- \fn QUuid::createUuidV5()
+ \fn QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData);
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.
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index ad2cb02213..b8f7954e33 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -126,7 +126,7 @@ QT_BEGIN_NAMESPACE
The following snippet shows a state machine that will finish when a button
is clicked:
- \snippet doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp simple state machine
+ \snippet code/src_corelib_statemachine_qstatemachine.cpp simple state machine
This code example uses QState, which inherits QAbstractState. The
QState class provides a state that you can use to set properties
@@ -1747,7 +1747,7 @@ QStateMachine::~QStateMachine()
\value RestoreProperties The state machine should save the initial values of properties
and restore them later.
- \sa QStateMachine::globalRestorePolicy QState::assignProperty()
+ \sa QStateMachine::globalRestorePolicy, QState::assignProperty()
*/
@@ -2265,13 +2265,9 @@ void QSignalEventGenerator::qt_static_metacall(QObject *_o, QMetaObject::Call _c
Q_UNUSED(_a);
}
-const QMetaObjectExtraData QSignalEventGenerator::staticMetaObjectExtraData = {
- 0, qt_static_metacall
-};
-
const QMetaObject QSignalEventGenerator::staticMetaObject = {
{ &QObject::staticMetaObject, qt_meta_stringdata_QSignalEventGenerator.data,
- qt_meta_data_QSignalEventGenerator, &staticMetaObjectExtraData }
+ qt_meta_data_QSignalEventGenerator, qt_static_metacall, 0, 0 }
};
const QMetaObject *QSignalEventGenerator::metaObject() const
diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp
index 2e3029f3fa..abd2cc1c93 100644
--- a/src/corelib/thread/qatomic.cpp
+++ b/src/corelib/thread/qatomic.cpp
@@ -68,7 +68,7 @@
functions allow you to implement your own implicitly shared
classes.
- \snippet doc/src/snippets/code/src_corelib_thread_qatomic.cpp 0
+ \snippet code/src_corelib_thread_qatomic.cpp 0
\section2 Memory ordering
@@ -104,7 +104,7 @@
nothing and return false. This operation equates to the following
code:
- \snippet doc/src/snippets/code/src_corelib_thread_qatomic.cpp 1
+ \snippet code/src_corelib_thread_qatomic.cpp 1
There are 4 test-and-set functions: testAndSetRelaxed(),
testAndSetAcquire(), testAndSetRelease(), and
@@ -117,7 +117,7 @@
QAtomicInt and then assign a new value, returning the original
value. This operation equates to the following code:
- \snippet doc/src/snippets/code/src_corelib_thread_qatomic.cpp 2
+ \snippet code/src_corelib_thread_qatomic.cpp 2
There are 4 fetch-and-store functions: fetchAndStoreRelaxed(),
fetchAndStoreAcquire(), fetchAndStoreRelease(), and
@@ -131,7 +131,7 @@
returning the original value. This operation equates to the
following code:
- \snippet doc/src/snippets/code/src_corelib_thread_qatomic.cpp 3
+ \snippet code/src_corelib_thread_qatomic.cpp 3
There are 4 fetch-and-add functions: fetchAndAddRelaxed(),
fetchAndAddAcquire(), fetchAndAddRelease(), and
@@ -215,41 +215,12 @@
Constructs a copy of \a other.
*/
-/*! \fn QAtomicInt &QAtomicInt::operator=(int value)
-
- Assigns the \a value to this QAtomicInt and returns a reference to
- this QAtomicInt.
-*/
-
/*! \fn QAtomicInt &QAtomicInt::operator=(const QAtomicInt &other)
Assigns \a other to this QAtomicInt and returns a reference to
this QAtomicInt.
*/
-/*! \fn bool QAtomicInt::operator==(int value) const
-
- Returns true if the \a value is equal to the value in this
- QAtomicInt; otherwise returns false.
-*/
-
-/*! \fn bool QAtomicInt::operator!=(int value) const
-
- Returns true if the value of this QAtomicInt is not equal to \a
- value; otherwise returns false.
-*/
-
-/*! \fn bool QAtomicInt::operator!() const
-
- Returns true is the value of this QAtomicInt is zero; otherwise
- returns false.
-*/
-
-/*! \fn QAtomicInt::operator int() const
-
- Returns the value stored by the QAtomicInt object as an integer.
-*/
-
/*! \fn bool QAtomicInt::isReferenceCountingNative()
Returns true if reference counting is implemented using atomic
@@ -679,7 +650,7 @@
these functions do nothing and return false. This operation
equates to the following code:
- \snippet doc/src/snippets/code/src_corelib_thread_qatomic.cpp 4
+ \snippet code/src_corelib_thread_qatomic.cpp 4
There are 4 test-and-set functions: testAndSetRelaxed(),
testAndSetAcquire(), testAndSetRelease(), and
@@ -692,7 +663,7 @@
QAtomicPointer and then assign a new value, returning the original
value. This operation equates to the following code:
- \snippet doc/src/snippets/code/src_corelib_thread_qatomic.cpp 5
+ \snippet code/src_corelib_thread_qatomic.cpp 5
There are 4 fetch-and-store functions: fetchAndStoreRelaxed(),
fetchAndStoreAcquire(), fetchAndStoreRelease(), and
@@ -706,7 +677,7 @@
returning the original value. This operation equates to the
following code:
- \snippet doc/src/snippets/code/src_corelib_thread_qatomic.cpp 6
+ \snippet code/src_corelib_thread_qatomic.cpp 6
There are 4 fetch-and-add functions: fetchAndAddRelaxed(),
fetchAndAddAcquire(), fetchAndAddRelease(), and
@@ -783,46 +754,12 @@
Constructs a copy of \a other.
*/
-/*! \fn QAtomicPointer<T> &QAtomicPointer::operator=(T *value)
-
- Assigns the \a value to this QAtomicPointer and returns a
- reference to this QAtomicPointer.
-*/
-
/*! \fn QAtomicPointer<T> &QAtomicPointer::operator=(const QAtomicPointer<T> &other)
Assigns \a other to this QAtomicPointer and returns a reference to
this QAtomicPointer.
*/
-/*! \fn bool QAtomicPointer::operator==(T *value) const
-
- Returns true if the \a value is equal to the value in this
- QAtomicPointer; otherwise returns false.
-*/
-
-/*! \fn bool QAtomicPointer::operator!=(T *value) const
-
- Returns true if the value of this QAtomicPointer is not equal to
- \a value; otherwise returns false.
-*/
-
-/*! \fn bool QAtomicPointer::operator!() const
-
- Returns true is the current value of this QAtomicPointer is zero;
- otherwise returns false.
-*/
-
-/*! \fn QAtomicPointer::operator T *() const
-
- Returns the current pointer value stored by this QAtomicPointer
- object.
-*/
-
-/*! \fn T *QAtomicPointer::operator->() const
-
-*/
-
/*! \fn bool QAtomicPointer::isTestAndSetNative()
Returns true if test-and-set is implemented using atomic processor
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h
index a8e321b46a..5cd9a6a5c4 100644
--- a/src/corelib/thread/qatomic.h
+++ b/src/corelib/thread/qatomic.h
@@ -165,7 +165,7 @@ public:
This is a helper for the assignment operators of implicitly
shared classes. Your assignment operator should look like this:
- \snippet doc/src/snippets/code/src.corelib.thread.qatomic.h 0
+ \snippet code/src.corelib.thread.qatomic.h 0
*/
template <typename T>
inline void qAtomicAssign(T *&d, T *x)
@@ -184,7 +184,7 @@ inline void qAtomicAssign(T *&d, T *x)
the members and sets the refcount to 1. After that, your detach
function should look like this:
- \snippet doc/src/snippets/code/src.corelib.thread.qatomic.h 1
+ \snippet code/src.corelib.thread.qatomic.h 1
*/
template <typename T>
inline void qAtomicDetach(T *&d)
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 049230f7a4..145916d750 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -55,7 +55,7 @@
QT_BEGIN_NAMESPACE
-/*!
+/*
\class QBasicMutex
\brief QMutex POD
\internal
@@ -86,20 +86,20 @@ QT_BEGIN_NAMESPACE
For example, say there is a method that prints a message to the
user on two lines:
- \snippet doc/src/snippets/code/src_corelib_thread_qmutex.cpp 0
+ \snippet code/src_corelib_thread_qmutex.cpp 0
If these two methods are called in succession, the following happens:
- \snippet doc/src/snippets/code/src_corelib_thread_qmutex.cpp 1
+ \snippet code/src_corelib_thread_qmutex.cpp 1
If these two methods are called simultaneously from two threads then the
following sequence could result:
- \snippet doc/src/snippets/code/src_corelib_thread_qmutex.cpp 2
+ \snippet code/src_corelib_thread_qmutex.cpp 2
If we add a mutex, we should get the result we want:
- \snippet doc/src/snippets/code/src_corelib_thread_qmutex.cpp 3
+ \snippet code/src_corelib_thread_qmutex.cpp 3
Then only one thread can modify \c number at any given time and
the result is correct. This is a trivial example, of course, but
@@ -178,26 +178,7 @@ QMutex::~QMutex()
\sa unlock()
*/
-/*!\fn bool QMutex::trylock()
- Attempts to lock the mutex. If the lock was obtained, this function
- returns true. If another thread has locked the mutex, this
- function returns false immediately.
-
- If the lock was obtained, the mutex must be unlocked with unlock()
- before another thread can successfully lock it.
-
- Calling this function multiple times on the same mutex from the
- same thread is allowed if this mutex is a
- \l{QMutex::Recursive}{recursive mutex}. If this mutex is a
- \l{QMutex::NonRecursive}{non-recursive mutex}, this function will
- \e always return false when attempting to lock the mutex
- recursively.
-
- \sa lock(), unlock()
-*/
-
/*! \fn bool QMutex::tryLock(int timeout)
- \overload
Attempts to lock the mutex. This function returns true if the lock
was obtained; otherwise it returns false. If another thread has
@@ -268,7 +249,7 @@ bool QBasicMutex::isRecursive() {
For example, this complex function locks a QMutex upon entering
the function and unlocks the mutex at all the exit points:
- \snippet doc/src/snippets/code/src_corelib_thread_qmutex.cpp 4
+ \snippet code/src_corelib_thread_qmutex.cpp 4
This example function will get more complicated as it is
developed, which increases the likelihood that errors will occur.
@@ -276,7 +257,7 @@ bool QBasicMutex::isRecursive() {
Using QMutexLocker greatly simplifies the code, and makes it more
readable:
- \snippet doc/src/snippets/code/src_corelib_thread_qmutex.cpp 5
+ \snippet code/src_corelib_thread_qmutex.cpp 5
Now, the mutex will always be unlocked when the QMutexLocker
object is destroyed (when the function returns since \c locker is
@@ -292,7 +273,7 @@ bool QBasicMutex::isRecursive() {
for code that needs access to the mutex, such as
QWaitCondition::wait(). For example:
- \snippet doc/src/snippets/code/src_corelib_thread_qmutex.cpp 6
+ \snippet code/src_corelib_thread_qmutex.cpp 6
\sa QReadLocker, QWriteLocker, QMutex
*/
@@ -317,13 +298,6 @@ bool QBasicMutex::isRecursive() {
*/
/*!
- \fn QMutex *QMutexLocker::mutex() const
-
- Returns a pointer to the mutex that was locked in the
- constructor.
-*/
-
-/*!
\fn void QMutexLocker::unlock()
Unlocks this mutex locker. You can use \c relock() to lock
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 9a81b3d4bd..0743c36457 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -158,7 +158,6 @@ private:
#else // QT_NO_THREAD or qdoc
-
class Q_CORE_EXPORT QMutex
{
public:
diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp
index 1bb5e77e77..a10bd35eff 100644
--- a/src/corelib/thread/qmutex_linux.cpp
+++ b/src/corelib/thread/qmutex_linux.cpp
@@ -51,6 +51,7 @@
#include <sys/syscall.h>
#include <unistd.h>
#include <errno.h>
+#include <asm/unistd.h>
#ifndef QT_LINUX_FUTEX
# error "Qt build is broken: qmutex_linux.cpp is being built but futex support is not wanted"
@@ -71,7 +72,7 @@ static inline int futexFlags()
// try an operation that has no side-effects: wake up 42 threads
// futex will return -1 (errno==ENOSYS) if the flag isn't supported
// there should be no other error conditions
- value = syscall(SYS_futex, &futexFlagSupport,
+ value = syscall(__NR_futex, &futexFlagSupport,
FUTEX_WAKE | FUTEX_PRIVATE_FLAG,
42, 0, 0, 0);
if (value != -1) {
@@ -95,7 +96,9 @@ static inline int _q_futex(void *addr, int op, int val, const struct timespec *t
int *addr2 = 0;
int val2 = 0;
- return syscall(SYS_futex, int_addr, op | futexFlags(), val, timeout, addr2, val2);
+ // we use __NR_futex because some libcs (like Android's bionic) don't
+ // provide SYS_futex etc.
+ return syscall(__NR_futex, int_addr, op | futexFlags(), val, timeout, addr2, val2);
}
static inline QMutexData *dummyFutexValue()
@@ -121,7 +124,7 @@ bool QBasicMutex::lockInternal(int timeout)
struct timespec ts, *pts = 0;
if (timeout >= 1) {
// recalculate the timeout
- qint64 xtimeout = timeout * 1000 * 1000;
+ qint64 xtimeout = qint64(timeout) * 1000 * 1000;
xtimeout -= elapsedTimer.nsecsElapsed();
if (xtimeout <= 0) {
// timer expired after we returned
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
index 6b6674ccdf..4d24f8c7c7 100644
--- a/src/corelib/thread/qmutexpool.cpp
+++ b/src/corelib/thread/qmutexpool.cpp
@@ -66,7 +66,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
For example, consider this simple class:
- \snippet doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp 0
+ \snippet code/src_corelib_thread_qmutexpool.cpp 0
Adding a QMutex member to the Number class does not make sense,
because it is so small. However, in order to ensure that access to
@@ -76,7 +76,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
Code to calculate the square of a number would then look something
like this:
- \snippet doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp 1
+ \snippet code/src_corelib_thread_qmutexpool.cpp 1
This function will safely calculate the square of a number, since
it uses a mutex from a QMutexPool. The mutex is locked and
diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp
index 519bae9fa6..1aba2f537e 100644
--- a/src/corelib/thread/qreadwritelock.cpp
+++ b/src/corelib/thread/qreadwritelock.cpp
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp 0
+ \snippet code/src_corelib_thread_qreadwritelock.cpp 0
To ensure that writers aren't blocked forever by readers, readers
attempting to obtain a lock will not succeed if there is a blocked
@@ -135,7 +135,7 @@ QReadWriteLock::~QReadWriteLock()
thread if any thread (including the current) has locked for
writing.
- \sa unlock() lockForWrite() tryLockForRead()
+ \sa unlock(), lockForWrite(), tryLockForRead()
*/
void QReadWriteLock::lockForRead()
{
@@ -178,7 +178,7 @@ void QReadWriteLock::lockForRead()
If the lock was obtained, the lock must be unlocked with unlock()
before another thread can successfully lock it.
- \sa unlock() lockForRead()
+ \sa unlock(), lockForRead()
*/
bool QReadWriteLock::tryLockForRead()
{
@@ -223,7 +223,7 @@ bool QReadWriteLock::tryLockForRead()
If the lock was obtained, the lock must be unlocked with unlock()
before another thread can successfully lock it.
- \sa unlock() lockForRead()
+ \sa unlock(), lockForRead()
*/
bool QReadWriteLock::tryLockForRead(int timeout)
{
@@ -263,7 +263,7 @@ bool QReadWriteLock::tryLockForRead(int timeout)
Locks the lock for writing. This function will block the current
thread if another thread has locked for reading or writing.
- \sa unlock() lockForRead() tryLockForWrite()
+ \sa unlock(), lockForRead(), tryLockForWrite()
*/
void QReadWriteLock::lockForWrite()
{
@@ -303,7 +303,7 @@ void QReadWriteLock::lockForWrite()
If the lock was obtained, the lock must be unlocked with unlock()
before another thread can successfully lock it.
- \sa unlock() lockForWrite()
+ \sa unlock(), lockForWrite()
*/
bool QReadWriteLock::tryLockForWrite()
{
@@ -347,7 +347,7 @@ bool QReadWriteLock::tryLockForWrite()
If the lock was obtained, the lock must be unlocked with unlock()
before another thread can successfully lock it.
- \sa unlock() lockForWrite()
+ \sa unlock(), lockForWrite()
*/
bool QReadWriteLock::tryLockForWrite(int timeout)
{
@@ -389,7 +389,7 @@ bool QReadWriteLock::tryLockForWrite(int timeout)
Attempting to unlock a lock that is not locked is an error, and will result
in program termination.
- \sa lockForRead() lockForWrite() tryLockForRead() tryLockForWrite()
+ \sa lockForRead(), lockForWrite(), tryLockForRead(), tryLockForWrite()
*/
void QReadWriteLock::unlock()
{
@@ -443,11 +443,11 @@ void QReadWriteLock::unlock()
Here's an example that uses QReadLocker to lock and unlock a
read-write lock for reading:
- \snippet doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp 1
+ \snippet code/src_corelib_thread_qreadwritelock.cpp 1
It is equivalent to the following code:
- \snippet doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp 2
+ \snippet code/src_corelib_thread_qreadwritelock.cpp 2
The QMutexLocker documentation shows examples where the use of a
locker object greatly simplifies programming.
@@ -515,11 +515,11 @@ void QReadWriteLock::unlock()
Here's an example that uses QWriteLocker to lock and unlock a
read-write lock for writing:
- \snippet doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp 3
+ \snippet code/src_corelib_thread_qreadwritelock.cpp 3
It is equivalent to the following code:
- \snippet doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp 4
+ \snippet code/src_corelib_thread_qreadwritelock.cpp 4
The QMutexLocker documentation shows examples where the use of a
locker object greatly simplifies programming.
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp
index 08952eeaa3..e5b460b725 100644
--- a/src/corelib/thread/qsemaphore.cpp
+++ b/src/corelib/thread/qsemaphore.cpp
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp 0
+ \snippet code/src_corelib_thread_qsemaphore.cpp 0
A typical application of semaphores is for controlling access to
a circular buffer shared by a producer thread and a consumer
@@ -151,7 +151,7 @@ void QSemaphore::acquire(int n)
This function can be used to "create" resources as well. For
example:
- \snippet doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp 1
+ \snippet code/src_corelib_thread_qsemaphore.cpp 1
\sa acquire(), available()
*/
@@ -182,7 +182,7 @@ int QSemaphore::available() const
Example:
- \snippet doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp 2
+ \snippet code/src_corelib_thread_qsemaphore.cpp 2
\sa acquire()
*/
@@ -208,7 +208,7 @@ bool QSemaphore::tryAcquire(int n)
Example:
- \snippet doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp 3
+ \snippet code/src_corelib_thread_qsemaphore.cpp 3
\sa acquire()
*/
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index ea6760a1b9..f93f383d3c 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -184,7 +184,7 @@ QThreadPrivate::~QThreadPrivate()
below). To create your own threads, subclass QThread and
reimplement run(). For example:
- \snippet doc/src/snippets/code/src_corelib_thread_qthread.cpp 0
+ \snippet code/src_corelib_thread_qthread.cpp 0
This will create a QTcpSocket in the thread and then execute the
thread's event loop. Use the start() method to begin execution.
@@ -493,7 +493,7 @@ int QThread::exec()
is not running then the next call to QThread::exec() will also return
immediately.
- \sa quit() QEventLoop
+ \sa quit(), QEventLoop
*/
void QThread::exit(int returnCode)
{
@@ -515,7 +515,7 @@ void QThread::exit(int returnCode)
This function does nothing if the thread does not have an event
loop.
- \sa exit() QEventLoop
+ \sa exit(), QEventLoop
*/
void QThread::quit()
{ exit(); }
@@ -529,7 +529,7 @@ void QThread::quit()
work. Returning from this method will end the execution of the
thread.
- \sa start() wait()
+ \sa start(), wait()
*/
void QThread::run()
{
@@ -553,7 +553,7 @@ void QThread::run()
(such as on Linux, see http://linux.die.net/man/2/sched_setscheduler
for more details).
- \sa Priority priority() start()
+ \sa Priority, priority(), start()
*/
/*!
@@ -562,7 +562,7 @@ void QThread::run()
Returns the priority for a running thread. If the thread is not
running, this function returns \c InheritPriority.
- \sa Priority setPriority() start()
+ \sa Priority, setPriority(), start()
*/
QThread::Priority QThread::priority() const
{
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 21ed8131df..a47115cfac 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -44,11 +44,15 @@
#include "qplatformdefs.h"
#include <private/qcoreapplication_p.h>
-#if !defined(QT_NO_GLIB)
-# include "../kernel/qeventdispatcher_glib_p.h"
-#endif
-#include <private/qeventdispatcher_unix_p.h>
+#if defined(Q_OS_BLACKBERRY)
+# include <private/qeventdispatcher_blackberry_p.h>
+#else
+# if !defined(QT_NO_GLIB)
+# include "../kernel/qeventdispatcher_glib_p.h"
+# endif
+# include <private/qeventdispatcher_unix_p.h>
+#endif
#include "qthreadstorage.h"
@@ -79,9 +83,9 @@
# define old_qDebug qDebug
# undef qDebug
# endif
-#ifndef QT_NO_CORESERVICES
+#ifndef Q_OS_IOS
# include <CoreServices/CoreServices.h>
-#endif //QT_NO_CORESERVICES
+#endif //Q_OS_IOS
# ifdef old_qDebug
# undef qDebug
@@ -248,6 +252,9 @@ typedef void*(*QtThreadCallback)(void*);
void QThreadPrivate::createEventDispatcher(QThreadData *data)
{
+#if defined(Q_OS_BLACKBERRY)
+ data->eventDispatcher = new QEventDispatcherBlackberry;
+#else
#if !defined(QT_NO_GLIB)
if (qgetenv("QT_NO_GLIB").isEmpty()
&& qgetenv("QT_NO_THREADED_GLIB").isEmpty()
@@ -256,6 +263,8 @@ void QThreadPrivate::createEventDispatcher(QThreadData *data)
else
#endif
data->eventDispatcher = new QEventDispatcherUNIX;
+#endif
+
data->eventDispatcher->startingUp();
}
@@ -288,7 +297,7 @@ void *QThreadPrivate::start(void *arg)
else
createEventDispatcher(data);
-#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC))
+#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX))
// sets the name of the current thread.
QByteArray objectName = thr->objectName().toLocal8Bit();
@@ -299,6 +308,8 @@ void *QThreadPrivate::start(void *arg)
prctl(PR_SET_NAME, (unsigned long)objectName.constData(), 0, 0, 0);
#elif defined(Q_OS_MAC)
pthread_setname_np(objectName.constData());
+#elif defined(Q_OS_QNX)
+ pthread_setname_np(thr->d_func()->thread_id, objectName.constData());
#endif
#endif
@@ -371,7 +382,7 @@ int QThread::idealThreadCount()
{
int cores = -1;
-#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
// Mac OS X
cores = MPProcessorsScheduled();
#elif defined(Q_OS_HPUX)
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 1cde07e330..433c561f1f 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -182,7 +182,7 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
}
}
-/*! \internal
+/*
This function loops and waits for native adopted threads to finish.
When this happens it derefs the QThreadData for the adopted thread
to make sure it gets cleaned up properly.
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index b7021817c5..c913146122 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -47,15 +47,6 @@
QT_BEGIN_NAMESPACE
-inline bool operator<(int priority, const QPair<QRunnable *, int> &p)
-{
- return p.second < priority;
-}
-inline bool operator<(const QPair<QRunnable *, int> &p, int priority)
-{
- return priority < p.second;
-}
-
Q_GLOBAL_STATIC(QThreadPool, theInstance)
/*
@@ -209,15 +200,22 @@ bool QThreadPoolPrivate::tryStart(QRunnable *task)
return true;
}
+inline bool operator<(int priority, const QPair<QRunnable *, int> &p)
+{ return p.second < priority; }
+inline bool operator<(const QPair<QRunnable *, int> &p, int priority)
+{ return priority < p.second; }
+
void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority)
{
if (runnable->autoDelete())
++runnable->ref;
// put it on the queue
- QList<QPair<QRunnable *, int> >::iterator at =
- qUpperBound(queue.begin(), queue.end(), priority);
- queue.insert(at, qMakePair(runnable, priority));
+ QList<QPair<QRunnable *, int> >::const_iterator begin = queue.constBegin();
+ QList<QPair<QRunnable *, int> >::const_iterator it = queue.constEnd();
+ if (it != begin && priority < (*(it - 1)).second)
+ it = qUpperBound(begin, --it, priority);
+ queue.insert(it - begin, qMakePair(runnable, priority));
runnableReady.wakeOne();
}
@@ -362,7 +360,7 @@ void QThreadPoolPrivate::stealRunnable(QRunnable *runnable)
the run() virtual function. Then create an object of that class and pass
it to QThreadPool::start().
- \snippet doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp 0
+ \snippet code/src_corelib_concurrent_qthreadpool.cpp 0
QThreadPool deletes the QRunnable automatically by default. Use
QRunnable::setAutoDelete() to change the auto-deletion flag.
@@ -412,8 +410,7 @@ QThreadPool::QThreadPool(QObject *parent)
*/
QThreadPool::~QThreadPool()
{
- d_func()->waitForDone();
- d_func()->reset();
+ waitForDone();
}
/*!
@@ -595,22 +592,10 @@ void QThreadPool::releaseThread()
}
/*!
- Waits for each thread to exit and removes all threads from the thread pool.
-*/
-void QThreadPool::waitForDone()
-{
- Q_D(QThreadPool);
- d->waitForDone();
- d->reset();
-}
-
-/*!
- \overload waitForDone()
- \since 4.8
-
Waits up to \a msecs milliseconds for all threads to exit and removes all
threads from the thread pool. Returns true if all threads were removed;
- otherwise it returns false.
+ otherwise it returns false. If \a msecs is -1 (the default), the timeout
+ is ignored (waits for the last thread to exit).
*/
bool QThreadPool::waitForDone(int msecs)
{
diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h
index 9fc023c56d..dd931713f7 100644
--- a/src/corelib/thread/qthreadpool.h
+++ b/src/corelib/thread/qthreadpool.h
@@ -83,8 +83,7 @@ public:
void reserveThread();
void releaseThread();
- void waitForDone();
- bool waitForDone(int msecs);
+ bool waitForDone(int msecs = -1);
};
QT_END_NAMESPACE
diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h
index 910e0b0714..760732993d 100644
--- a/src/corelib/thread/qthreadpool_p.h
+++ b/src/corelib/thread/qthreadpool_p.h
@@ -82,7 +82,7 @@ public:
void startThread(QRunnable *runnable = 0);
void reset();
- bool waitForDone(int msecs = -1);
+ bool waitForDone(int msecs);
void stealRunnable(QRunnable *);
mutable QMutex mutex;
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp
index 68db8fe261..caa2ac907f 100644
--- a/src/corelib/thread/qthreadstorage.cpp
+++ b/src/corelib/thread/qthreadstorage.cpp
@@ -238,9 +238,9 @@ void QThreadStorageData::finish(void **p)
removeFromCache() functions. The cache is automatically
deleted when the calling thread exits.
- \snippet doc/src/snippets/threads/threads.cpp 7
- \snippet doc/src/snippets/threads/threads.cpp 8
- \snippet doc/src/snippets/threads/threads.cpp 9
+ \snippet threads/threads.cpp 7
+ \snippet threads/threads.cpp 8
+ \snippet threads/threads.cpp 9
\section1 Caveats
diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc
index 81c095f394..58679c4543 100644
--- a/src/corelib/thread/qwaitcondition.qdoc
+++ b/src/corelib/thread/qwaitcondition.qdoc
@@ -45,7 +45,7 @@
split into a thread, each of which would have a
\l{QThread::run()}{run()} body like this:
- \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 0
+ \snippet code/src_corelib_thread_qwaitcondition_unix.cpp 0
Here, the \c keyPressed variable is a global variable of type
QWaitCondition.
@@ -53,7 +53,7 @@
A fourth thread would read key presses and wake the other three
threads up every time it receives one, like this:
- \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 1
+ \snippet code/src_corelib_thread_qwaitcondition_unix.cpp 1
The order in which the three threads are woken up is undefined.
Also, if some of the threads are still in \c do_something() when
@@ -63,11 +63,11 @@
counter and a QMutex to guard it. For example, here's the new
code for the worker threads:
- \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 2
+ \snippet code/src_corelib_thread_qwaitcondition_unix.cpp 2
Here's the code for the fourth thread:
- \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 3
+ \snippet code/src_corelib_thread_qwaitcondition_unix.cpp 3
The mutex is necessary because the results of two threads
attempting to change the value of the same variable
diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc
index 5a4a278ad0..28fd9881d6 100644
--- a/src/corelib/tools/qalgorithms.qdoc
+++ b/src/corelib/tools/qalgorithms.qdoc
@@ -60,14 +60,14 @@
a particular value. If you need that functionality, you can use
qFill():
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 0
+ \snippet code/doc_src_qalgorithms.cpp 0
qFill() takes a begin iterator, an end iterator, and a value.
In the example above, we pass \c list.begin() and \c list.end()
as the begin and end iterators, but this doesn't have to be
the case:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 1
+ \snippet code/doc_src_qalgorithms.cpp 1
Different algorithms can have different requirements for the
iterators they accept. For example, qFill() accepts two
@@ -98,13 +98,13 @@
name_table array and return the corresponding Unicode value from
the \c value_table if the entity is recognized:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 2
+ \snippet code/doc_src_qalgorithms.cpp 2
This kind of code is for advanced users only; for most
applications, a QMap- or QHash-based approach would work just as
well:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 3
+ \snippet code/doc_src_qalgorithms.cpp 3
\section1 Types of Iterators
@@ -185,7 +185,7 @@
position \a begin2 + 1; and so on.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 4
+ \snippet code/doc_src_qalgorithms.cpp 4
\sa qCopyBackward(), {input iterators}, {output iterators}
*/
@@ -201,7 +201,7 @@
at position \a end2 - 2; and so on.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 5
+ \snippet code/doc_src_qalgorithms.cpp 5
\sa qCopy(), {bidirectional iterators}
*/
@@ -214,7 +214,7 @@
items compare equal; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 6
+ \snippet code/doc_src_qalgorithms.cpp 6
This function requires the item type (in the example above,
QString) to implement \c operator==().
@@ -228,7 +228,7 @@
Fills the range [\a begin, \a end) with \a value.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 7
+ \snippet code/doc_src_qalgorithms.cpp 7
\sa qCopy(), {forward iterators}
*/
@@ -249,7 +249,7 @@
value isn't found.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 8
+ \snippet code/doc_src_qalgorithms.cpp 8
This function requires the item type (in the example above,
QString) to implement \c operator==().
@@ -278,7 +278,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 9
+ \snippet code/doc_src_qalgorithms.cpp 9
This function requires the item type (in the example above,
\c int) to implement \c operator==().
@@ -302,7 +302,7 @@ of \a value in the variable passed as a reference in argument \a n.
Exchanges the values of variables \a var1 and \a var2.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 10
+ \snippet code/doc_src_qalgorithms.cpp 10
*/
/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end)
@@ -312,7 +312,7 @@ of \a value in the variable passed as a reference in argument \a n.
using the quicksort algorithm.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 11
+ \snippet code/doc_src_qalgorithms.cpp 11
The sort algorithm is efficient on large data sets. It operates
in \l {linear-logarithmic time}, O(\e{n} log \e{n}).
@@ -338,13 +338,13 @@ of \a value in the variable passed as a reference in argument \a n.
For example, here's how to sort the strings in a QStringList
in case-insensitive alphabetical order:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 12
+ \snippet code/doc_src_qalgorithms.cpp 12
To sort values in reverse order, pass
\l{qGreater()}{qGreater<T>()} as the \a lessThan parameter. For
example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 13
+ \snippet code/doc_src_qalgorithms.cpp 13
If neither of the two items is "less than" the other, the items are
taken to be equal. It is then undefined which one of the two
@@ -356,7 +356,7 @@ of \a value in the variable passed as a reference in argument \a n.
following code shows how to sort a list of strings case
insensitively using QMap:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 14
+ \snippet code/doc_src_qalgorithms.cpp 14
\sa QMap
*/
@@ -382,7 +382,7 @@ of \a value in the variable passed as a reference in argument \a n.
property is often useful when sorting user-visible data.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 15
+ \snippet code/doc_src_qalgorithms.cpp 15
The sort algorithm is efficient on large data sets. It operates
in \l {linear-logarithmic time}, O(\e{n} log \e{n}).
@@ -405,7 +405,7 @@ of \a value in the variable passed as a reference in argument \a n.
For example, here's how to sort the strings in a QStringList
in case-insensitive alphabetical order:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 16
+ \snippet code/doc_src_qalgorithms.cpp 16
Note that earlier versions of Qt allowed using a lessThan function that took its
arguments by non-const reference. From 4.3 and on this is no longer possible,
@@ -415,7 +415,7 @@ of \a value in the variable passed as a reference in argument \a n.
\l{qGreater()}{qGreater<T>()} as the \a lessThan parameter. For
example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 17
+ \snippet code/doc_src_qalgorithms.cpp 17
If neither of the two items is "less than" the other, the items are
taken to be equal. The item that appeared before the other in the
@@ -444,7 +444,7 @@ of \a value in the variable passed as a reference in argument \a n.
ascending order; see qSort().
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 18
+ \snippet code/doc_src_qalgorithms.cpp 18
This function requires the item type (in the example above,
\c{int}) to implement \c operator<().
@@ -452,7 +452,7 @@ of \a value in the variable passed as a reference in argument \a n.
qLowerBound() can be used in conjunction with qUpperBound() to
iterate over all occurrences of the same value:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 19
+ \snippet code/doc_src_qalgorithms.cpp 19
\sa qUpperBound(), qBinaryFind()
*/
@@ -494,7 +494,7 @@ of \a value in the variable passed as a reference in argument \a n.
ascending order; see qSort().
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 20
+ \snippet code/doc_src_qalgorithms.cpp 20
This function requires the item type (in the example above,
\c{int}) to implement \c operator<().
@@ -502,7 +502,7 @@ of \a value in the variable passed as a reference in argument \a n.
qUpperBound() can be used in conjunction with qLowerBound() to
iterate over all occurrences of the same value:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 21
+ \snippet code/doc_src_qalgorithms.cpp 21
\sa qLowerBound(), qBinaryFind()
*/
@@ -545,7 +545,7 @@ of \a value in the variable passed as a reference in argument \a n.
finer control.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 22
+ \snippet code/doc_src_qalgorithms.cpp 22
This function requires the item type (in the example above,
QString) to implement \c operator<().
@@ -587,7 +587,7 @@ of \a value in the variable passed as a reference in argument \a n.
example, \c{QWidget *}).
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 23
+ \snippet code/doc_src_qalgorithms.cpp 23
Notice that qDeleteAll() doesn't remove the items from the
container; it merely calls \c delete on them. In the example
@@ -618,7 +618,7 @@ of \a value in the variable passed as a reference in argument \a n.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 24
+ \snippet code/doc_src_qalgorithms.cpp 24
\sa {qGreater()}{qGreater<T>()}
*/
@@ -631,7 +631,7 @@ of \a value in the variable passed as a reference in argument \a n.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 25
+ \snippet code/doc_src_qalgorithms.cpp 25
\sa {qLess()}{qLess<T>()}
*/
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp
index f1b88d5051..328d39cde9 100644
--- a/src/corelib/tools/qarraydata.cpp
+++ b/src/corelib/tools/qarraydata.cpp
@@ -82,7 +82,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
// Allocate additional space if array is growing
if (options & Grow)
- capacity = qAllocMore(objectSize * capacity, headerSize) / objectSize;
+ capacity = qAllocMore(objectSize * capacity, headerSize) / int(objectSize);
size_t allocSize = headerSize + objectSize * capacity;
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 78fbc9cf32..4d79c92cec 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -169,7 +169,7 @@ struct QTypedArrayData
result->offset = reinterpret_cast<const char *>(data)
- reinterpret_cast<const char *>(result);
- result->size = n;
+ result->size = int(n);
}
return result;
}
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp
index 4cb08a7310..0e74e15a27 100644
--- a/src/corelib/tools/qbitarray.cpp
+++ b/src/corelib/tools/qbitarray.cpp
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
The following code constructs a QBitArray containing 200 bits
initialized to false (0):
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 0
+ \snippet code/src_corelib_tools_qbitarray.cpp 0
To initialize the bits to true, either pass \c true as second
argument to the constructor, or call fill() later on.
@@ -75,13 +75,13 @@ QT_BEGIN_NAMESPACE
bit that can be used on the left side of an assignment. For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 1
+ \snippet code/src_corelib_tools_qbitarray.cpp 1
For technical reasons, it is more efficient to use testBit() and
setBit() to access bits in the array than operator[](). For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 2
+ \snippet code/src_corelib_tools_qbitarray.cpp 2
QBitArray supports \c{&} (\link operator&() AND\endlink), \c{|}
(\link operator|() OR\endlink), \c{^} (\link operator^()
@@ -90,7 +90,7 @@ QT_BEGIN_NAMESPACE
as the built-in C++ bitwise operators of the same name. For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 3
+ \snippet code/src_corelib_tools_qbitarray.cpp 3
For historical reasons, QBitArray distinguishes between a null
bit array and an empty bit array. A \e null bit array is a bit
@@ -99,7 +99,7 @@ QT_BEGIN_NAMESPACE
array is always empty, but an empty bit array isn't necessarily
null:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 4
+ \snippet code/src_corelib_tools_qbitarray.cpp 4
All functions except isNull() treat null bit arrays the same as
empty bit arrays; for example, QBitArray() compares equal to
@@ -228,7 +228,7 @@ void QBitArray::resize(int size)
Returns true if this bit array is null; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 5
+ \snippet code/src_corelib_tools_qbitarray.cpp 5
Qt makes a distinction between null bit arrays and empty bit
arrays for historical reasons. For most applications, what
@@ -245,7 +245,7 @@ void QBitArray::resize(int size)
the bit array is resized to \a size beforehand.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 6
+ \snippet code/src_corelib_tools_qbitarray.cpp 6
\sa resize()
*/
@@ -372,7 +372,7 @@ void QBitArray::fill(bool value, int begin, int end)
\a i < size()).
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 7
+ \snippet code/src_corelib_tools_qbitarray.cpp 7
The return value is of type QBitRef, a helper class for QBitArray.
When you get an object of type QBitRef, you can assign to
@@ -451,7 +451,7 @@ void QBitArray::fill(bool value, int begin, int end)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 8
+ \snippet code/src_corelib_tools_qbitarray.cpp 8
\sa operator&(), operator|=(), operator^=(), operator~()
*/
@@ -480,7 +480,7 @@ QBitArray &QBitArray::operator&=(const QBitArray &other)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 9
+ \snippet code/src_corelib_tools_qbitarray.cpp 9
\sa operator|(), operator&=(), operator^=(), operator~()
*/
@@ -506,7 +506,7 @@ QBitArray &QBitArray::operator|=(const QBitArray &other)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 10
+ \snippet code/src_corelib_tools_qbitarray.cpp 10
\sa operator^(), operator&=(), operator|=(), operator~()
*/
@@ -527,7 +527,7 @@ QBitArray &QBitArray::operator^=(const QBitArray &other)
array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 11
+ \snippet code/src_corelib_tools_qbitarray.cpp 11
\sa operator&(), operator|(), operator^()
*/
@@ -559,7 +559,7 @@ QBitArray QBitArray::operator~() const
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 12
+ \snippet code/src_corelib_tools_qbitarray.cpp 12
\sa QBitArray::operator&=(), operator|(), operator^()
*/
@@ -582,7 +582,7 @@ QBitArray operator&(const QBitArray &a1, const QBitArray &a2)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 13
+ \snippet code/src_corelib_tools_qbitarray.cpp 13
\sa QBitArray::operator|=(), operator&(), operator^()
*/
@@ -605,7 +605,7 @@ QBitArray operator|(const QBitArray &a1, const QBitArray &a2)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 14
+ \snippet code/src_corelib_tools_qbitarray.cpp 14
\sa QBitArray::operator^=(), operator&(), operator|()
*/
@@ -668,7 +668,7 @@ QBitArray operator^(const QBitArray &a1, const QBitArray &a2)
Writes bit array \a ba to stream \a out.
- \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+ \sa {Serializing Qt Data Types}{Format of the QDataStream operators}
*/
QDataStream &operator<<(QDataStream &out, const QBitArray &ba)
@@ -685,7 +685,7 @@ QDataStream &operator<<(QDataStream &out, const QBitArray &ba)
Reads a bit array into \a ba from stream \a in.
- \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+ \sa {Serializing Qt Data Types}{Format of the QDataStream operators}
*/
QDataStream &operator>>(QDataStream &in, QBitArray &ba)
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 31cf65b78d..b67d655a9d 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -131,7 +131,7 @@ char *qstrcpy(char *dst, const char *src)
if (!src)
return 0;
#if defined(_MSC_VER) && _MSC_VER >= 1400
- int len = strlen(src);
+ const int len = int(strlen(src));
// This is actually not secure!!! It will be fixed
// properly in a later release!
if (len >= 0 && strcpy_s(dst, len+1, src) == 0)
@@ -648,7 +648,7 @@ static inline char qToLower(char c)
char *} to its constructor. For example, the following code
creates a byte array of size 5 containing the data "Hello":
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 0
+ \snippet code/src_corelib_tools_qbytearray.cpp 0
Although the size() is 5, the byte array also maintains an extra
'\\0' character at the end so that if a function is used that
@@ -668,11 +668,11 @@ static inline char qToLower(char c)
arrays, operator[]() returns a reference to a byte that can be
used on the left side of an assignment. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 1
+ \snippet code/src_corelib_tools_qbytearray.cpp 1
For read-only access, an alternative syntax is to use at():
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 2
+ \snippet code/src_corelib_tools_qbytearray.cpp 2
at() can be faster than operator[](), because it never causes a
\l{deep copy} to occur.
@@ -700,7 +700,7 @@ static inline char qToLower(char c)
the byte data: append(), prepend(), insert(), replace(), and
remove(). For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 3
+ \snippet code/src_corelib_tools_qbytearray.cpp 3
The replace() and remove() functions' first two arguments are the
position from which to start erasing and the number of bytes that
@@ -728,7 +728,7 @@ static inline char qToLower(char c)
For example, here's a typical loop that finds all occurrences of a
particular substring:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 4
+ \snippet code/src_corelib_tools_qbytearray.cpp 4
If you simply want to check whether a QByteArray contains a
particular character or substring, use contains(). If you want to
@@ -752,7 +752,7 @@ static inline char qToLower(char c)
array is always empty, but an empty byte array isn't necessarily
null:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 5
+ \snippet code/src_corelib_tools_qbytearray.cpp 5
All functions except isNull() treat null byte arrays the same as
empty byte arrays. For example, data() returns a pointer to a
@@ -914,12 +914,13 @@ QByteArray &QByteArray::operator=(const char *str)
} else if (!*str) {
x = Data::allocate(0);
} else {
- int len = strlen(str);
- if (d->ref.isShared() || uint(len) + 1u > d->alloc
- || (len < d->size && uint(len) + 1u < uint(d->alloc >> 1)))
- reallocData(uint(len) + 1u, d->detachFlags());
+ const int len = int(strlen(str));
+ const uint fullLen = len + 1;
+ if (d->ref.isShared() || fullLen > d->alloc
+ || (len < d->size && fullLen < uint(d->alloc >> 1)))
+ reallocData(fullLen, d->detachFlags());
x = d;
- memcpy(x->data(), str, uint(len) + 1u); // include null terminator
+ memcpy(x->data(), str, fullLen); // include null terminator
x->size = len;
}
x->ref.ref();
@@ -949,7 +950,7 @@ QByteArray &QByteArray::operator=(const char *str)
automaticall unless the \l{deep copy} is created.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 6
+ \snippet code/src_corelib_tools_qbytearray.cpp 6
\sa isEmpty(), resize()
*/
@@ -959,7 +960,7 @@ QByteArray &QByteArray::operator=(const char *str)
Returns true if the byte array has size 0; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 7
+ \snippet code/src_corelib_tools_qbytearray.cpp 7
\sa size()
*/
@@ -1046,7 +1047,7 @@ QByteArray &QByteArray::operator=(const char *str)
'\\0' terminator.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 8
+ \snippet code/src_corelib_tools_qbytearray.cpp 8
The pointer remains valid as long as the byte array isn't
reallocated or destroyed. For read-only access, constData() is
@@ -1059,11 +1060,11 @@ QByteArray &QByteArray::operator=(const char *str)
data(), but it will corrupt the heap and cause a crash because it
does not allocate a byte for the '\\0' at the end:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 46
+ \snippet code/src_corelib_tools_qbytearray.cpp 46
This one allocates the correct amount of space:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 47
+ \snippet code/src_corelib_tools_qbytearray.cpp 47
Note: A QByteArray can store any byte values including '\\0's,
but most functions that take \c{char *} arguments assume that the
@@ -1129,7 +1130,7 @@ QByteArray &QByteArray::operator=(const char *str)
place.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 9
+ \snippet code/src_corelib_tools_qbytearray.cpp 9
The return value is of type QByteRef, a helper class for
QByteArray. When you get an object of type QByteRef, you can use
@@ -1188,7 +1189,7 @@ QByteArray &QByteArray::operator=(const char *str)
If \a pos is beyond the end of the array, nothing happens.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 10
+ \snippet code/src_corelib_tools_qbytearray.cpp 10
\sa chop(), resize(), left()
*/
@@ -1206,7 +1207,7 @@ void QByteArray::truncate(int pos)
array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 11
+ \snippet code/src_corelib_tools_qbytearray.cpp 11
\sa truncate(), resize(), left()
*/
@@ -1224,7 +1225,7 @@ void QByteArray::chop(int n)
returns a reference to this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 12
+ \snippet code/src_corelib_tools_qbytearray.cpp 12
Note: QByteArray is an \l{implicitly shared} class. Consequently,
if \e this is an empty QByteArray, then \e this will just share
@@ -1284,7 +1285,7 @@ void QByteArray::chop(int n)
Returns true if this byte array is null; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 13
+ \snippet code/src_corelib_tools_qbytearray.cpp 13
Qt makes a distinction between null byte arrays and empty byte
arrays for historical reasons. For most applications, what
@@ -1322,7 +1323,7 @@ QByteArray::QByteArray(const char *data, int size)
d = Data::sharedNull();
} else {
if (size < 0)
- size = strlen(data);
+ size = int(strlen(data));
if (!size) {
d = Data::allocate(0);
} else {
@@ -1428,7 +1429,7 @@ void QByteArray::resize(int size)
size \a size beforehand.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 14
+ \snippet code/src_corelib_tools_qbytearray.cpp 14
\sa resize()
*/
@@ -1493,7 +1494,7 @@ QByteArray QByteArray::nulTerminated() const
reference to this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 15
+ \snippet code/src_corelib_tools_qbytearray.cpp 15
This is the same as insert(0, \a ba).
@@ -1573,7 +1574,7 @@ QByteArray &QByteArray::prepend(char ch)
Appends the byte array \a ba onto the end of this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 16
+ \snippet code/src_corelib_tools_qbytearray.cpp 16
This is the same as insert(size(), \a ba).
@@ -1631,7 +1632,7 @@ QByteArray &QByteArray::append(const QByteArray &ba)
QByteArray& QByteArray::append(const char *str)
{
if (str) {
- int len = strlen(str);
+ const int len = int(strlen(str));
if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc)
reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow);
memcpy(d->data() + d->size, str, len + 1); // include null terminator
@@ -1710,7 +1711,7 @@ static inline QByteArray &qbytearray_insert(QByteArray *ba,
reference to this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 17
+ \snippet code/src_corelib_tools_qbytearray.cpp 17
\sa append(), prepend(), replace(), remove()
*/
@@ -1793,7 +1794,7 @@ QByteArray &QByteArray::insert(int i, char ch)
array is truncated at position \a pos.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 18
+ \snippet code/src_corelib_tools_qbytearray.cpp 18
\sa insert(), replace()
*/
@@ -1817,7 +1818,7 @@ QByteArray &QByteArray::remove(int pos, int len)
array \a after, and returns a reference to this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 19
+ \snippet code/src_corelib_tools_qbytearray.cpp 19
\sa insert(), remove()
*/
@@ -1855,7 +1856,7 @@ QByteArray &QByteArray::replace(int pos, int len, const char *after)
\overload
Replaces \a len bytes from index position \a pos with \a alen bytes
- from the string \a after. \a after is allowed to have '\0' characters.
+ from the string \a after. \a after is allowed to have '\\0' characters.
\since 4.7
*/
@@ -1881,7 +1882,7 @@ QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen)
byte array \a after.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 20
+ \snippet code/src_corelib_tools_qbytearray.cpp 20
*/
QByteArray &QByteArray::replace(const QByteArray &before, const QByteArray &after)
@@ -2214,7 +2215,7 @@ QByteArray QByteArray::repeated(int times) const
position \a from. Returns -1 if \a ba could not be found.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 21
+ \snippet code/src_corelib_tools_qbytearray.cpp 21
\sa lastIndexOf(), contains(), count()
*/
@@ -2284,7 +2285,7 @@ int QByteArray::indexOf(const char *c, int from) const
position \a from. Returns -1 if \a ch could not be found.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 22
+ \snippet code/src_corelib_tools_qbytearray.cpp 22
\sa lastIndexOf(), contains()
*/
@@ -2346,7 +2347,7 @@ static int lastIndexOfHelper(const char *haystack, int l, const char *needle, in
starts at the last byte. Returns -1 if \a ba could not be found.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 23
+ \snippet code/src_corelib_tools_qbytearray.cpp 23
\sa indexOf(), contains(), count()
*/
@@ -2406,7 +2407,7 @@ int QByteArray::lastIndexOf(const char *str, int from) const
last (size() - 1) byte. Returns -1 if \a ch could not be found.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 24
+ \snippet code/src_corelib_tools_qbytearray.cpp 24
\sa indexOf(), contains()
*/
@@ -2493,7 +2494,7 @@ int QByteArray::count(char ch) const
otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 25
+ \snippet code/src_corelib_tools_qbytearray.cpp 25
\sa endsWith(), left()
*/
@@ -2515,7 +2516,7 @@ bool QByteArray::startsWith(const char *str) const
{
if (!str || !*str)
return true;
- int len = strlen(str);
+ const int len = int(strlen(str));
if (d->size < len)
return false;
return qstrncmp(d->data(), str, len) == 0;
@@ -2538,7 +2539,7 @@ bool QByteArray::startsWith(char ch) const
otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 26
+ \snippet code/src_corelib_tools_qbytearray.cpp 26
\sa startsWith(), right()
*/
@@ -2560,7 +2561,7 @@ bool QByteArray::endsWith(const char *str) const
{
if (!str || !*str)
return true;
- int len = strlen(str);
+ const int len = int(strlen(str));
if (d->size < len)
return false;
return qstrncmp(d->data() + d->size - len, str, len) == 0;
@@ -2586,7 +2587,7 @@ bool QByteArray::endsWith(char ch) const
size().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 27
+ \snippet code/src_corelib_tools_qbytearray.cpp 27
\sa right(), mid(), startsWith(), truncate()
*/
@@ -2608,7 +2609,7 @@ QByteArray QByteArray::left(int len) const
size().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 28
+ \snippet code/src_corelib_tools_qbytearray.cpp 28
\sa endsWith(), left(), mid()
*/
@@ -2631,7 +2632,7 @@ QByteArray QByteArray::right(int len) const
pos until the end of the byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 29
+ \snippet code/src_corelib_tools_qbytearray.cpp 29
\sa left(), right()
*/
@@ -2658,7 +2659,7 @@ QByteArray QByteArray::mid(int pos, int len) const
interpreted as a Latin-1 encoded string.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 30
+ \snippet code/src_corelib_tools_qbytearray.cpp 30
\sa toUpper(), {8-bit Character Comparisons}
*/
@@ -2680,7 +2681,7 @@ QByteArray QByteArray::toLower() const
interpreted as a Latin-1 encoded string.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 31
+ \snippet code/src_corelib_tools_qbytearray.cpp 31
\sa toLower(), {8-bit Character Comparisons}
*/
@@ -3090,7 +3091,7 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba)
characters '\\t', '\\n', '\\v', '\\f', '\\r', and ' '.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 32
+ \snippet code/src_corelib_tools_qbytearray.cpp 32
\sa trimmed()
*/
@@ -3128,7 +3129,7 @@ QByteArray QByteArray::simplified() const
characters '\\t', '\\n', '\\v', '\\f', '\\r', and ' '.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 33
+ \snippet code/src_corelib_tools_qbytearray.cpp 33
Unlike simplified(), trimmed() leaves internal whitespace alone.
@@ -3170,7 +3171,7 @@ QByteArray QByteArray::trimmed() const
after position \a width are removed, and the copy is returned.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 34
+ \snippet code/src_corelib_tools_qbytearray.cpp 34
\sa rightJustified()
*/
@@ -3207,7 +3208,7 @@ QByteArray QByteArray::leftJustified(int width, char fill, bool truncate) const
position \a width.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 35
+ \snippet code/src_corelib_tools_qbytearray.cpp 35
\sa leftJustified()
*/
@@ -3314,7 +3315,7 @@ qulonglong QByteArray::toULongLong(bool *ok, int base) const
If \a ok is not 0: if a conversion error occurs, *\a{ok} is set to
false; otherwise *\a{ok} is set to true.
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 36
+ \snippet code/src_corelib_tools_qbytearray.cpp 36
\note The conversion of the number is performed in the default C locale,
irrespective of the user's locale.
@@ -3380,7 +3381,7 @@ uint QByteArray::toUInt(bool *ok, int base) const
If \a ok is not 0: if a conversion error occurs, *\a{ok} is set to
false; otherwise *\a{ok} is set to true.
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 37
+ \snippet code/src_corelib_tools_qbytearray.cpp 37
\note The conversion of the number is performed in the default C locale,
irrespective of the user's locale.
@@ -3501,7 +3502,7 @@ ushort QByteArray::toUShort(bool *ok, int base) const
If \a ok is not 0: if a conversion error occurs, *\a{ok} is set to
false; otherwise *\a{ok} is set to true.
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 38
+ \snippet code/src_corelib_tools_qbytearray.cpp 38
\note The conversion of the number is performed in the default C locale,
irrespective of the user's locale.
@@ -3536,7 +3537,7 @@ float QByteArray::toFloat(bool *ok) const
/*!
Returns a copy of the byte array, encoded as Base64.
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 39
+ \snippet code/src_corelib_tools_qbytearray.cpp 39
The algorithm used to encode Base64-encoded data is defined in \l{RFC 2045}.
@@ -3588,7 +3589,7 @@ QByteArray QByteArray::toBase64() const
be any value between 2 and 36.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 40
+ \snippet code/src_corelib_tools_qbytearray.cpp 40
\note The format of the number is not localized; the default C locale
is used irrespective of the user's locale.
@@ -3632,7 +3633,7 @@ QByteArray &QByteArray::setNum(qlonglong n, int base)
}
#endif
QLocale locale(QLocale::C);
- *this = locale.d()->longLongToString(n, -1, base).toLatin1();
+ *this = locale.d->longLongToString(n, -1, base).toLatin1();
return *this;
}
@@ -3651,7 +3652,7 @@ QByteArray &QByteArray::setNum(qulonglong n, int base)
}
#endif
QLocale locale(QLocale::C);
- *this = locale.d()->unsLongLongToString(n, -1, base).toLatin1();
+ *this = locale.d->unsLongLongToString(n, -1, base).toLatin1();
return *this;
}
@@ -3710,7 +3711,7 @@ QByteArray &QByteArray::setNum(double n, char f, int prec)
}
QLocale locale(QLocale::C);
- *this = locale.d()->doubleToString(n, prec, form, -1, flags).toLatin1();
+ *this = locale.d->doubleToString(n, prec, form, -1, flags).toLatin1();
return *this;
}
@@ -3734,7 +3735,7 @@ QByteArray &QByteArray::setNum(double n, char f, int prec)
any value between 2 and 36.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 41
+ \snippet code/src_corelib_tools_qbytearray.cpp 41
\note The format of the number is not localized; the default C locale
is used irrespective of the user's locale.
@@ -3806,7 +3807,7 @@ QByteArray QByteArray::number(qulonglong n, int base)
decimal point. With 'g' and 'G', \a prec is the maximum number of
significant digits (trailing zeroes are omitted).
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 42
+ \snippet code/src_corelib_tools_qbytearray.cpp 42
\note The format of the number is not localized; the default C locale
is used irrespective of the user's locale.
@@ -3843,7 +3844,7 @@ QByteArray QByteArray::number(double n, char f, int prec)
Here is an example of how to read data using a QDataStream on raw
data in memory without copying the raw data into a QByteArray:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 43
+ \snippet code/src_corelib_tools_qbytearray.cpp 43
\warning A byte array created with fromRawData() is \e not
null-terminated, unless the raw data contains a 0 character at
@@ -3908,7 +3909,7 @@ QByteArray &QByteArray::setRawData(const char *data, uint size)
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 44
+ \snippet code/src_corelib_tools_qbytearray.cpp 44
The algorithm used to decode Base64-encoded data is defined in \l{RFC 2045}.
@@ -3960,7 +3961,7 @@ QByteArray QByteArray::fromBase64(const QByteArray &base64)
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 45
+ \snippet code/src_corelib_tools_qbytearray.cpp 45
\sa toHex()
*/
diff --git a/src/corelib/tools/qcache.qdoc b/src/corelib/tools/qcache.qdoc
index 80d47ff703..86eec28e4b 100644
--- a/src/corelib/tools/qcache.qdoc
+++ b/src/corelib/tools/qcache.qdoc
@@ -39,11 +39,11 @@
definition of a cache that stores objects of type Employee
associated with an integer key:
- \snippet doc/src/snippets/code/doc_src_qcache.cpp 0
+ \snippet code/doc_src_qcache.cpp 0
Here's how to insert an object in the cache:
- \snippet doc/src/snippets/code/doc_src_qcache.cpp 1
+ \snippet code/doc_src_qcache.cpp 1
The advantage of using QCache over some other key-based data
structure (such as QMap or QHash) is that QCache automatically
@@ -59,7 +59,7 @@
By default, QCache's maxCost() is 100. You can specify a
different value in the QCache constructor:
- \snippet doc/src/snippets/code/doc_src_qcache.cpp 2
+ \snippet code/doc_src_qcache.cpp 2
Each time you call insert(), you can specify a cost as third
argument (after the key and a pointer to the object to insert).
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index ef229fc0fc..b83170cb46 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -108,8 +108,8 @@ QT_BEGIN_NAMESPACE
The classification functions include functions like those in the
standard C++ header \<cctype\> (formerly \<ctype.h\>), but
- operating on the full range of Unicode characters. They all
- return true if the character is a certain type of character;
+ operating on the full range of Unicode characters, not just for the ASCII
+ range. They all return true if the character is a certain type of character;
otherwise they return false. These classification functions are
isNull() (returns true if the character is '\\0'), isPrint()
(true if the character is any sort of printable character,
@@ -118,7 +118,9 @@ QT_BEGIN_NAMESPACE
sort of numeric character, not just 0-9), isLetterOrNumber(), and
isDigit() (decimal digits). All of these are wrappers around
category() which return the Unicode-defined category of each
- character.
+ character. Some of these also calculate the derived properties
+ (i.e. isSpace() returns true if the character is of category
+ Separator_* or an exceptional code point from Other_Control category).
QChar also provides direction(), which indicates the "natural"
writing direction of this character. The joining() function
@@ -153,6 +155,9 @@ QT_BEGIN_NAMESPACE
to construct a QChar from an 8-bit \c char, and you will need to
call toAscii() or toLatin1() to get the 8-bit value back.
+ For more information see
+ \l{http://www.unicode.org/ucd/}{"About the Unicode Character Database"}.
+
\sa Unicode, QString, QLatin1Char
*/
@@ -473,7 +478,7 @@ QT_BEGIN_NAMESPACE
/*!
Returns true if the character is a printable character; otherwise
- returns false. This is any character not of category Cc or Cn.
+ returns false. This is any character not of category Other_*.
Note that this gives no indication of whether the character is
available in a particular font.
@@ -481,6 +486,9 @@ QT_BEGIN_NAMESPACE
bool QChar::isPrint() const
{
const int test = FLAG(Other_Control) |
+ FLAG(Other_Format) |
+ FLAG(Other_Surrogate) |
+ FLAG(Other_PrivateUse) |
FLAG(Other_NotAssigned);
return !(FLAG(qGetProp(ucs)->category) & test);
}
@@ -699,12 +707,10 @@ bool QChar::isSymbol() const
*/
/*!
+ \fn int QChar::digitValue() const
+
Returns the numeric value of the digit, or -1 if the character is not a digit.
*/
-int QChar::digitValue() const
-{
- return qGetProp(ucs)->digitValue;
-}
/*!
\overload
@@ -729,12 +735,10 @@ int QChar::digitValue(uint ucs4)
}
/*!
+ \fn QChar::Category QChar::category() const
+
Returns the character's category.
*/
-QChar::Category QChar::category() const
-{
- return (QChar::Category) qGetProp(ucs)->category;
-}
/*!
\overload
@@ -758,12 +762,10 @@ QChar::Category QChar::category(ushort ucs2)
/*!
+ \fn QChar::Direction QChar::direction() const
+
Returns the character's direction.
*/
-QChar::Direction QChar::direction() const
-{
- return (QChar::Direction) qGetProp(ucs)->direction;
-}
/*!
\overload
@@ -786,13 +788,11 @@ QChar::Direction QChar::direction(ushort ucs2)
}
/*!
+ \fn QChar::Joining QChar::joining() const
+
Returns information about the joining properties of the character
(needed for certain languages such as Arabic).
*/
-QChar::Joining QChar::joining() const
-{
- return (QChar::Joining) qGetProp(ucs)->joining;
-}
/*!
\overload
@@ -857,15 +857,13 @@ bool QChar::hasMirrored() const
*/
/*!
+ \fn QChar QChar::mirroredChar() const
+
Returns the mirrored character if this character is a mirrored
character; otherwise returns the character itself.
\sa hasMirrored()
*/
-QChar QChar::mirroredChar() const
-{
- return ucs + qGetProp(ucs)->mirrorDiff;
-}
/*!
\overload
@@ -894,27 +892,26 @@ ushort QChar::mirroredChar(ushort ucs2)
}
+// constants for Hangul (de)composition, see UAX #15
enum {
Hangul_SBase = 0xac00,
Hangul_LBase = 0x1100,
Hangul_VBase = 0x1161,
Hangul_TBase = 0x11a7,
- Hangul_SCount = 11172,
Hangul_LCount = 19,
Hangul_VCount = 21,
Hangul_TCount = 28,
- Hangul_NCount = 21*28
+ Hangul_NCount = Hangul_VCount * Hangul_TCount,
+ Hangul_SCount = Hangul_LCount * Hangul_NCount
};
// buffer has to have a length of 3. It's needed for Hangul decomposition
static const unsigned short * QT_FASTCALL decompositionHelper
(uint ucs4, int *length, int *tag, unsigned short *buffer)
{
- *length = 0;
- if (ucs4 > UNICODE_LAST_CODEPOINT)
- return 0;
if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) {
- int SIndex = ucs4 - Hangul_SBase;
+ // compute Hangul syllable decomposition as per UAX #15
+ const uint SIndex = ucs4 - Hangul_SBase;
buffer[0] = Hangul_LBase + SIndex / Hangul_NCount; // L
buffer[1] = Hangul_VBase + (SIndex % Hangul_NCount) / Hangul_TCount; // V
buffer[2] = Hangul_TBase + SIndex % Hangul_TCount; // T
@@ -924,8 +921,12 @@ static const unsigned short * QT_FASTCALL decompositionHelper
}
const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
- if (index == 0xffff)
+ if (index == 0xffff) {
+ *length = 0;
+ *tag = QChar::NoDecomposition;
return 0;
+ }
+
const unsigned short *decomposition = uc_decomposition_map+index;
*tag = (*decomposition) & 0xff;
*length = (*decomposition) >> 8;
@@ -952,7 +953,7 @@ QString QChar::decomposition(uint ucs4)
int length;
int tag;
const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer);
- return QString::fromUtf16(d, length);
+ return QString(reinterpret_cast<const QChar *>(d), length);
}
/*!
@@ -971,8 +972,8 @@ QChar::Decomposition QChar::decompositionTag() const
*/
QChar::Decomposition QChar::decompositionTag(uint ucs4)
{
- if (ucs4 > UNICODE_LAST_CODEPOINT)
- return QChar::NoDecomposition;
+ if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount)
+ return QChar::Canonical;
const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
if (index == 0xffff)
return QChar::NoDecomposition;
@@ -980,6 +981,8 @@ QChar::Decomposition QChar::decompositionTag(uint ucs4)
}
/*!
+ \fn unsigned char QChar::combiningClass() const
+
Returns the combining class for the character as defined in the
Unicode standard. This is mainly useful as a positioning hint for
marks attached to a base character.
@@ -987,10 +990,6 @@ QChar::Decomposition QChar::decompositionTag(uint ucs4)
The Qt text rendering engine uses this information to correctly
position non-spacing marks around a base character.
*/
-unsigned char QChar::combiningClass() const
-{
- return (unsigned char) qGetProp(ucs)->combiningClass;
-}
/*!
\overload
@@ -1015,12 +1014,10 @@ unsigned char QChar::combiningClass(ushort ucs2)
}
/*!
+ \fn QChar::UnicodeVersion QChar::unicodeVersion() const
+
Returns the Unicode version that introduced this character.
*/
-QChar::UnicodeVersion QChar::unicodeVersion() const
-{
- return (QChar::UnicodeVersion) qGetProp(ucs)->unicodeVersion;
-}
/*!
\overload
@@ -1052,17 +1049,61 @@ QChar::UnicodeVersion QChar::currentUnicodeVersion()
return UNICODE_DATA_VERSION;
}
+
+template <typename T>
+static inline T toLowerCase_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (p->lowerCaseSpecial) {
+ const ushort *specialCase = specialCaseMap + p->lowerCaseDiff;
+ if (*specialCase == 1)
+ return specialCase[1];
+ }
+ return uc + p->lowerCaseDiff;
+}
+
+template <typename T>
+static inline T toUpperCase_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (p->upperCaseSpecial) {
+ const ushort *specialCase = specialCaseMap + p->upperCaseDiff;
+ if (*specialCase == 1)
+ return specialCase[1];
+ }
+ return uc + p->upperCaseDiff;
+}
+
+template <typename T>
+static inline T toTitleCase_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (p->titleCaseSpecial) {
+ const ushort *specialCase = specialCaseMap + p->titleCaseDiff;
+ if (*specialCase == 1)
+ return specialCase[1];
+ }
+ return uc + p->titleCaseDiff;
+}
+
+template <typename T>
+static inline T toCaseFolded_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (p->caseFoldSpecial) {
+ const ushort *specialCase = specialCaseMap + p->caseFoldDiff;
+ if (*specialCase == 1)
+ return specialCase[1];
+ }
+ return uc + p->caseFoldDiff;
+}
+
/*!
+ \fn QChar QChar::toLower() const
+
Returns the lowercase equivalent if the character is uppercase or titlecase;
otherwise returns the character itself.
*/
-QChar QChar::toLower() const
-{
- const QUnicodeTables::Properties *p = qGetProp(ucs);
- if (!p->lowerCaseSpecial)
- return ucs + p->lowerCaseDiff;
- return ucs;
-}
/*!
\overload
@@ -1074,10 +1115,7 @@ uint QChar::toLower(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- const QUnicodeTables::Properties *p = qGetProp(ucs4);
- if (!p->lowerCaseSpecial)
- return ucs4 + p->lowerCaseDiff;
- return ucs4;
+ return toLowerCase_helper<uint>(ucs4);
}
/*!
@@ -1088,23 +1126,15 @@ uint QChar::toLower(uint ucs4)
*/
ushort QChar::toLower(ushort ucs2)
{
- const QUnicodeTables::Properties *p = qGetProp(ucs2);
- if (!p->lowerCaseSpecial)
- return ucs2 + p->lowerCaseDiff;
- return ucs2;
+ return toLowerCase_helper<ushort>(ucs2);
}
/*!
+ \fn QChar QChar::toUpper() const
+
Returns the uppercase equivalent if the character is lowercase or titlecase;
otherwise returns the character itself.
*/
-QChar QChar::toUpper() const
-{
- const QUnicodeTables::Properties *p = qGetProp(ucs);
- if (!p->upperCaseSpecial)
- return ucs + p->upperCaseDiff;
- return ucs;
-}
/*!
\overload
@@ -1116,10 +1146,7 @@ uint QChar::toUpper(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- const QUnicodeTables::Properties *p = qGetProp(ucs4);
- if (!p->upperCaseSpecial)
- return ucs4 + p->upperCaseDiff;
- return ucs4;
+ return toUpperCase_helper<uint>(ucs4);
}
/*!
@@ -1130,23 +1157,15 @@ uint QChar::toUpper(uint ucs4)
*/
ushort QChar::toUpper(ushort ucs2)
{
- const QUnicodeTables::Properties *p = qGetProp(ucs2);
- if (!p->upperCaseSpecial)
- return ucs2 + p->upperCaseDiff;
- return ucs2;
+ return toUpperCase_helper<ushort>(ucs2);
}
/*!
+ \fn QChar QChar::toTitleCase() const
+
Returns the title case equivalent if the character is lowercase or uppercase;
otherwise returns the character itself.
*/
-QChar QChar::toTitleCase() const
-{
- const QUnicodeTables::Properties *p = qGetProp(ucs);
- if (!p->titleCaseSpecial)
- return ucs + p->titleCaseDiff;
- return ucs;
-}
/*!
\overload
@@ -1158,10 +1177,7 @@ uint QChar::toTitleCase(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- const QUnicodeTables::Properties *p = qGetProp(ucs4);
- if (!p->titleCaseSpecial)
- return ucs4 + p->titleCaseDiff;
- return ucs4;
+ return toTitleCase_helper<uint>(ucs4);
}
/*!
@@ -1172,19 +1188,15 @@ uint QChar::toTitleCase(uint ucs4)
*/
ushort QChar::toTitleCase(ushort ucs2)
{
- const QUnicodeTables::Properties *p = qGetProp(ucs2);
- if (!p->titleCaseSpecial)
- return ucs2 + p->titleCaseDiff;
- return ucs2;
+ return toTitleCase_helper<ushort>(ucs2);
}
-
static inline uint foldCase(const ushort *ch, const ushort *start)
{
uint c = *ch;
if (QChar(c).isLowSurrogate() && ch > start && QChar(*(ch - 1)).isHighSurrogate())
c = QChar::surrogateToUcs4(*(ch - 1), c);
- return *ch + qGetProp(c)->caseFoldDiff;
+ return toCaseFolded_helper<uint>(c);
}
static inline uint foldCase(uint ch, uint &last)
@@ -1193,22 +1205,20 @@ static inline uint foldCase(uint ch, uint &last)
if (QChar(c).isLowSurrogate() && QChar(last).isHighSurrogate())
c = QChar::surrogateToUcs4(last, c);
last = ch;
- return ch + qGetProp(c)->caseFoldDiff;
+ return toCaseFolded_helper<uint>(c);
}
static inline ushort foldCase(ushort ch)
{
- return ch + qGetProp(ch)->caseFoldDiff;
+ return toCaseFolded_helper<ushort>(ch);
}
/*!
- Returns the case folded equivalent of the character. For most Unicode characters this
- is the same as toLowerCase().
+ \fn QChar QChar::toCaseFolded() const
+
+ Returns the case folded equivalent of the character.
+ For most Unicode characters this is the same as toLowerCase().
*/
-QChar QChar::toCaseFolded() const
-{
- return ucs + qGetProp(ucs)->caseFoldDiff;
-}
/*!
\overload
@@ -1219,7 +1229,7 @@ uint QChar::toCaseFolded(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- return ucs4 + qGetProp(ucs4)->caseFoldDiff;
+ return toCaseFolded_helper<uint>(ucs4);
}
/*!
@@ -1229,7 +1239,7 @@ uint QChar::toCaseFolded(uint ucs4)
*/
ushort QChar::toCaseFolded(ushort ucs2)
{
- return ucs2 + qGetProp(ucs2)->caseFoldDiff;
+ return toCaseFolded_helper<ushort>(ucs2);
}
/*!
@@ -1391,6 +1401,8 @@ QDataStream &operator>>(QDataStream &in, QChar &chr)
static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, int from)
{
+ int length;
+ int tag;
unsigned short buffer[3];
QString &s = *str;
@@ -1406,18 +1418,18 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion
ucs4 = QChar::surrogateToUcs4(high, ucs4);
}
}
+
const QChar::UnicodeVersion v = QChar::unicodeVersion(ucs4);
if (v > version || v == QChar::Unicode_Unassigned)
continue;
- int length;
- int tag;
+
const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer);
if (!d || (canonical && tag != QChar::Canonical))
continue;
int pos = uc - utf16;
s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, reinterpret_cast<const QChar *>(d), length);
- // since the insert invalidates the pointers and we do decomposition recursive
+ // since the replace invalidates the pointers and we do decomposition recursive
utf16 = reinterpret_cast<unsigned short *>(s.data());
uc = utf16 + pos + length;
}
@@ -1436,20 +1448,22 @@ inline bool operator<(const UCS2Pair &ligature, ushort u1)
static ushort ligatureHelper(ushort u1, ushort u2)
{
- // hangul L-V pair
- int LIndex = u1 - Hangul_LBase;
- if (0 <= LIndex && LIndex < Hangul_LCount) {
- int VIndex = u2 - Hangul_VBase;
- if (0 <= VIndex && VIndex < Hangul_VCount)
- return Hangul_SBase + (LIndex * Hangul_VCount + VIndex) * Hangul_TCount;
- }
-
- // hangul LV-T pair
- int SIndex = u1 - Hangul_SBase;
- if (0 <= SIndex && SIndex < Hangul_SCount && (SIndex % Hangul_TCount) == 0) {
- int TIndex = u2 - Hangul_TBase;
- if (0 <= TIndex && TIndex <= Hangul_TCount)
- return u1 + TIndex;
+ if (u1 >= Hangul_LBase && u1 <= Hangul_SBase + Hangul_SCount) {
+ // compute Hangul syllable composition as per UAX #15
+ // hangul L-V pair
+ const uint LIndex = u1 - Hangul_LBase;
+ if (LIndex < Hangul_LCount) {
+ const uint VIndex = u2 - Hangul_VBase;
+ if (VIndex < Hangul_VCount)
+ return Hangul_SBase + (LIndex * Hangul_VCount + VIndex) * Hangul_TCount;
+ }
+ // hangul LV-T pair
+ const uint SIndex = u1 - Hangul_SBase;
+ if (SIndex < Hangul_SCount && (SIndex % Hangul_TCount) == 0) {
+ const uint TIndex = u2 - Hangul_TBase;
+ if (TIndex <= Hangul_TCount)
+ return u1 + TIndex;
+ }
}
const unsigned short index = GET_LIGATURE_INDEX(u2);
@@ -1516,10 +1530,14 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
{
QString &s = *str;
const int l = s.length()-1;
+
+ uint u1, u2;
+ ushort c1, c2;
+
int pos = from;
while (pos < l) {
int p2 = pos+1;
- uint u1 = s.at(pos).unicode();
+ u1 = s.at(pos).unicode();
if (QChar(u1).isHighSurrogate()) {
ushort low = s.at(p2).unicode();
if (QChar(low).isLowSurrogate()) {
@@ -1529,7 +1547,10 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
++p2;
}
}
- uint u2 = s.at(p2).unicode();
+ c1 = 0;
+
+ advance:
+ u2 = s.at(p2).unicode();
if (QChar(u2).isHighSurrogate() && p2 < l) {
ushort low = s.at(p2+1).unicode();
if (QChar(low).isLowSurrogate()) {
@@ -1538,7 +1559,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
}
}
- ushort c2 = 0;
+ c2 = 0;
{
const QUnicodeTables::Properties *p = qGetProp(u2);
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
@@ -1549,8 +1570,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
continue;
}
- ushort c1 = 0;
- {
+ if (c1 == 0) {
const QUnicodeTables::Properties *p = qGetProp(u1);
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
c1 = p->combiningClass;
@@ -1580,6 +1600,16 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
++pos;
if (QChar::requiresSurrogates(u1))
++pos;
+
+ u1 = u2;
+ c1 = c2; // != 0
+ p2 = pos + 1;
+ if (QChar::requiresSurrogates(u1))
+ ++p2;
+ if (p2 > l)
+ break;
+
+ goto advance;
}
}
}
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index 9f2ca7ae9e..5d9402ae0c 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -203,23 +203,23 @@ public:
};
// ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO
- Category category() const;
- Direction direction() const;
- Joining joining() const;
+ inline Category category() const { return QChar::category(ucs); }
+ inline Direction direction() const { return QChar::direction(ucs); }
+ inline Joining joining() const { return QChar::joining(ucs); }
bool hasMirrored() const;
- unsigned char combiningClass() const;
+ inline unsigned char combiningClass() const { return QChar::combiningClass(ucs); }
- QChar mirroredChar() const;
+ inline QChar mirroredChar() const { return QChar::mirroredChar(ucs); }
QString decomposition() const;
Decomposition decompositionTag() const;
- int digitValue() const;
- QChar toLower() const;
- QChar toUpper() const;
- QChar toTitleCase() const;
- QChar toCaseFolded() const;
+ inline int digitValue() const { return QChar::digitValue(ucs); }
+ inline QChar toLower() const { return QChar::toLower(ucs); }
+ inline QChar toUpper() const { return QChar::toUpper(ucs); }
+ inline QChar toTitleCase() const { return QChar::toTitleCase(ucs); }
+ inline QChar toCaseFolded() const { return QChar::toCaseFolded(ucs); }
- UnicodeVersion unicodeVersion() const;
+ inline UnicodeVersion unicodeVersion() const { return QChar::unicodeVersion(ucs); }
inline char toAscii() const;
inline char toLatin1() const;
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index fa5eed4f86..630deccadd 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -824,7 +824,7 @@ QString QDate::toString(Qt::DateFormat f) const
range 0 to 9999. This restriction may apply to locale-aware
formats as well, depending on the locale settings.
- \sa QDateTime::toString() QTime::toString()
+ \sa QDateTime::toString(), QTime::toString()
*/
QString QDate::toString(const QString& format) const
@@ -836,7 +836,7 @@ QString QDate::toString(const QString& format) const
#endif //QT_NO_DATESTRING
/*!
- \fn bool setYMD(int y, int m, int d)
+ \fn bool QDate::setYMD(int y, int m, int d)
\deprecated in 5.0, use setDate() instead.
@@ -906,7 +906,7 @@ void QDate::getDate(int *year, int *month, int *day)
Returns a null date if the current date is invalid or the new date is
out-of-range.
- \sa addMonths() addYears() daysTo()
+ \sa addMonths(), addYears(), daysTo()
*/
QDate QDate::addDays(qint64 ndays) const
@@ -938,7 +938,7 @@ QDate QDate::addDays(qint64 ndays) const
resulting month/year, this function will return a date that is the
latest valid date.
- \sa addDays() addYears()
+ \sa addDays(), addYears()
*/
QDate QDate::addMonths(int nmonths) const
@@ -1029,7 +1029,7 @@ QDate QDate::addYears(int nyears) const
Returns 0 if either date is invalid.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 0
+ \snippet code/src_corelib_tools_qdatetime.cpp 0
\sa addDays()
*/
@@ -1217,7 +1217,7 @@ QDate QDate::fromString(const QString& s, Qt::DateFormat f)
of characters that are enclosed in single quotes will also be
treated as text and will not be used as an expression. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 1
+ \snippet code/src_corelib_tools_qdatetime.cpp 1
If the format is not satisfied, an invalid QDate is returned. The
expressions that don't expect leading zeroes (d, M) will be
@@ -1227,7 +1227,7 @@ QDate QDate::fromString(const QString& s, Qt::DateFormat f)
string could have meant January 30 but the M will grab two
digits, resulting in an invalid date:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 2
+ \snippet code/src_corelib_tools_qdatetime.cpp 2
For any field that is not represented in the format the following
defaults are used:
@@ -1241,7 +1241,7 @@ QDate QDate::fromString(const QString& s, Qt::DateFormat f)
The following examples demonstrate the default values:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 3
+ \snippet code/src_corelib_tools_qdatetime.cpp 3
\sa QDateTime::fromString(), QTime::fromString(), QDate::toString(),
QDateTime::toString(), QTime::toString()
@@ -1269,7 +1269,7 @@ QDate QDate::fromString(const QString &string, const QString &format)
day) is valid; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 4
+ \snippet code/src_corelib_tools_qdatetime.cpp 4
\sa isNull(), setDate()
*/
@@ -1300,7 +1300,7 @@ bool QDate::isLeapYear(int y)
return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
}
-/*! \fn static QDate QDate::fromJulianDay(int jd)
+/*! \fn static QDate QDate::fromJulianDay(qint64 jd)
Converts the Julian day \a jd to a QDate.
@@ -1582,7 +1582,7 @@ QString QTime::toString(Qt::DateFormat format) const
If the datetime is invalid, an empty string will be returned.
If \a format is empty, the default format "hh:mm:ss" is used.
- \sa QDate::toString() QDateTime::toString()
+ \sa QDate::toString(), QDateTime::toString()
*/
QString QTime::toString(const QString& format) const
{
@@ -1623,7 +1623,7 @@ bool QTime::setHMS(int h, int m, int s, int ms)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 5
+ \snippet code/src_corelib_tools_qdatetime.cpp 5
\sa addMSecs(), secsTo(), QDateTime::addSecs()
*/
@@ -1845,7 +1845,7 @@ QTime QTime::fromString(const QString& s, Qt::DateFormat f)
of characters that are enclosed in single quotes will also be
treated as text and not be used as an expression.
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 6
+ \snippet code/src_corelib_tools_qdatetime.cpp 6
If the format is not satisfied an invalid QTime is returned.
Expressions that do not expect leading zeroes to be given (h, m, s
@@ -1855,15 +1855,15 @@ QTime QTime::fromString(const QString& s, Qt::DateFormat f)
could have meant 00:07:10, but the m will grab two digits, resulting
in an invalid time:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 7
+ \snippet code/src_corelib_tools_qdatetime.cpp 7
Any field that is not represented in the format will be set to zero.
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 8
+ \snippet code/src_corelib_tools_qdatetime.cpp 8
- \sa QDateTime::fromString() QDate::fromString() QDate::toString()
- QDateTime::toString() QTime::toString()
+ \sa QDateTime::fromString(), QDate::fromString(), QDate::toString(),
+ QDateTime::toString(), QTime::toString()
*/
QTime QTime::fromString(const QString &string, const QString &format)
@@ -1894,7 +1894,7 @@ QTime QTime::fromString(const QString &string, const QString &format)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 9
+ \snippet code/src_corelib_tools_qdatetime.cpp 9
*/
bool QTime::isValid(int h, int m, int s, int ms)
@@ -1906,7 +1906,7 @@ bool QTime::isValid(int h, int m, int s, int ms)
/*!
Sets this time to the current time. This is practical for timing:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 10
+ \snippet code/src_corelib_tools_qdatetime.cpp 10
\sa restart(), elapsed(), currentTime()
*/
@@ -2077,7 +2077,7 @@ int QTime::elapsed() const
time zone before 1970, even if the system's time zone database
supports that information.
- \sa QDate QTime QDateTimeEdit
+ \sa QDate, QTime, QDateTimeEdit
*/
/*!
@@ -2432,7 +2432,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
range 0 to 9999. This restriction may apply to locale-aware
formats as well, depending on the locale settings.
- \sa QDate::toString() QTime::toString() Qt::DateFormat
+ \sa QDate::toString(), QTime::toString(), Qt::DateFormat
*/
QString QDateTime::toString(Qt::DateFormat f) const
@@ -2574,7 +2574,7 @@ QString QDateTime::toString(Qt::DateFormat f) const
If the datetime is invalid, an empty string will be returned.
- \sa QDate::toString() QTime::toString()
+ \sa QDate::toString(), QTime::toString()
*/
QString QDateTime::toString(const QString& format) const
{
@@ -2718,7 +2718,7 @@ qint64 QDateTime::daysTo(const QDateTime &other) const
Returns 0 if either time is invalid.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 11
+ \snippet code/src_corelib_tools_qdatetime.cpp 11
\sa addSecs(), daysTo(), QTime::secsTo()
*/
@@ -3420,7 +3420,7 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f)
of characters that are enclosed in singlequotes will also be
treated as text and not be used as an expression.
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 12
+ \snippet code/src_corelib_tools_qdatetime.cpp 12
If the format is not satisfied an invalid QDateTime is returned.
The expressions that don't have leading zeroes (d, M, h, m, s, z) will be
@@ -3428,7 +3428,7 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f)
put them outside the range and/or leave too few digits for other
sections.
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 13
+ \snippet code/src_corelib_tools_qdatetime.cpp 13
This could have meant 1 January 00:30.00 but the M will grab
two digits.
@@ -3448,10 +3448,10 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f)
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 14
+ \snippet code/src_corelib_tools_qdatetime.cpp 14
- \sa QDate::fromString() QTime::fromString() QDate::toString()
- QDateTime::toString() QTime::toString()
+ \sa QDate::fromString(), QTime::fromString(), QDate::toString(),
+ QDateTime::toString(), QTime::toString()
*/
QDateTime QDateTime::fromString(const QString &string, const QString &format)
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 81778f908f..e237b81cfa 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -55,7 +55,7 @@
\class QEasingCurve
\since 4.6
\ingroup animation
- \brief The QEasingCurve class provides easing curves for controlling animation.
+ \captionief The QEasingCurve class provides easing curves for controlling animation.
Easing curves describe a function that controls how the speed of the interpolation
between 0 and 1 should be. Easing curves allow transitions from
@@ -112,183 +112,173 @@
The type of easing curve.
- \value Linear \inlineimage qeasingcurve-linear.png
- \br
- Easing curve for a linear (t) function:
+ \value Linear \image qeasingcurve-linear.png
+ \caption Easing curve for a linear (t) function:
velocity is constant.
- \value InQuad \inlineimage qeasingcurve-inquad.png
- \br
- Easing curve for a quadratic (t^2) function:
+ \value InQuad \image qeasingcurve-inquad.png
+ \caption Easing curve for a quadratic (t^2) function:
accelerating from zero velocity.
- \value OutQuad \inlineimage qeasingcurve-outquad.png
- \br
- Easing curve for a quadratic (t^2) function:
+ \value OutQuad \image qeasingcurve-outquad.png
+ \caption Easing curve for a quadratic (t^2) function:
decelerating to zero velocity.
- \value InOutQuad \inlineimage qeasingcurve-inoutquad.png
- \br
- Easing curve for a quadratic (t^2) function:
+ \value InOutQuad \image qeasingcurve-inoutquad.png
+ \caption Easing curve for a quadratic (t^2) function:
acceleration until halfway, then deceleration.
- \value OutInQuad \inlineimage qeasingcurve-outinquad.png
- \br
- Easing curve for a quadratic (t^2) function:
+ \value OutInQuad \image qeasingcurve-outinquad.png
+ \caption Easing curve for a quadratic (t^2) function:
deceleration until halfway, then acceleration.
- \value InCubic \inlineimage qeasingcurve-incubic.png
- \br
- Easing curve for a cubic (t^3) function:
+ \value InCubic \image qeasingcurve-incubic.png
+ \caption Easing curve for a cubic (t^3) function:
accelerating from zero velocity.
- \value OutCubic \inlineimage qeasingcurve-outcubic.png
- \br
- Easing curve for a cubic (t^3) function:
+ \value OutCubic \image qeasingcurve-outcubic.png
+ \caption Easing curve for a cubic (t^3) function:
decelerating to zero velocity.
- \value InOutCubic \inlineimage qeasingcurve-inoutcubic.png
- \br
- Easing curve for a cubic (t^3) function:
+ \value InOutCubic \image qeasingcurve-inoutcubic.png
+ \caption Easing curve for a cubic (t^3) function:
acceleration until halfway, then deceleration.
- \value OutInCubic \inlineimage qeasingcurve-outincubic.png
- \br
- Easing curve for a cubic (t^3) function:
+ \value OutInCubic \image qeasingcurve-outincubic.png
+ \caption Easing curve for a cubic (t^3) function:
deceleration until halfway, then acceleration.
- \value InQuart \inlineimage qeasingcurve-inquart.png
- \br
- Easing curve for a quartic (t^4) function:
+ \value InQuart \image qeasingcurve-inquart.png
+ \caption Easing curve for a quartic (t^4) function:
accelerating from zero velocity.
- \value OutQuart \inlineimage qeasingcurve-outquart.png
- \br
+ \value OutQuart \image qeasingcurve-outquart.png
+ \caption
Easing curve for a quartic (t^4) function:
decelerating to zero velocity.
- \value InOutQuart \inlineimage qeasingcurve-inoutquart.png
- \br
+ \value InOutQuart \image qeasingcurve-inoutquart.png
+ \caption
Easing curve for a quartic (t^4) function:
acceleration until halfway, then deceleration.
- \value OutInQuart \inlineimage qeasingcurve-outinquart.png
- \br
+ \value OutInQuart \image qeasingcurve-outinquart.png
+ \caption
Easing curve for a quartic (t^4) function:
deceleration until halfway, then acceleration.
- \value InQuint \inlineimage qeasingcurve-inquint.png
- \br
+ \value InQuint \image qeasingcurve-inquint.png
+ \caption
Easing curve for a quintic (t^5) easing
in: accelerating from zero velocity.
- \value OutQuint \inlineimage qeasingcurve-outquint.png
- \br
+ \value OutQuint \image qeasingcurve-outquint.png
+ \caption
Easing curve for a quintic (t^5) function:
decelerating to zero velocity.
- \value InOutQuint \inlineimage qeasingcurve-inoutquint.png
- \br
+ \value InOutQuint \image qeasingcurve-inoutquint.png
+ \caption
Easing curve for a quintic (t^5) function:
acceleration until halfway, then deceleration.
- \value OutInQuint \inlineimage qeasingcurve-outinquint.png
- \br
+ \value OutInQuint \image qeasingcurve-outinquint.png
+ \caption
Easing curve for a quintic (t^5) function:
deceleration until halfway, then acceleration.
- \value InSine \inlineimage qeasingcurve-insine.png
- \br
+ \value InSine \image qeasingcurve-insine.png
+ \caption
Easing curve for a sinusoidal (sin(t)) function:
accelerating from zero velocity.
- \value OutSine \inlineimage qeasingcurve-outsine.png
- \br
+ \value OutSine \image qeasingcurve-outsine.png
+ \caption
Easing curve for a sinusoidal (sin(t)) function:
decelerating from zero velocity.
- \value InOutSine \inlineimage qeasingcurve-inoutsine.png
- \br
+ \value InOutSine \image qeasingcurve-inoutsine.png
+ \caption
Easing curve for a sinusoidal (sin(t)) function:
acceleration until halfway, then deceleration.
- \value OutInSine \inlineimage qeasingcurve-outinsine.png
- \br
+ \value OutInSine \image qeasingcurve-outinsine.png
+ \caption
Easing curve for a sinusoidal (sin(t)) function:
deceleration until halfway, then acceleration.
- \value InExpo \inlineimage qeasingcurve-inexpo.png
- \br
+ \value InExpo \image qeasingcurve-inexpo.png
+ \caption
Easing curve for an exponential (2^t) function:
accelerating from zero velocity.
- \value OutExpo \inlineimage qeasingcurve-outexpo.png
- \br
+ \value OutExpo \image qeasingcurve-outexpo.png
+ \caption
Easing curve for an exponential (2^t) function:
decelerating from zero velocity.
- \value InOutExpo \inlineimage qeasingcurve-inoutexpo.png
- \br
+ \value InOutExpo \image qeasingcurve-inoutexpo.png
+ \caption
Easing curve for an exponential (2^t) function:
acceleration until halfway, then deceleration.
- \value OutInExpo \inlineimage qeasingcurve-outinexpo.png
- \br
+ \value OutInExpo \image qeasingcurve-outinexpo.png
+ \caption
Easing curve for an exponential (2^t) function:
deceleration until halfway, then acceleration.
- \value InCirc \inlineimage qeasingcurve-incirc.png
- \br
+ \value InCirc \image qeasingcurve-incirc.png
+ \caption
Easing curve for a circular (sqrt(1-t^2)) function:
accelerating from zero velocity.
- \value OutCirc \inlineimage qeasingcurve-outcirc.png
- \br
+ \value OutCirc \image qeasingcurve-outcirc.png
+ \caption
Easing curve for a circular (sqrt(1-t^2)) function:
decelerating from zero velocity.
- \value InOutCirc \inlineimage qeasingcurve-inoutcirc.png
- \br
+ \value InOutCirc \image qeasingcurve-inoutcirc.png
+ \caption
Easing curve for a circular (sqrt(1-t^2)) function:
acceleration until halfway, then deceleration.
- \value OutInCirc \inlineimage qeasingcurve-outincirc.png
- \br
+ \value OutInCirc \image qeasingcurve-outincirc.png
+ \caption
Easing curve for a circular (sqrt(1-t^2)) function:
deceleration until halfway, then acceleration.
- \value InElastic \inlineimage qeasingcurve-inelastic.png
- \br
+ \value InElastic \image qeasingcurve-inelastic.png
+ \caption
Easing curve for an elastic
(exponentially decaying sine wave) function:
accelerating from zero velocity. The peak amplitude
can be set with the \e amplitude parameter, and the
period of decay by the \e period parameter.
- \value OutElastic \inlineimage qeasingcurve-outelastic.png
- \br
+ \value OutElastic \image qeasingcurve-outelastic.png
+ \caption
Easing curve for an elastic
(exponentially decaying sine wave) function:
decelerating from zero velocity. The peak amplitude
can be set with the \e amplitude parameter, and the
period of decay by the \e period parameter.
- \value InOutElastic \inlineimage qeasingcurve-inoutelastic.png
- \br
+ \value InOutElastic \image qeasingcurve-inoutelastic.png
+ \caption
Easing curve for an elastic
(exponentially decaying sine wave) function:
acceleration until halfway, then deceleration.
- \value OutInElastic \inlineimage qeasingcurve-outinelastic.png
- \br
+ \value OutInElastic \image qeasingcurve-outinelastic.png
+ \caption
Easing curve for an elastic
(exponentially decaying sine wave) function:
deceleration until halfway, then acceleration.
- \value InBack \inlineimage qeasingcurve-inback.png
- \br
+ \value InBack \image qeasingcurve-inback.png
+ \caption
Easing curve for a back (overshooting
cubic function: (s+1)*t^3 - s*t^2) easing in:
accelerating from zero velocity.
- \value OutBack \inlineimage qeasingcurve-outback.png
- \br
+ \value OutBack \image qeasingcurve-outback.png
+ \caption
Easing curve for a back (overshooting
cubic function: (s+1)*t^3 - s*t^2) easing out:
decelerating to zero velocity.
- \value InOutBack \inlineimage qeasingcurve-inoutback.png
- \br
+ \value InOutBack \image qeasingcurve-inoutback.png
+ \caption
Easing curve for a back (overshooting
cubic function: (s+1)*t^3 - s*t^2) easing in/out:
acceleration until halfway, then deceleration.
- \value OutInBack \inlineimage qeasingcurve-outinback.png
- \br
+ \value OutInBack \image qeasingcurve-outinback.png
+ \caption
Easing curve for a back (overshooting
cubic easing: (s+1)*t^3 - s*t^2) easing out/in:
deceleration until halfway, then acceleration.
- \value InBounce \inlineimage qeasingcurve-inbounce.png
- \br
+ \value InBounce \image qeasingcurve-inbounce.png
+ \caption
Easing curve for a bounce (exponentially
decaying parabolic bounce) function: accelerating
from zero velocity.
- \value OutBounce \inlineimage qeasingcurve-outbounce.png
- \br
+ \value OutBounce \image qeasingcurve-outbounce.png
+ \caption
Easing curve for a bounce (exponentially
decaying parabolic bounce) function: decelerating
from zero velocity.
- \value InOutBounce \inlineimage qeasingcurve-inoutbounce.png
- \br
+ \value InOutBounce \image qeasingcurve-inoutbounce.png
+ \caption
Easing curve for a bounce (exponentially
decaying parabolic bounce) function easing in/out:
acceleration until halfway, then deceleration.
- \value OutInBounce \inlineimage qeasingcurve-outinbounce.png
- \br
+ \value OutInBounce \image qeasingcurve-outinbounce.png
+ \caption
Easing curve for a bounce (exponentially
decaying parabolic bounce) function easing out/in:
deceleration until halfway, then acceleration.
@@ -312,7 +302,7 @@
This is a typedef for a pointer to a function with the following
signature:
- \snippet doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp 0
+ \snippet code/src_corelib_tools_qeasingcurve.cpp 0
*/
#include "qeasingcurve.h"
@@ -349,7 +339,7 @@ struct TCBPoint {
TCBPoint() {}
TCBPoint(QPointF point, qreal t, qreal c, qreal b) : _point(point), _t(t), _c(c), _b(b) {}
- bool operator==(const TCBPoint& other)
+ bool operator==(const TCBPoint &other) const
{
return _point == other._point &&
qFuzzyCompare(_t, other._t) &&
@@ -373,7 +363,7 @@ public:
virtual ~QEasingCurveFunction() {}
virtual qreal value(qreal t);
virtual QEasingCurveFunction *copy() const;
- bool operator==(const QEasingCurveFunction& other);
+ bool operator==(const QEasingCurveFunction &other) const;
Type _t;
qreal _p;
@@ -397,7 +387,7 @@ QEasingCurveFunction *QEasingCurveFunction::copy() const
return rv;
}
-bool QEasingCurveFunction::operator==(const QEasingCurveFunction& other)
+bool QEasingCurveFunction::operator==(const QEasingCurveFunction &other) const
{
return _t == other._t &&
qFuzzyCompare(_p, other._p) &&
@@ -1467,7 +1457,7 @@ QDataStream &operator<<(QDataStream &stream, const QEasingCurve &easing)
/*!
\fn QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing)
- \relates QQuaternion
+ \relates QEasingCurve
Reads an easing curve from the given \a stream into the given \a
easing curve and returns a reference to the stream.
diff --git a/src/corelib/tools/qelapsedtimer.cpp b/src/corelib/tools/qelapsedtimer.cpp
index e8f2ce174e..76b0d796f0 100644
--- a/src/corelib/tools/qelapsedtimer.cpp
+++ b/src/corelib/tools/qelapsedtimer.cpp
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
spent in a slow operation. The simplest example of such a case is for
debugging purposes, as in the following example:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 0
+ \snippet qelapsedtimer/main.cpp 0
In this example, the timer is started by a call to start() and the
elapsed timer is calculated by the elapsed() function.
@@ -76,14 +76,14 @@ QT_BEGIN_NAMESPACE
subclasses are good examples of such need. In that case, the code could
be as follows:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 1
+ \snippet qelapsedtimer/main.cpp 1
Another use-case is to execute a certain operation for a specific
timeslice. For this, QElapsedTimer provides the hasExpired() convenience
function, which can be used to determine if a certain number of
milliseconds has already elapsed:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 2
+ \snippet qelapsedtimer/main.cpp 2
\section1 Reference clocks
diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp
index 05214f0698..a20b6b5662 100644
--- a/src/corelib/tools/qelapsedtimer_generic.cpp
+++ b/src/corelib/tools/qelapsedtimer_generic.cpp
@@ -70,7 +70,7 @@ bool QElapsedTimer::isMonotonic()
Starts this timer. Once started, a timer value can be checked with elapsed() or msecsSinceReference().
Normally, a timer is started just before a lengthy operation, such as:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 0
+ \snippet qelapsedtimer/main.cpp 0
Also, starting a timer makes it valid again.
@@ -91,7 +91,7 @@ void QElapsedTimer::start()
parameter to a slow operation (for example, an iteration count) so that
this operation takes at least 250 milliseconds:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 3
+ \snippet qelapsedtimer/main.cpp 3
\sa start(), invalidate(), elapsed()
*/
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 20202a4896..10dcff92c7 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -369,7 +369,6 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
QT_RETHROW;
}
- dup->h = oldNode->h;
*nextNode = dup;
nextNode = &dup->next;
oldNode = oldNode->next;
@@ -694,21 +693,21 @@ void QHashData::checkSanity()
\endlist
Here's an example QHash with QString keys and \c int values:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 0
+ \snippet code/src_corelib_tools_qhash.cpp 0
To insert a (key, value) pair into the hash, you can use operator[]():
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 1
+ \snippet code/src_corelib_tools_qhash.cpp 1
This inserts the following three (key, value) pairs into the
QHash: ("one", 1), ("three", 3), and ("seven", 7). Another way to
insert items into the hash is to use insert():
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 2
+ \snippet code/src_corelib_tools_qhash.cpp 2
To look up a value, use operator[]() or value():
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 3
+ \snippet code/src_corelib_tools_qhash.cpp 3
If there is no item with the specified key in the hash, these
functions return a \l{default-constructed value}.
@@ -716,12 +715,12 @@ void QHashData::checkSanity()
If you want to check whether the hash contains a particular key,
use contains():
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 4
+ \snippet code/src_corelib_tools_qhash.cpp 4
There is also a value() overload that uses its second argument as
a default value if there is no item with the specified key:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 5
+ \snippet code/src_corelib_tools_qhash.cpp 5
In general, we recommend that you use contains() and value()
rather than operator[]() for looking up a key in a hash. The
@@ -730,7 +729,7 @@ void QHashData::checkSanity()
const). For example, the following code snippet will create 1000
items in memory:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 6
+ \snippet code/src_corelib_tools_qhash.cpp 6
To avoid this problem, replace \c hash[i] with \c hash.value(i)
in the code above.
@@ -751,11 +750,11 @@ void QHashData::checkSanity()
QHash::iterator). Here's how to iterate over a QHash<QString,
int> using a Java-style iterator:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 7
+ \snippet code/src_corelib_tools_qhash.cpp 7
Here's the same code, but using an STL-style iterator:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 8
+ \snippet code/src_corelib_tools_qhash.cpp 8
QHash is unordered, so an iterator's sequence cannot be assumed
to be predictable. If ordering by key is required, use a QMap.
@@ -764,7 +763,7 @@ void QHashData::checkSanity()
insert() with a key that already exists in the QHash, the
previous value is erased. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 9
+ \snippet code/src_corelib_tools_qhash.cpp 9
However, you can store multiple values per key by using
insertMulti() instead of insert() (or using the convenience
@@ -772,19 +771,19 @@ void QHashData::checkSanity()
the values for a single key, you can use values(const Key &key),
which returns a QList<T>:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 10
+ \snippet code/src_corelib_tools_qhash.cpp 10
The items that share the same key are available from most
recently to least recently inserted. A more efficient approach is
to call find() to get the iterator for the first item with a key
and iterate from there:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 11
+ \snippet code/src_corelib_tools_qhash.cpp 11
If you only need to extract the values from a hash (not the keys),
you can also use \l{foreach}:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 12
+ \snippet code/src_corelib_tools_qhash.cpp 12
Items can be removed from the hash in several ways. One way is to
call remove(); this will remove any item with the given key.
@@ -975,7 +974,7 @@ void QHashData::checkSanity()
This function is useful for code that needs to build a huge hash
and wants to avoid repeated reallocation. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 14
+ \snippet code/src_corelib_tools_qhash.cpp 14
Ideally, \a size should be slightly more than the maximum number
of items expected in the hash. \a size doesn't have to be prime,
@@ -1284,7 +1283,7 @@ void QHashData::checkSanity()
be called while iterating, and won't affect the order of items in
the hash. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 15
+ \snippet code/src_corelib_tools_qhash.cpp 15
\sa remove(), take(), find()
*/
@@ -1303,7 +1302,7 @@ void QHashData::checkSanity()
the iterator. For example, here's some code that iterates over all
the items with the same key:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 16
+ \snippet code/src_corelib_tools_qhash.cpp 16
\sa value(), values(), QMultiHash::find()
*/
@@ -1460,7 +1459,7 @@ void QHashData::checkSanity()
start iterating. Here's a typical loop that prints all the (key,
value) pairs stored in a hash:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 17
+ \snippet code/src_corelib_tools_qhash.cpp 17
Unlike QMap, which orders its items by key, QHash stores its
items in an arbitrary order. The only guarantee is that items that
@@ -1473,22 +1472,22 @@ void QHashData::checkSanity()
Here's an example that increments every value stored in the QHash
by 2:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 18
+ \snippet code/src_corelib_tools_qhash.cpp 18
Here's an example that removes all the items whose key is a
string that starts with an underscore character:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 19
+ \snippet code/src_corelib_tools_qhash.cpp 19
The call to QHash::erase() removes the item pointed to by the
iterator from the hash, and returns an iterator to the next item.
Here's another way of removing an item while iterating:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 20
+ \snippet code/src_corelib_tools_qhash.cpp 20
It might be tempting to write code like this:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 21
+ \snippet code/src_corelib_tools_qhash.cpp 21
However, this will potentially crash in \c{++i}, because \c i is
a dangling iterator after the call to erase().
@@ -1514,7 +1513,7 @@ void QHashData::checkSanity()
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QHash::begin() QHash::end()
+ \sa QHash::begin(), QHash::end()
*/
/*! \fn QHash::iterator::iterator(void *node)
@@ -1540,7 +1539,7 @@ void QHashData::checkSanity()
You can change the value of an item by using value() on
the left side of an assignment, for example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 22
+ \snippet code/src_corelib_tools_qhash.cpp 22
\sa key(), operator*()
*/
@@ -1684,7 +1683,7 @@ void QHashData::checkSanity()
QHash::find() before you can start iterating. Here's a typical
loop that prints all the (key, value) pairs stored in a hash:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 23
+ \snippet code/src_corelib_tools_qhash.cpp 23
Unlike QMap, which orders its items by key, QHash stores its
items in an arbitrary order. The only guarantee is that items that
@@ -1710,7 +1709,7 @@ void QHashData::checkSanity()
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QHash::constBegin() QHash::constEnd()
+ \sa QHash::constBegin(), QHash::constEnd()
*/
/*! \fn QHash::const_iterator::const_iterator(void *node)
@@ -1897,7 +1896,7 @@ void QHashData::checkSanity()
operator+=().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 24
+ \snippet code/src_corelib_tools_qhash.cpp 24
Unlike QHash, QMultiHash provides no operator[]. Use value() or
replace() if you want to access the most recently inserted item
@@ -1906,7 +1905,7 @@ void QHashData::checkSanity()
If you want to retrieve all the values for a single key, you can
use values(const Key &key), which returns a QList<T>:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 25
+ \snippet code/src_corelib_tools_qhash.cpp 25
The items that share the same key are available from most
recently to least recently inserted.
@@ -1915,7 +1914,7 @@ void QHashData::checkSanity()
the STL-style iterator for the first item with a key and iterate from
there:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 26
+ \snippet code/src_corelib_tools_qhash.cpp 26
QMultiHash's key and value data types must be \l{assignable data
types}. You cannot, for example, store a QWidget as a value;
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index fe6a8dfad1..d196e6e376 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -197,27 +197,29 @@ inline bool operator==(const QHashDummyValue & /* v1 */, const QHashDummyValue &
Q_DECLARE_TYPEINFO(QHashDummyValue, Q_MOVABLE_TYPE | Q_DUMMY_TYPE);
template <class Key, class T>
-struct QHashDummyNode
+struct QHashNode
{
- QHashDummyNode *next;
+ QHashNode *next;
uint h;
Key key;
+ T value;
- inline QHashDummyNode(const Key &key0) : key(key0) {}
+ inline QHashNode(const Key &key0, const T &value0, uint hash, QHashNode *n)
+ : next(n), h(hash), key(key0), value(value0) {}
+ inline bool same_key(uint h0, const Key &key0) { return h0 == h && key0 == key; }
};
template <class Key, class T>
-struct QHashNode
+struct QHashDummyNode
{
- QHashNode *next;
+ QHashNode<Key, T> *next;
uint h;
Key key;
- T value;
- inline QHashNode(const Key &key0, const T &value0) : key(key0), value(value0) {}
- inline bool same_key(uint h0, const Key &key0) { return h0 == h && key0 == key; }
+ inline QHashDummyNode(const Key &key0, uint hash, QHashNode<Key, T> *n) : next(n), h(hash), key(key0) {}
};
+
#if 0
// ###
// The introduction of the QHash random seed breaks this optimization, as it
@@ -519,9 +521,9 @@ Q_INLINE_TEMPLATE void QHash<Key, T>::duplicateNode(QHashData::Node *node, void
{
Node *concreteNode = concrete(node);
if (QTypeInfo<T>::isDummy) {
- (void) new (newNode) DummyNode(concreteNode->key);
+ (void) new (newNode) DummyNode(concreteNode->key, concreteNode->h, 0);
} else {
- (void) new (newNode) Node(concreteNode->key, concreteNode->value);
+ (void) new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, 0);
}
}
@@ -532,13 +534,11 @@ QHash<Key, T>::createNode(uint ah, const Key &akey, const T &avalue, Node **anex
Node *node;
if (QTypeInfo<T>::isDummy) {
- node = reinterpret_cast<Node *>(new (d->allocateNode(alignOfDummyNode())) DummyNode(akey));
+ node = reinterpret_cast<Node *>(new (d->allocateNode(alignOfDummyNode())) DummyNode(akey, ah, *anextNode));
} else {
- node = new (d->allocateNode(alignOfNode())) Node(akey, avalue);
+ node = new (d->allocateNode(alignOfNode())) Node(akey, avalue, ah, *anextNode);
}
- node->h = ah;
- node->next = *anextNode;
*anextNode = node;
++d->size;
return node;
diff --git a/src/corelib/tools/qiterator.qdoc b/src/corelib/tools/qiterator.qdoc
index e19a751755..508664ec45 100644
--- a/src/corelib/tools/qiterator.qdoc
+++ b/src/corelib/tools/qiterator.qdoc
@@ -50,7 +50,7 @@
the list (before the first item). Here's how to iterate over all
the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 0
+ \snippet code/doc_src_qiterator.cpp 0
The next() function returns the next item in the list and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -61,11 +61,11 @@
position between the second and third item, and returns the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 1
+ \snippet code/doc_src_qiterator.cpp 1
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -98,7 +98,7 @@
beginning of the list (before the first item). Here's how to
iterate over all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 2
+ \snippet code/doc_src_qiterator.cpp 2
The next() function returns the next item in the list and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -109,11 +109,11 @@
position between the second and third item, and returns the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 3
+ \snippet code/doc_src_qiterator.cpp 3
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -150,7 +150,7 @@
of the vector (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 4
+ \snippet code/doc_src_qiterator.cpp 4
The next() function returns the next item in the vector and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -161,11 +161,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 5
+ \snippet code/doc_src_qiterator.cpp 5
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -197,7 +197,7 @@
the first item). Here's how to iterate over all the elements
sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 6
+ \snippet code/doc_src_qiterator.cpp 6
The next() function returns the next item in the set and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -208,11 +208,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 7
+ \snippet code/doc_src_qiterator.cpp 7
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -251,7 +251,7 @@
of the list (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 8
+ \snippet code/doc_src_qiterator.cpp 8
The next() function returns the next item in the list and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -262,11 +262,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 9
+ \snippet code/doc_src_qiterator.cpp 9
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -277,7 +277,7 @@
insert().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 10
+ \snippet code/doc_src_qiterator.cpp 10
The example traverses a list, replacing negative numbers with
their absolute values, and eliminating zeroes.
@@ -312,7 +312,7 @@
beginning of the list (before the first item). Here's how to
iterate over all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 11
+ \snippet code/doc_src_qiterator.cpp 11
The next() function returns the next item in the list and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -323,11 +323,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 12
+ \snippet code/doc_src_qiterator.cpp 12
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -338,7 +338,7 @@
insert().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 13
+ \snippet code/doc_src_qiterator.cpp 13
The example traverses a list, replacing negative numbers with
their absolute values, and eliminating zeroes.
@@ -378,7 +378,7 @@
beginning of the list (before the first item). Here's how to
iterate over all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 14
+ \snippet code/doc_src_qiterator.cpp 14
The next() function returns the next item in the vector and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -389,11 +389,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 15
+ \snippet code/doc_src_qiterator.cpp 15
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -404,7 +404,7 @@
insert().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 16
+ \snippet code/doc_src_qiterator.cpp 16
The example traverses a vector, replacing negative numbers with
their absolute values, and eliminating zeroes.
@@ -440,7 +440,7 @@
of the set (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 17
+ \snippet code/doc_src_qiterator.cpp 17
The next() function returns the next item in the set and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -451,11 +451,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 18
+ \snippet code/doc_src_qiterator.cpp 18
If you want to remove items as you iterate over the set, use
remove().
@@ -755,7 +755,7 @@
traversal functions (next(), previous(), findNext(), findPrevious()).
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 19
+ \snippet code/doc_src_qiterator.cpp 19
\sa insert(), setValue()
*/
@@ -766,7 +766,7 @@
traversal functions (next(), previous(), findNext(), findPrevious()).
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 20
+ \snippet code/doc_src_qiterator.cpp 20
\sa insert(), setValue()
*/
@@ -777,7 +777,7 @@
traversal functions (next(), previous(), findNext(), findPrevious()).
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 21
+ \snippet code/doc_src_qiterator.cpp 21
\sa insert(), setValue()
*/
@@ -788,7 +788,7 @@
traversal functions (next(), previous(), findNext(), findPrevious()).
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 22
+ \snippet code/doc_src_qiterator.cpp 22
\sa value()
*/
@@ -802,7 +802,7 @@
findPrevious().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 23
+ \snippet code/doc_src_qiterator.cpp 23
\sa value(), remove(), insert()
*/
@@ -816,7 +816,7 @@
findPrevious().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 24
+ \snippet code/doc_src_qiterator.cpp 24
\sa value(), remove(), insert()
*/
@@ -830,7 +830,7 @@
findPrevious().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 25
+ \snippet code/doc_src_qiterator.cpp 25
\sa value(), remove(), insert()
*/
@@ -889,7 +889,7 @@
the map (before the first item). Here's how to iterate over all
the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 26
+ \snippet code/doc_src_qiterator.cpp 26
The next() function returns the next item in the map and
advances the iterator. The key() and value() functions return the
@@ -902,16 +902,16 @@
next() advances the iterator to the position between the second
and third item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 27
+ \snippet code/doc_src_qiterator.cpp 27
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop. For example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 28
+ \snippet code/doc_src_qiterator.cpp 28
Multiple iterators can be used on the same map. If the map is
modified while a QMapIterator is active, the QMapIterator will
@@ -941,7 +941,7 @@
the hash (before the first item). Here's how to iterate over all
the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 29
+ \snippet code/doc_src_qiterator.cpp 29
The next() function returns the next item in the hash and
advances the iterator. The key() and value() functions return the
@@ -954,16 +954,16 @@
next() advances the iterator to the position between the second
and third item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 30
+ \snippet code/doc_src_qiterator.cpp 30
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop. For example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 31
+ \snippet code/doc_src_qiterator.cpp 31
Multiple iterators can be used on the same hash. If the hash is
modified while a QHashIterator is active, the QHashIterator will
@@ -994,7 +994,7 @@
of the map (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 32
+ \snippet code/doc_src_qiterator.cpp 32
The next() function returns the next item in the map and
advances the iterator. The key() and value() functions return the
@@ -1007,16 +1007,16 @@
next() advances the iterator to the position between the second
and third item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 33
+ \snippet code/doc_src_qiterator.cpp 33
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop. For example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 34
+ \snippet code/doc_src_qiterator.cpp 34
If you want to remove items as you iterate over the map, use
remove(). If you want to modify the value of an item, use
@@ -1024,7 +1024,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 35
+ \snippet code/doc_src_qiterator.cpp 35
The example removes all (key, value) pairs where the key and the
value are the same.
@@ -1059,7 +1059,7 @@
of the hash (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 36
+ \snippet code/doc_src_qiterator.cpp 36
The next() function returns the next item in the hash and
advances the iterator. The key() and value() functions return the
@@ -1072,16 +1072,16 @@
next() advances the iterator to the position between the second
and third item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 37
+ \snippet code/doc_src_qiterator.cpp 37
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop. For example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 38
+ \snippet code/doc_src_qiterator.cpp 38
If you want to remove items as you iterate over the hash, use
remove(). If you want to modify the value of an item, use
@@ -1089,7 +1089,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 39
+ \snippet code/doc_src_qiterator.cpp 39
The example removes all (key, value) pairs where the key and the
value are the same.
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index 1502f70d56..3682818099 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -81,13 +81,13 @@ const QLinkedListData QLinkedListData::shared_null = {
Here's an example of a QLinkedList that stores integers and a
QLinkedList that stores QTime values:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 0
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 0
QLinkedList stores a list of items. The default constructor
creates an empty list. To insert items into the list, you can use
operator<<():
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 1
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 1
If you want to get the first or last item in a linked list, use
first() or last(). If you want to remove an item from either end
@@ -99,7 +99,7 @@ const QLinkedListData QLinkedListData::shared_null = {
list and do something with it. For this, QLinkedList provides
takeFirst() and takeLast(). Here's a loop that removes the items
from a list one at a time and calls \c delete on them:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 2
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 2
QLinkedList's value type must be an \l {assignable data type}. This
covers most data types that are commonly used, but the compiler
@@ -230,7 +230,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Inserts \a value at the end of the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 3
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 3
This is the same as list.insert(end(), \a value).
@@ -242,7 +242,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Inserts \a value at the beginning of the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 4
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 4
This is the same as list.insert(begin(), \a value).
@@ -254,7 +254,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Removes all occurrences of \a value in the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 5
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 5
This function requires the value type to have an implementation of
\c operator==().
@@ -270,7 +270,7 @@ const QLinkedListData QLinkedListData::shared_null = {
success; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 6
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 6
This function requires the value type to have an implementation of
\c operator==().
@@ -635,35 +635,35 @@ const QLinkedListData QLinkedListData::shared_null = {
QLinkedList::insert() before you can start iterating. Here's a
typical loop that prints all the items stored in a list:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 7
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 7
STL-style iterators can be used as arguments to \l{generic
algorithms}. For example, here's how to find an item in the list
using the qFind() algorithm:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 8
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 8
Let's see a few examples of things we can do with a
QLinkedList::iterator that we cannot do with a QLinkedList::const_iterator.
Here's an example that increments every value stored in a
QLinkedList\<int\> by 2:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 9
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 9
Here's an example that removes all the items that start with an
underscore character in a QLinkedList\<QString\>:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 10
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 10
The call to QLinkedList::erase() removes the item pointed to by
the iterator from the list, and returns an iterator to the next
item. Here's another way of removing an item while iterating:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 11
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 11
It might be tempting to write code like this:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 12
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 12
However, this will potentially crash in \c{++i}, because \c i is
a dangling iterator after the call to erase().
@@ -686,7 +686,7 @@ const QLinkedListData QLinkedListData::shared_null = {
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QLinkedList::begin() QLinkedList::end()
+ \sa QLinkedList::begin(), QLinkedList::end()
*/
/*! \fn QLinkedList::iterator::iterator(Node *node)
@@ -736,7 +736,7 @@ const QLinkedListData QLinkedListData::shared_null = {
You can change the value of an item by using operator*() on the
left side of an assignment, for example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 13
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 13
\sa operator->()
*/
@@ -868,13 +868,13 @@ const QLinkedListData QLinkedListData::shared_null = {
QLinkedList::insert() before you can start iterating. Here's a
typical loop that prints all the items stored in a list:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 14
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 14
STL-style iterators can be used as arguments to \l{generic
algorithms}. For example, here's how to find an item in the list
using the qFind() algorithm:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 15
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 15
Multiple iterators can be used on the same list. If you add items
to the list, existing iterators will remain valid. If you remove
@@ -892,7 +892,7 @@ const QLinkedListData QLinkedListData::shared_null = {
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QLinkedList::constBegin() QLinkedList::constEnd()
+ \sa QLinkedList::constBegin(), QLinkedList::constEnd()
*/
/*! \fn QLinkedList::const_iterator::const_iterator(Node *node)
@@ -1082,7 +1082,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 16
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 16
\sa toStdList()
*/
@@ -1094,7 +1094,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Returns a std::list object with the data contained in this
QLinkedList. Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 17
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 17
\sa fromStdList()
*/
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index c87b3e7d24..b3514d35ef 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -375,7 +375,7 @@ void **QListData::erase(void **xi)
Here's an example of a QList that stores integers and
a QList that stores QDate values:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 0
+ \snippet code/src_corelib_tools_qlistdata.cpp 0
Qt includes a QStringList class that inherits QList\<QString\>
and adds a few convenience functions, such as QStringList::join()
@@ -386,7 +386,7 @@ void **QListData::erase(void **xi)
empty list. To insert items into the list, you can use
operator<<():
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 1
+ \snippet code/src_corelib_tools_qlistdata.cpp 1
QList provides these basic functions to add, move, and remove
items: insert(), replace(), removeAt(), move(), and swap(). In
@@ -398,13 +398,13 @@ void **QListData::erase(void **xi)
non-const lists, operator[]() returns a reference to the item and
can be used on the left side of an assignment:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 2
+ \snippet code/src_corelib_tools_qlistdata.cpp 2
Because QList is implemented as an array of pointers, this
operation is very fast (\l{constant time}). For read-only access,
an alternative syntax is to use at():
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 3
+ \snippet code/src_corelib_tools_qlistdata.cpp 3
at() can be faster than operator[](), because it never causes a
\l{deep copy} to occur.
@@ -414,7 +414,7 @@ void **QListData::erase(void **xi)
and takeLast(). Here's a loop that removes the items from a list
one at a time and calls \c delete on them:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 4
+ \snippet code/src_corelib_tools_qlistdata.cpp 4
Inserting and removing items at either ends of the list is very
fast (\l{constant time} in most cases), because QList
@@ -427,7 +427,7 @@ void **QListData::erase(void **xi)
backward. Both return the index of a matching item if they find
it; otherwise, they return -1. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 5
+ \snippet code/src_corelib_tools_qlistdata.cpp 5
If you simply want to check whether a list contains a particular
value, use contains(). If you want to find out how many times a
@@ -652,7 +652,7 @@ void **QListData::erase(void **xi)
Inserts \a value at the end of the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 6
+ \snippet code/src_corelib_tools_qlistdata.cpp 6
This is the same as list.insert(size(), \a value).
@@ -680,7 +680,7 @@ void **QListData::erase(void **xi)
Inserts \a value at the beginning of the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 7
+ \snippet code/src_corelib_tools_qlistdata.cpp 7
This is the same as list.insert(0, \a value).
@@ -698,7 +698,7 @@ void **QListData::erase(void **xi)
value is appended to the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 8
+ \snippet code/src_corelib_tools_qlistdata.cpp 8
\sa append(), prepend(), replace(), removeAt()
*/
@@ -729,7 +729,7 @@ void **QListData::erase(void **xi)
number of entries removed.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 9
+ \snippet code/src_corelib_tools_qlistdata.cpp 9
This function requires the value type to have an implementation of
\c operator==().
@@ -745,7 +745,7 @@ void **QListData::erase(void **xi)
true on success; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 10
+ \snippet code/src_corelib_tools_qlistdata.cpp 10
This function requires the value type to have an implementation of
\c operator==().
@@ -805,7 +805,7 @@ void **QListData::erase(void **xi)
Moves the item at index position \a from to index position \a to.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 11
+ \snippet code/src_corelib_tools_qlistdata.cpp 11
This is the same as insert(\a{to}, takeAt(\a{from})).This function
assumes that both \a from and \a to are at least 0 but less than
@@ -823,7 +823,7 @@ void **QListData::erase(void **xi)
\a i and \a j are at least 0 and less than size().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 12
+ \snippet code/src_corelib_tools_qlistdata.cpp 12
\sa move()
*/
@@ -835,7 +835,7 @@ void **QListData::erase(void **xi)
-1 if no item matched.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 13
+ \snippet code/src_corelib_tools_qlistdata.cpp 13
This function requires the value type to have an implementation of
\c operator==().
@@ -855,7 +855,7 @@ void **QListData::erase(void **xi)
Returns -1 if no item matched.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 14
+ \snippet code/src_corelib_tools_qlistdata.cpp 14
This function requires the value type to have an implementation of
\c operator==().
@@ -1237,14 +1237,14 @@ void **QListData::erase(void **xi)
start iterating. Here's a typical loop that prints all the items
stored in a list:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 15
+ \snippet code/src_corelib_tools_qlistdata.cpp 15
Let's see a few examples of things we can do with a
QList::iterator that we cannot do with a QList::const_iterator.
Here's an example that increments every value stored in a
QList\<int\> by 2:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 16
+ \snippet code/src_corelib_tools_qlistdata.cpp 16
Most QList functions accept an integer index rather than an
iterator. For that reason, iterators are rarely useful in
@@ -1254,7 +1254,7 @@ void **QListData::erase(void **xi)
For example, here's how to delete all the widgets stored in a
QList\<QWidget *\>:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 17
+ \snippet code/src_corelib_tools_qlistdata.cpp 17
Multiple iterators can be used on the same list. However, be
aware that any non-const function call performed on the QList
@@ -1299,7 +1299,7 @@ void **QListData::erase(void **xi)
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QList::begin() QList::end()
+ \sa QList::begin(), QList::end()
*/
/*! \fn QList::iterator::iterator(Node *node)
@@ -1319,7 +1319,7 @@ void **QListData::erase(void **xi)
You can change the value of an item by using operator*() on the
left side of an assignment, for example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 18
+ \snippet code/src_corelib_tools_qlistdata.cpp 18
\sa operator->()
*/
@@ -1493,7 +1493,7 @@ void **QListData::erase(void **xi)
QList::insert() before you can start iterating. Here's a typical
loop that prints all the items stored in a list:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 19
+ \snippet code/src_corelib_tools_qlistdata.cpp 19
Most QList functions accept an integer index rather than an
iterator. For that reason, iterators are rarely useful in
@@ -1503,7 +1503,7 @@ void **QListData::erase(void **xi)
For example, here's how to delete all the widgets stored in a
QList\<QWidget *\>:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 20
+ \snippet code/src_corelib_tools_qlistdata.cpp 20
Multiple iterators can be used on the same list. However, be
aware that any non-const function call performed on the QList
@@ -1522,7 +1522,7 @@ void **QListData::erase(void **xi)
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QList::constBegin() QList::constEnd()
+ \sa QList::constBegin(), QList::constEnd()
*/
/*! \typedef QList::const_iterator::iterator_category
@@ -1738,7 +1738,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 21
+ \snippet code/src_corelib_tools_qlistdata.cpp 21
\sa fromSet(), toVector(), QVector::toList()
*/
@@ -1749,7 +1749,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 22
+ \snippet code/src_corelib_tools_qlistdata.cpp 22
\sa toSet(), fromVector(), QVector::fromList()
*/
@@ -1761,7 +1761,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 23
+ \snippet code/src_corelib_tools_qlistdata.cpp 23
\sa fromVector(), toSet(), QSet::toList(), qSort()
*/
@@ -1774,7 +1774,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 24
+ \snippet code/src_corelib_tools_qlistdata.cpp 24
\sa toVector(), fromSet(), QSet::fromList()
*/
@@ -1786,7 +1786,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 25
+ \snippet code/src_corelib_tools_qlistdata.cpp 25
\sa toStdList(), QVector::fromStdVector()
*/
@@ -1796,7 +1796,7 @@ void **QListData::erase(void **xi)
Returns a std::list object with the data contained in this QList.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 26
+ \snippet code/src_corelib_tools_qlistdata.cpp 26
\sa fromStdList(), QVector::toStdVector()
*/
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index b9f199e50e..88667f7fbd 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -78,8 +78,8 @@ public:
};
Q_GLOBAL_STATIC(QSystemLocaleSingleton, QSystemLocale_globalSystemLocale)
-static QLocalePrivate *system_lp = 0;
-Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate)
+static QLocaleData *system_data = 0;
+Q_GLOBAL_STATIC(QLocaleData, globalLocaleData)
#endif
#ifdef QT_USE_ICU
@@ -157,12 +157,12 @@ QLocale::Country QLocalePrivate::codeToCountry(const QString &code)
QString QLocalePrivate::languageCode() const
{
- if (m_language_id == QLocale::AnyLanguage)
+ if (m_data->m_language_id == QLocale::AnyLanguage)
return QString();
- if (m_language_id == QLocale::C)
+ if (m_data->m_language_id == QLocale::C)
return QLatin1String("C");
- const unsigned char *c = language_code_list + 3*(uint(m_language_id));
+ const unsigned char *c = language_code_list + 3*(uint(m_data->m_language_id));
QString code(c[2] == 0 ? 2 : 3, Qt::Uninitialized);
@@ -176,18 +176,18 @@ QString QLocalePrivate::languageCode() const
QString QLocalePrivate::scriptCode() const
{
- if (m_script_id == QLocale::AnyScript || m_script_id > QLocale::LastScript)
+ if (m_data->m_script_id == QLocale::AnyScript || m_data->m_script_id > QLocale::LastScript)
return QString();
- const unsigned char *c = script_code_list + 4*(uint(m_script_id));
+ const unsigned char *c = script_code_list + 4*(uint(m_data->m_script_id));
return QString::fromLatin1((const char *)c, 4);
}
QString QLocalePrivate::countryCode() const
{
- if (m_country_id == QLocale::AnyCountry)
+ if (m_data->m_country_id == QLocale::AnyCountry)
return QString();
- const unsigned char *c = country_code_list + 3*(uint(m_country_id));
+ const unsigned char *c = country_code_list + 3*(uint(m_data->m_country_id));
QString code(c[2] == 0 ? 2 : 3, Qt::Uninitialized);
@@ -201,15 +201,15 @@ QString QLocalePrivate::countryCode() const
QString QLocalePrivate::bcp47Name() const
{
- if (m_language_id == QLocale::AnyLanguage)
+ if (m_data->m_language_id == QLocale::AnyLanguage)
return QString();
- if (m_language_id == QLocale::C)
+ if (m_data->m_language_id == QLocale::C)
return QLatin1String("C");
- const unsigned char *lang = language_code_list + 3*(uint(m_language_id));
+ const unsigned char *lang = language_code_list + 3*(uint(m_data->m_language_id));
const unsigned char *script =
- (m_script_id != QLocale::AnyScript ? script_code_list + 4*(uint(m_script_id)) : 0);
+ (m_data->m_script_id != QLocale::AnyScript ? script_code_list + 4*(uint(m_data->m_script_id)) : 0);
const unsigned char *country =
- (m_country_id != QLocale::AnyCountry ? country_code_list + 3*(uint(m_country_id)) : 0);
+ (m_data->m_country_id != QLocale::AnyCountry ? country_code_list + 3*(uint(m_data->m_country_id)) : 0);
char len = (lang[2] != 0 ? 3 : 2) + (script ? 4+1 : 0) + (country ? (country[2] != 0 ? 3 : 2)+1 : 0);
QString name(len, Qt::Uninitialized);
QChar *uc = name.data();
@@ -234,7 +234,7 @@ QString QLocalePrivate::bcp47Name() const
return name;
}
-const QLocalePrivate *QLocalePrivate::findLocale(QLocale::Language language, QLocale::Script script, QLocale::Country country)
+const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country)
{
const unsigned language_id = language;
const unsigned script_id = script;
@@ -242,33 +242,33 @@ const QLocalePrivate *QLocalePrivate::findLocale(QLocale::Language language, QLo
uint idx = locale_index[language_id];
- const QLocalePrivate *d = locale_data + idx;
+ const QLocaleData *data = locale_data + idx;
if (idx == 0) // default language has no associated country
- return d;
+ return data;
if (script == QLocale::AnyScript && country == QLocale::AnyCountry)
- return d;
+ return data;
- Q_ASSERT(d->languageId() == language_id);
+ Q_ASSERT(data->m_language_id == language_id);
if (country == QLocale::AnyCountry) {
- while (d->m_language_id == language_id && d->m_script_id != script_id)
- ++d;
- if (d->m_language_id == language_id && d->m_script_id == script_id)
- return d;
+ while (data->m_language_id == language_id && data->m_script_id != script_id)
+ ++data;
+ if (data->m_language_id == language_id && data->m_script_id == script_id)
+ return data;
} else if (script == QLocale::AnyScript) {
- while (d->m_language_id == language_id) {
- if (d->m_script_id == script_id && d->m_country_id == country_id)
- return d;
- ++d;
+ while (data->m_language_id == language_id) {
+ if (data->m_script_id == script_id && data->m_country_id == country_id)
+ return data;
+ ++data;
}
} else {
// both script and country are explicitly specified
- while (d->m_language_id == language_id) {
- if (d->m_script_id == script_id && d->m_country_id == country_id)
- return d;
- ++d;
+ while (data->m_language_id == language_id) {
+ if (data->m_script_id == script_id && data->m_country_id == country_id)
+ return data;
+ ++data;
}
}
@@ -370,14 +370,14 @@ void QLocalePrivate::getLangAndCountry(const QString &name, QLocale::Language &l
cntry = QLocalePrivate::codeToCountry(cntry_code);
}
-static const QLocalePrivate *findLocale(const QString &name)
+static const QLocaleData *findLocaleData(const QString &name)
{
QLocale::Language lang;
QLocale::Script script;
QLocale::Country cntry;
QLocalePrivate::getLangAndCountry(name, lang, script, cntry);
- return QLocalePrivate::findLocale(lang, script, cntry);
+ return QLocaleData::findLocaleData(lang, script, cntry);
}
QString qt_readEscapedFormatString(const QString &format, int *idx)
@@ -423,7 +423,7 @@ int qt_repeatCount(const QString &s, int i)
return j - i;
}
-static const QLocalePrivate *default_lp = 0;
+static const QLocaleData *default_data = 0;
static uint default_number_options = 0;
#ifndef QT_NO_SYSTEMLOCALE
@@ -443,8 +443,8 @@ QSystemLocale::QSystemLocale()
delete _systemLocale;
_systemLocale = this;
- if (system_lp)
- system_lp->m_language_id = 0;
+ if (system_data)
+ system_data->m_language_id = 0;
}
/*! \internal */
@@ -459,8 +459,8 @@ QSystemLocale::~QSystemLocale()
if (_systemLocale == this) {
_systemLocale = 0;
- if (system_lp)
- system_lp->m_language_id = 0;
+ if (system_data)
+ system_data->m_language_id = 0;
}
}
@@ -474,74 +474,74 @@ static const QSystemLocale *systemLocale()
void QLocalePrivate::updateSystemPrivate()
{
const QSystemLocale *sys_locale = systemLocale();
- if (!system_lp)
- system_lp = globalLocalePrivate();
+ if (!system_data)
+ system_data = globalLocaleData();
// tell the object that the system locale has changed.
sys_locale->query(QSystemLocale::LocaleChanged, QVariant());
- *system_lp = *sys_locale->fallbackLocale().d();
+ *system_data = *sys_locale->fallbackLocale().d->m_data;
QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant());
if (!res.isNull()) {
- system_lp->m_language_id = res.toInt();
- system_lp->m_script_id = QLocale::AnyScript; // default for compatibility
+ system_data->m_language_id = res.toInt();
+ system_data->m_script_id = QLocale::AnyScript; // default for compatibility
}
res = sys_locale->query(QSystemLocale::CountryId, QVariant());
if (!res.isNull()) {
- system_lp->m_country_id = res.toInt();
- system_lp->m_script_id = QLocale::AnyScript; // default for compatibility
+ system_data->m_country_id = res.toInt();
+ system_data->m_script_id = QLocale::AnyScript; // default for compatibility
}
res = sys_locale->query(QSystemLocale::ScriptId, QVariant());
if (!res.isNull())
- system_lp->m_script_id = res.toInt();
+ system_data->m_script_id = res.toInt();
res = sys_locale->query(QSystemLocale::DecimalPoint, QVariant());
if (!res.isNull())
- system_lp->m_decimal = res.toString().at(0).unicode();
+ system_data->m_decimal = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant());
if (!res.isNull())
- system_lp->m_group = res.toString().at(0).unicode();
+ system_data->m_group = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant());
if (!res.isNull())
- system_lp->m_zero = res.toString().at(0).unicode();
+ system_data->m_zero = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::NegativeSign, QVariant());
if (!res.isNull())
- system_lp->m_minus = res.toString().at(0).unicode();
+ system_data->m_minus = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::PositiveSign, QVariant());
if (!res.isNull())
- system_lp->m_plus = res.toString().at(0).unicode();
+ system_data->m_plus = res.toString().at(0).unicode();
#ifdef QT_USE_ICU
- if (!default_lp)
- qt_initIcu(system_lp->bcp47Name());
+ if (!default_data)
+ qt_initIcu(sys_locale->fallbackLocale().bcp47Name());
#endif
}
#endif
-static const QLocalePrivate *systemPrivate()
+static const QLocaleData *systemData()
{
#ifndef QT_NO_SYSTEMLOCALE
// copy over the information from the fallback locale and modify
- if (!system_lp || system_lp->m_language_id == 0)
+ if (!system_data || system_data->m_language_id == 0)
QLocalePrivate::updateSystemPrivate();
- return system_lp;
+ return system_data;
#else
return locale_data;
#endif
}
-static const QLocalePrivate *defaultPrivate()
+static const QLocaleData *defaultData()
{
- if (!default_lp)
- default_lp = systemPrivate();
- return default_lp;
+ if (!default_data)
+ default_data = systemData();
+ return default_data;
}
static QString getLocaleListData(const ushort *data, int size, int index)
@@ -585,14 +585,14 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
#endif // QT_NO_DATASTREAM
-static const int locale_data_size = sizeof(locale_data)/sizeof(QLocalePrivate) - 1;
+static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1;
-static const QLocalePrivate *dataPointerHelper(quint16 index)
+static const QLocaleData *dataPointerHelper(quint16 index)
{
#ifndef QT_NO_SYSTEMLOCALE
Q_ASSERT(index <= locale_data_size);
if (index == locale_data_size)
- return system_lp;
+ return system_data;
#else
Q_ASSERT(index < locale_data_size);
#endif
@@ -600,12 +600,12 @@ static const QLocalePrivate *dataPointerHelper(quint16 index)
return &locale_data[index];
}
-static quint16 localePrivateIndex(const QLocalePrivate *p)
+static quint16 localeDataIndex(const QLocaleData *p)
{
#ifndef QT_NO_SYSTEMLOCALE
Q_ASSERT((p >= locale_data && p - locale_data < locale_data_size)
- || (p != 0 && p == system_lp));
- quint16 index = p == system_lp ? locale_data_size : p - locale_data;
+ || (p != 0 && p == system_data));
+ quint16 index = p == system_data ? locale_data_size : p - locale_data;
#else
Q_ASSERT(p >= locale_data && p - locale_data < locale_data_size);
quint16 index = p - locale_data;
@@ -644,10 +644,11 @@ static quint16 localePrivateIndex(const QLocalePrivate *p)
*/
QLocale::QLocale(const QString &name)
- : v(0)
+ : d(new QLocalePrivate())
{
- p.numberOptions = 0;
- p.index = localePrivateIndex(findLocale(name));
+ d->m_numberOptions = 0;
+ d->m_index = localeDataIndex(findLocaleData(name));
+ d->m_data = dataPointerHelper(d->m_index);
}
/*!
@@ -659,10 +660,11 @@ QLocale::QLocale(const QString &name)
*/
QLocale::QLocale()
- : v(0)
+ : d(new QLocalePrivate())
{
- p.numberOptions = default_number_options;
- p.index = localePrivateIndex(defaultPrivate());
+ d->m_numberOptions = default_number_options;
+ d->m_index = localeDataIndex(defaultData());
+ d->m_data = dataPointerHelper(d->m_index);
}
/*!
@@ -681,22 +683,23 @@ QLocale::QLocale()
The language and country that are actually used can be queried
using language() and country().
- \sa setDefault() language() country()
+ \sa setDefault(), language(), country()
*/
QLocale::QLocale(Language language, Country country)
- : v(0)
+ : d(new QLocalePrivate())
{
- const QLocalePrivate *d = QLocalePrivate::findLocale(language, QLocale::AnyScript, country);
+ const QLocaleData *data = QLocaleData::findLocaleData(language, QLocale::AnyScript, country);
// If not found, should default to system
- if (d->languageId() == QLocale::C && language != QLocale::C) {
- p.numberOptions = default_number_options;
- p.index = localePrivateIndex(defaultPrivate());
+ if (data->m_language_id == QLocale::C && language != QLocale::C) {
+ d->m_numberOptions = default_number_options;
+ d->m_index = localeDataIndex(defaultData());
} else {
- p.numberOptions = 0;
- p.index = localePrivateIndex(d);
+ d->m_numberOptions = 0;
+ d->m_index = localeDataIndex(data);
}
+ d->m_data = dataPointerHelper(d->m_index);
}
\
/*!
@@ -720,22 +723,23 @@ QLocale::QLocale(Language language, Country country)
The language, script and country that are actually used can be queried
using language(), script() and country().
- \sa setDefault() language() script() country()
+ \sa setDefault(), language(), script(), country()
*/
QLocale::QLocale(Language language, Script script, Country country)
- : v(0)
+ : d(new QLocalePrivate())
{
- const QLocalePrivate *d = QLocalePrivate::findLocale(language, script, country);
+ const QLocaleData *data = QLocaleData::findLocaleData(language, script, country);
// If not found, should default to system
- if (d->languageId() == QLocale::C && language != QLocale::C) {
- p.numberOptions = default_number_options;
- p.index = localePrivateIndex(defaultPrivate());
+ if (data->m_language_id == QLocale::C && language != QLocale::C) {
+ d->m_numberOptions = default_number_options;
+ d->m_index = localeDataIndex(defaultData());
} else {
- p.numberOptions = 0;
- p.index = localePrivateIndex(d);
+ d->m_numberOptions = 0;
+ d->m_index = localeDataIndex(data);
}
+ d->m_data = dataPointerHelper(d->m_index);
}
/*!
@@ -744,12 +748,15 @@ QLocale::QLocale(Language language, Script script, Country country)
QLocale::QLocale(const QLocale &other)
{
- v = other.v;
+ d = other.d;
}
-const QLocalePrivate *QLocale::d() const
+/*!
+ Destructor
+*/
+
+QLocale::~QLocale()
{
- return dataPointerHelper(p.index);
}
/*!
@@ -759,18 +766,18 @@ const QLocalePrivate *QLocale::d() const
QLocale &QLocale::operator=(const QLocale &other)
{
- v = other.v;
+ d = other.d;
return *this;
}
bool QLocale::operator==(const QLocale &other) const
{
- return d() == other.d() && numberOptions() == other.numberOptions();
+ return d->m_data == other.d->m_data && d->m_numberOptions == other.d->m_numberOptions;
}
bool QLocale::operator!=(const QLocale &other) const
{
- return d() != other.d() || numberOptions() != other.numberOptions();
+ return d->m_data != other.d->m_data || d->m_numberOptions != other.d->m_numberOptions;
}
/*!
@@ -781,7 +788,7 @@ bool QLocale::operator!=(const QLocale &other) const
*/
void QLocale::setNumberOptions(NumberOptions options)
{
- p.numberOptions = options;
+ d->m_numberOptions = options;
}
/*!
@@ -794,7 +801,7 @@ void QLocale::setNumberOptions(NumberOptions options)
*/
QLocale::NumberOptions QLocale::numberOptions() const
{
- return static_cast<NumberOption>(p.numberOptions);
+ return static_cast<NumberOption>(d->m_numberOptions);
}
/*!
@@ -816,7 +823,7 @@ QString QLocale::quoteString(const QString &str, QuotationStyle style) const
QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res;
if (style == QLocale::AlternateQuotation)
res = systemLocale()->query(QSystemLocale::StringToAlternateQuotation, QVariant::fromValue(str));
@@ -828,9 +835,9 @@ QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const
#endif
if (style == QLocale::StandardQuotation)
- return QChar(d()->m_quotation_start) % str % QChar(d()->m_quotation_end);
+ return QChar(d->m_data->m_quotation_start) % str % QChar(d->m_data->m_quotation_end);
else
- return QChar(d()->m_alternate_quotation_start) % str % QChar(d()->m_alternate_quotation_end);
+ return QChar(d->m_data->m_alternate_quotation_start) % str % QChar(d->m_data->m_alternate_quotation_end);
}
/*!
@@ -842,7 +849,7 @@ QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const
QString QLocale::createSeparatedList(const QStringList &list) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res;
res = systemLocale()->query(QSystemLocale::ListToSeparatedString, QVariant::fromValue(list));
@@ -855,12 +862,12 @@ QString QLocale::createSeparatedList(const QStringList &list) const
if (size == 1) {
return list.at(0);
} else if (size == 2) {
- QString format = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_two_idx, d()->m_list_pattern_part_two_size);
+ QString format = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_two_idx, d->m_data->m_list_pattern_part_two_size);
return format.arg(list.at(0), list.at(1));
} else if (size > 2) {
- QString formatStart = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_start_idx, d()->m_list_pattern_part_start_size);
- QString formatMid = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_mid_idx, d()->m_list_pattern_part_mid_size);
- QString formatEnd = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_end_idx, d()->m_list_pattern_part_end_size);
+ QString formatStart = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_start_idx, d->m_data->m_list_pattern_part_start_size);
+ QString formatMid = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_mid_idx, d->m_data->m_list_pattern_part_mid_size);
+ QString formatEnd = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_end_idx, d->m_data->m_list_pattern_part_end_size);
QString result = formatStart.arg(list.at(0), list.at(1));
for (int i = 2; i < size - 1; ++i)
result = formatMid.arg(result, list.at(i));
@@ -883,12 +890,12 @@ QString QLocale::createSeparatedList(const QStringList &list) const
should be set at application startup, before any non-GUI threads
are created.
- \sa system() c()
+ \sa system(), c()
*/
void QLocale::setDefault(const QLocale &locale)
{
- default_lp = locale.d();
+ default_data = locale.d->m_data;
default_number_options = locale.numberOptions();
#ifdef QT_USE_ICU
@@ -903,7 +910,7 @@ void QLocale::setDefault(const QLocale &locale)
*/
QLocale::Language QLocale::language() const
{
- return Language(d()->languageId());
+ return Language(d->languageId());
}
/*!
@@ -915,7 +922,7 @@ QLocale::Language QLocale::language() const
*/
QLocale::Script QLocale::script() const
{
- return Script(d()->m_script_id);
+ return Script(d->m_data->m_script_id);
}
/*!
@@ -925,7 +932,7 @@ QLocale::Script QLocale::script() const
*/
QLocale::Country QLocale::country() const
{
- return Country(d()->countryId());
+ return Country(d->countryId());
}
/*!
@@ -945,7 +952,7 @@ QString QLocale::name() const
{
Language l = language();
- QString result = d()->languageCode();
+ QString result = d->languageCode();
if (l == C)
return result;
@@ -955,7 +962,7 @@ QString QLocale::name() const
return result;
result.append(QLatin1Char('_'));
- result.append(d()->countryCode());
+ result.append(d->countryCode());
return result;
}
@@ -976,7 +983,7 @@ QString QLocale::name() const
*/
QString QLocale::bcp47Name() const
{
- return d()->bcp47Name();
+ return d->bcp47Name();
}
/*!
@@ -1132,11 +1139,11 @@ uint QLocale::toUInt(const QString &s, bool *ok) const
qlonglong QLocale::toLongLong(const QString &s, bool *ok) const
{
QLocalePrivate::GroupSeparatorMode mode
- = p.numberOptions & RejectGroupSeparator
+ = d->m_numberOptions & RejectGroupSeparator
? QLocalePrivate::FailOnGroupSeparators
: QLocalePrivate::ParseGroupSeparators;
- return d()->stringToLongLong(s, 10, ok, mode);
+ return d->stringToLongLong(s, 10, ok, mode);
}
/*!
@@ -1156,11 +1163,11 @@ qlonglong QLocale::toLongLong(const QString &s, bool *ok) const
qulonglong QLocale::toULongLong(const QString &s, bool *ok) const
{
QLocalePrivate::GroupSeparatorMode mode
- = p.numberOptions & RejectGroupSeparator
+ = d->m_numberOptions & RejectGroupSeparator
? QLocalePrivate::FailOnGroupSeparators
: QLocalePrivate::ParseGroupSeparators;
- return d()->stringToUnsLongLong(s, 10, ok, mode);
+ return d->stringToUnsLongLong(s, 10, ok, mode);
}
/*!
@@ -1202,7 +1209,7 @@ float QLocale::toFloat(const QString &s, bool *ok) const
the "C" locale if the string cannot be interpreted in this
locale.
- \snippet doc/src/snippets/code/src_corelib_tools_qlocale.cpp 3
+ \snippet code/src_corelib_tools_qlocale.cpp 3
Notice that the last conversion returns 1234.0, because '.' is the
thousands group separator in the German locale.
@@ -1215,11 +1222,11 @@ float QLocale::toFloat(const QString &s, bool *ok) const
double QLocale::toDouble(const QString &s, bool *ok) const
{
QLocalePrivate::GroupSeparatorMode mode
- = p.numberOptions & RejectGroupSeparator
+ = d->m_numberOptions & RejectGroupSeparator
? QLocalePrivate::FailOnGroupSeparators
: QLocalePrivate::ParseGroupSeparators;
- return d()->stringToDouble(s, ok, mode);
+ return d->stringToDouble(s, ok, mode);
}
/*!
@@ -1230,11 +1237,11 @@ double QLocale::toDouble(const QString &s, bool *ok) const
QString QLocale::toString(qlonglong i) const
{
- int flags = p.numberOptions & OmitGroupSeparator
+ int flags = d->m_numberOptions & OmitGroupSeparator
? 0
: QLocalePrivate::ThousandsGroup;
- return d()->longLongToString(i, -1, 10, -1, flags);
+ return d->longLongToString(i, -1, 10, -1, flags);
}
/*!
@@ -1245,11 +1252,11 @@ QString QLocale::toString(qlonglong i) const
QString QLocale::toString(qulonglong i) const
{
- int flags = p.numberOptions & OmitGroupSeparator
+ int flags = d->m_numberOptions & OmitGroupSeparator
? 0
: QLocalePrivate::ThousandsGroup;
- return d()->unsLongLongToString(i, -1, 10, -1, flags);
+ return d->unsLongLongToString(i, -1, 10, -1, flags);
}
/*!
@@ -1260,7 +1267,7 @@ QString QLocale::toString(qulonglong i) const
QString QLocale::toString(const QDate &date, const QString &format) const
{
- return d()->dateTimeToString(format, &date, 0, this);
+ return d->dateTimeToString(format, &date, 0, this);
}
/*!
@@ -1274,7 +1281,7 @@ QString QLocale::toString(const QDate &date, FormatType format) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateToStringLong : QSystemLocale::DateToStringShort,
date);
@@ -1338,7 +1345,7 @@ static QString timeZone()
*/
QString QLocale::toString(const QTime &time, const QString &format) const
{
- return d()->dateTimeToString(format, 0, &time, this);
+ return d->dateTimeToString(format, 0, &time, this);
}
/*!
@@ -1353,7 +1360,7 @@ QString QLocale::toString(const QDateTime &dateTime, const QString &format) cons
{
const QDate dt = dateTime.date();
const QTime tm = dateTime.time();
- return d()->dateTimeToString(format, &dt, &tm, this);
+ return d->dateTimeToString(format, &dt, &tm, this);
}
/*!
@@ -1369,7 +1376,7 @@ QString QLocale::toString(const QDateTime &dateTime, FormatType format) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateTimeToStringLong
: QSystemLocale::DateTimeToStringShort,
@@ -1395,7 +1402,7 @@ QString QLocale::toString(const QTime &time, FormatType format) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::TimeToStringLong : QSystemLocale::TimeToStringShort,
time);
@@ -1422,7 +1429,7 @@ QString QLocale::toString(const QTime &time, FormatType format) const
QString QLocale::dateFormat(FormatType format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateFormatLong : QSystemLocale::DateFormatShort,
QVariant());
@@ -1434,12 +1441,12 @@ QString QLocale::dateFormat(FormatType format) const
quint32 idx, size;
switch (format) {
case LongFormat:
- idx = d()->m_long_date_format_idx;
- size = d()->m_long_date_format_size;
+ idx = d->m_data->m_long_date_format_idx;
+ size = d->m_data->m_long_date_format_size;
break;
default:
- idx = d()->m_short_date_format_idx;
- size = d()->m_short_date_format_size;
+ idx = d->m_data->m_short_date_format_idx;
+ size = d->m_data->m_short_date_format_size;
break;
}
return getLocaleData(date_format_data + idx, size);
@@ -1459,7 +1466,7 @@ QString QLocale::dateFormat(FormatType format) const
QString QLocale::timeFormat(FormatType format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::TimeFormatLong : QSystemLocale::TimeFormatShort,
QVariant());
@@ -1471,12 +1478,12 @@ QString QLocale::timeFormat(FormatType format) const
quint32 idx, size;
switch (format) {
case LongFormat:
- idx = d()->m_long_time_format_idx;
- size = d()->m_long_time_format_size;
+ idx = d->m_data->m_long_time_format_idx;
+ size = d->m_data->m_long_time_format_size;
break;
default:
- idx = d()->m_short_time_format_idx;
- size = d()->m_short_time_format_size;
+ idx = d->m_data->m_short_time_format_idx;
+ size = d->m_data->m_short_time_format_size;
break;
}
return getLocaleData(time_format_data + idx, size);
@@ -1496,7 +1503,7 @@ QString QLocale::timeFormat(FormatType format) const
QString QLocale::dateTimeFormat(FormatType format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateTimeFormatLong
: QSystemLocale::DateTimeFormatShort,
@@ -1664,7 +1671,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format) cons
*/
QChar QLocale::decimalPoint() const
{
- return d()->decimal();
+ return d->decimal();
}
/*!
@@ -1674,7 +1681,7 @@ QChar QLocale::decimalPoint() const
*/
QChar QLocale::groupSeparator() const
{
- return d()->group();
+ return d->group();
}
/*!
@@ -1684,7 +1691,7 @@ QChar QLocale::groupSeparator() const
*/
QChar QLocale::percent() const
{
- return d()->percent();
+ return d->percent();
}
/*!
@@ -1694,7 +1701,7 @@ QChar QLocale::percent() const
*/
QChar QLocale::zeroDigit() const
{
- return d()->zero();
+ return d->zero();
}
/*!
@@ -1704,7 +1711,7 @@ QChar QLocale::zeroDigit() const
*/
QChar QLocale::negativeSign() const
{
- return d()->minus();
+ return d->minus();
}
/*!
@@ -1714,7 +1721,7 @@ QChar QLocale::negativeSign() const
*/
QChar QLocale::positiveSign() const
{
- return d()->plus();
+ return d->plus();
}
/*!
@@ -1724,7 +1731,7 @@ QChar QLocale::positiveSign() const
*/
QChar QLocale::exponential() const
{
- return d()->exponential();
+ return d->exponential();
}
static bool qIsUpper(char c)
@@ -1771,9 +1778,9 @@ QString QLocale::toString(double i, char f, int prec) const
break;
}
- if (!(p.numberOptions & OmitGroupSeparator))
+ if (!(d->m_numberOptions & OmitGroupSeparator))
flags |= QLocalePrivate::ThousandsGroup;
- return d()->doubleToString(i, prec, form, -1, flags);
+ return d->doubleToString(i, prec, form, -1, flags);
}
/*!
@@ -1796,7 +1803,8 @@ QString QLocale::toString(double i, char f, int prec) const
QLocale QLocale::system()
{
QLocale result(C);
- result.p.index = localePrivateIndex(systemPrivate());
+ result.d->m_index = localeDataIndex(systemData());
+ result.d->m_data = dataPointerHelper(result.d->m_index);
return result;
}
@@ -1819,17 +1827,18 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
return QList<QLocale>();
QList<QLocale> result;
- const QLocalePrivate *d = locale_data;
+ const QLocaleData *data = locale_data;
if (language == QLocale::AnyLanguage && script == QLocale::AnyScript && country == QLocale::AnyCountry)
result.reserve(locale_data_size);
if (language != QLocale::C)
- d += locale_index[language];
- while ( (d != locale_data + locale_data_size)
- && (language == QLocale::AnyLanguage || d->m_language_id == uint(language))) {
+ data += locale_index[language];
+ while ( (data != locale_data + locale_data_size)
+ && (language == QLocale::AnyLanguage || data->m_language_id == uint(language))) {
QLocale locale(QLocale::C);
- locale.p.index = localePrivateIndex(d);
+ locale.d->m_index = localeDataIndex(data);
+ locale.d->m_data = dataPointerHelper(locale.d->m_index);
result.append(locale);
- ++d;
+ ++data;
}
return result;
}
@@ -1856,11 +1865,11 @@ QList<QLocale::Country> QLocale::countriesForLanguage(Language language)
return result;
}
- const QLocalePrivate *d = locale_data + idx;
+ const QLocaleData *data = locale_data + idx;
- while (d->languageId() == language_id) {
- result << static_cast<Country>(d->countryId());
- ++d;
+ while (data->m_language_id == language_id) {
+ result << static_cast<Country>(data->m_country_id);
+ ++data;
}
return result;
@@ -1880,7 +1889,7 @@ QString QLocale::monthName(int month, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort,
month);
@@ -1892,16 +1901,16 @@ QString QLocale::monthName(int month, FormatType type) const
quint32 idx, size;
switch (type) {
case QLocale::LongFormat:
- idx = d()->m_long_month_names_idx;
- size = d()->m_long_month_names_size;
+ idx = d->m_data->m_long_month_names_idx;
+ size = d->m_data->m_long_month_names_size;
break;
case QLocale::ShortFormat:
- idx = d()->m_short_month_names_idx;
- size = d()->m_short_month_names_size;
+ idx = d->m_data->m_short_month_names_idx;
+ size = d->m_data->m_short_month_names_size;
break;
case QLocale::NarrowFormat:
- idx = d()->m_narrow_month_names_idx;
- size = d()->m_narrow_month_names_size;
+ idx = d->m_data->m_narrow_month_names_idx;
+ size = d->m_data->m_narrow_month_names_size;
break;
default:
return QString();
@@ -1926,7 +1935,7 @@ QString QLocale::standaloneMonthName(int month, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort,
month);
@@ -1938,16 +1947,16 @@ QString QLocale::standaloneMonthName(int month, FormatType type) const
quint32 idx, size;
switch (type) {
case QLocale::LongFormat:
- idx = d()->m_standalone_long_month_names_idx;
- size = d()->m_standalone_long_month_names_size;
+ idx = d->m_data->m_standalone_long_month_names_idx;
+ size = d->m_data->m_standalone_long_month_names_size;
break;
case QLocale::ShortFormat:
- idx = d()->m_standalone_short_month_names_idx;
- size = d()->m_standalone_short_month_names_size;
+ idx = d->m_data->m_standalone_short_month_names_idx;
+ size = d->m_data->m_standalone_short_month_names_size;
break;
case QLocale::NarrowFormat:
- idx = d()->m_standalone_narrow_month_names_idx;
- size = d()->m_standalone_narrow_month_names_size;
+ idx = d->m_data->m_standalone_narrow_month_names_idx;
+ size = d->m_data->m_standalone_narrow_month_names_size;
break;
default:
return QString();
@@ -1973,7 +1982,7 @@ QString QLocale::dayName(int day, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort,
day);
@@ -1987,16 +1996,16 @@ QString QLocale::dayName(int day, FormatType type) const
quint32 idx, size;
switch (type) {
case QLocale::LongFormat:
- idx = d()->m_long_day_names_idx;
- size = d()->m_long_day_names_size;
+ idx = d->m_data->m_long_day_names_idx;
+ size = d->m_data->m_long_day_names_size;
break;
case QLocale::ShortFormat:
- idx = d()->m_short_day_names_idx;
- size = d()->m_short_day_names_size;
+ idx = d->m_data->m_short_day_names_idx;
+ size = d->m_data->m_short_day_names_size;
break;
case QLocale::NarrowFormat:
- idx = d()->m_narrow_day_names_idx;
- size = d()->m_narrow_day_names_size;
+ idx = d->m_data->m_narrow_day_names_idx;
+ size = d->m_data->m_narrow_day_names_size;
break;
default:
return QString();
@@ -2022,7 +2031,7 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort,
day);
@@ -2036,16 +2045,16 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
quint32 idx, size;
switch (type) {
case QLocale::LongFormat:
- idx = d()->m_standalone_long_day_names_idx;
- size = d()->m_standalone_long_day_names_size;
+ idx = d->m_data->m_standalone_long_day_names_idx;
+ size = d->m_data->m_standalone_long_day_names_size;
break;
case QLocale::ShortFormat:
- idx = d()->m_standalone_short_day_names_idx;
- size = d()->m_standalone_short_day_names_size;
+ idx = d->m_data->m_standalone_short_day_names_idx;
+ size = d->m_data->m_standalone_short_day_names_size;
break;
case QLocale::NarrowFormat:
- idx = d()->m_standalone_narrow_day_names_idx;
- size = d()->m_standalone_narrow_day_names_size;
+ idx = d->m_data->m_standalone_narrow_day_names_idx;
+ size = d->m_data->m_standalone_narrow_day_names_size;
break;
default:
return QString();
@@ -2064,20 +2073,20 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
Qt::DayOfWeek QLocale::firstDayOfWeek() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::FirstDayOfWeek, QVariant());
if (!res.isNull())
return static_cast<Qt::DayOfWeek>(res.toUInt());
}
#endif
- return static_cast<Qt::DayOfWeek>(d()->m_first_day_of_week);
+ return static_cast<Qt::DayOfWeek>(d->m_data->m_first_day_of_week);
}
QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const
{
for (int i = 0; i < ImperialMeasurementSystemsCount; ++i) {
- if (ImperialMeasurementSystems[i].languageId == m_language_id
- && ImperialMeasurementSystems[i].countryId == m_country_id) {
+ if (ImperialMeasurementSystems[i].languageId == m_data->m_language_id
+ && ImperialMeasurementSystems[i].countryId == m_data->m_country_id) {
return ImperialMeasurementSystems[i].system;
}
}
@@ -2092,15 +2101,15 @@ QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const
QList<Qt::DayOfWeek> QLocale::weekdays() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::Weekdays, QVariant());
if (!res.isNull())
return static_cast<QList<Qt::DayOfWeek> >(res.value<QList<Qt::DayOfWeek> >());
}
#endif
QList<Qt::DayOfWeek> weekdays;
- quint16 weekendStart = d()->m_weekend_start;
- quint16 weekendEnd = d()->m_weekend_end;
+ quint16 weekendStart = d->m_data->m_weekend_start;
+ quint16 weekendEnd = d->m_data->m_weekend_end;
for (int day = Qt::Monday; day <= Qt::Sunday; day++) {
if ((weekendEnd >= weekendStart && (day < weekendStart || day > weekendEnd)) ||
(weekendEnd < weekendStart && (day > weekendEnd && day < weekendStart)))
@@ -2117,14 +2126,14 @@ QList<Qt::DayOfWeek> QLocale::weekdays() const
QLocale::MeasurementSystem QLocale::measurementSystem() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::MeasurementSystem, QVariant());
if (!res.isNull())
return MeasurementSystem(res.toInt());
}
#endif
- return d()->measurementSystem();
+ return d->measurementSystem();
}
/*!
@@ -2193,13 +2202,13 @@ QString QLocale::toLower(const QString &str) const
QString QLocale::amText() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::AMText, QVariant());
if (!res.isNull())
return res.toString();
}
#endif
- return getLocaleData(am_data + d()->m_am_idx, d()->m_am_size);
+ return getLocaleData(am_data + d->m_data->m_am_idx, d->m_data->m_am_size);
}
/*!
@@ -2213,13 +2222,13 @@ QString QLocale::amText() const
QString QLocale::pmText() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::PMText, QVariant());
if (!res.isNull())
return res.toString();
}
#endif
- return getLocaleData(pm_data + d()->m_pm_idx, d()->m_pm_size);
+ return getLocaleData(pm_data + d->m_data->m_pm_idx, d->m_data->m_pm_size);
}
@@ -3098,7 +3107,7 @@ qulonglong QLocalePrivate::bytearrayToUnsLongLong(const char *num, int base, boo
QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::CurrencySymbol, format);
if (!res.isNull())
return res.toString();
@@ -3107,20 +3116,20 @@ QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format) const
quint32 idx, size;
switch (format) {
case CurrencySymbol:
- idx = d()->m_currency_symbol_idx;
- size = d()->m_currency_symbol_size;
+ idx = d->m_data->m_currency_symbol_idx;
+ size = d->m_data->m_currency_symbol_size;
return getLocaleData(currency_symbol_data + idx, size);
case CurrencyDisplayName:
- idx = d()->m_currency_display_name_idx;
- size = d()->m_currency_display_name_size;
+ idx = d->m_data->m_currency_display_name_idx;
+ size = d->m_data->m_currency_display_name_size;
return getLocaleListData(currency_display_name_data + idx, size, 0);
case CurrencyIsoCode: {
int len = 0;
- const QLocalePrivate *d = this->d();
+ const QLocaleData *data = this->d->m_data;
for (; len < 3; ++len)
- if (!d->m_currency_iso_code[len])
+ if (!data->m_currency_iso_code[len])
break;
- return len ? QString::fromLatin1(d->m_currency_iso_code, len) : QString();
+ return len ? QString::fromLatin1(data->m_currency_iso_code, len) : QString();
}
}
return QString();
@@ -3137,19 +3146,19 @@ QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format) const
QString QLocale::toCurrencyString(qlonglong value, const QString &symbol) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QSystemLocale::CurrencyToStringArgument arg(value, symbol);
QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
if (!res.isNull())
return res.toString();
}
#endif
- const QLocalePrivate *d = this->d();
- quint8 idx = d->m_currency_format_idx;
- quint8 size = d->m_currency_format_size;
- if (d->m_currency_negative_format_size && value < 0) {
- idx = d->m_currency_negative_format_idx;
- size = d->m_currency_negative_format_size;
+ const QLocalePrivate *d = this->d;
+ quint8 idx = d->m_data->m_currency_format_idx;
+ quint8 size = d->m_data->m_currency_format_size;
+ if (d->m_data->m_currency_negative_format_size && value < 0) {
+ idx = d->m_data->m_currency_negative_format_idx;
+ size = d->m_data->m_currency_negative_format_size;
value = -value;
}
QString str = d->longLongToString(value);
@@ -3167,16 +3176,16 @@ QString QLocale::toCurrencyString(qlonglong value, const QString &symbol) const
QString QLocale::toCurrencyString(qulonglong value, const QString &symbol) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QSystemLocale::CurrencyToStringArgument arg(value, symbol);
QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
if (!res.isNull())
return res.toString();
}
#endif
- const QLocalePrivate *d = this->d();
- quint8 idx = d->m_currency_format_idx;
- quint8 size = d->m_currency_format_size;
+ const QLocaleData *data = this->d->m_data;
+ quint8 idx = data->m_currency_format_idx;
+ quint8 size = data->m_currency_format_size;
QString str = d->unsLongLongToString(value);
QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty())
@@ -3192,22 +3201,22 @@ QString QLocale::toCurrencyString(qulonglong value, const QString &symbol) const
QString QLocale::toCurrencyString(double value, const QString &symbol) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QSystemLocale::CurrencyToStringArgument arg(value, symbol);
QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
if (!res.isNull())
return res.toString();
}
#endif
- const QLocalePrivate *d = this->d();
- quint8 idx = d->m_currency_format_idx;
- quint8 size = d->m_currency_format_size;
- if (d->m_currency_negative_format_size && value < 0) {
- idx = d->m_currency_negative_format_idx;
- size = d->m_currency_negative_format_size;
+ const QLocaleData *data = this->d->m_data;
+ quint8 idx = data->m_currency_format_idx;
+ quint8 size = data->m_currency_format_size;
+ if (data->m_currency_negative_format_size && value < 0) {
+ idx = data->m_currency_negative_format_idx;
+ size = data->m_currency_negative_format_size;
value = -value;
}
- QString str = d->doubleToString(value, d->m_currency_digits,
+ QString str = d->doubleToString(value, d->m_data->m_currency_digits,
QLocalePrivate::DFDecimal);
QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty())
@@ -3235,7 +3244,7 @@ QString QLocale::toCurrencyString(double value, const QString &symbol) const
QStringList QLocale::uiLanguages() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::UILanguages, QVariant());
if (!res.isNull()) {
QStringList result = res.toStringList();
@@ -3258,13 +3267,13 @@ QStringList QLocale::uiLanguages() const
QString QLocale::nativeLanguageName() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::NativeLanguageName, QVariant());
if (!res.isNull())
return res.toString();
}
#endif
- return getLocaleData(endonyms_data + d()->m_language_endonym_idx, d()->m_language_endonym_size);
+ return getLocaleData(endonyms_data + d->m_data->m_language_endonym_idx, d->m_data->m_language_endonym_size);
}
/*!
@@ -3278,13 +3287,13 @@ QString QLocale::nativeLanguageName() const
QString QLocale::nativeCountryName() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::NativeCountryName, QVariant());
if (!res.isNull())
return res.toString();
}
#endif
- return getLocaleData(endonyms_data + d()->m_country_endonym_idx, d()->m_country_endonym_size);
+ return getLocaleData(endonyms_data + d->m_data->m_country_endonym_idx, d->m_data->m_country_endonym_size);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index bdb5ae026c..a014b6b7b5 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -45,6 +45,7 @@
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
#include <QtCore/qobjectdefs.h>
+#include <QtCore/qshareddata.h>
QT_BEGIN_HEADER
@@ -59,9 +60,8 @@ class QVariant;
class QTextStream;
class QTextStreamPrivate;
-class QLocale;
+class QLocalePrivate;
-struct QLocalePrivate;
class Q_CORE_EXPORT QLocale
{
Q_GADGET
@@ -590,6 +590,7 @@ public:
QLocale(Language language, Country country = AnyCountry);
QLocale(Language language, Script script, Country country);
QLocale(const QLocale &other);
+ ~QLocale();
QLocale &operator=(const QLocale &other);
@@ -700,20 +701,10 @@ public:
QString quoteString(const QStringRef &str, QuotationStyle style = StandardQuotation) const;
QString createSeparatedList(const QStringList &strl) const;
-//private: // this should be private, but can't be
- struct Data {
- quint16 index;
- quint16 numberOptions;
- };
+
private:
- friend struct QLocalePrivate;
- // ### We now use this field to pack an index into locale_data and NumberOptions.
- // ### Qt 5: change to a QLocaleData *d; uint numberOptions.
- union {
- void *v;
- Data p;
- };
- const QLocalePrivate *d() const;
+ friend class QLocalePrivate;
+ QSharedDataPointer<QLocalePrivate> d;
};
Q_DECLARE_TYPEINFO(QLocale, Q_MOVABLE_TYPE);
Q_DECLARE_OPERATORS_FOR_FLAGS(QLocale::NumberOptions)
diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc
index 32822c2e6e..ed80984de3 100644
--- a/src/corelib/tools/qlocale.qdoc
+++ b/src/corelib/tools/qlocale.qdoc
@@ -42,7 +42,7 @@
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlocale.cpp 0
+ \snippet code/src_corelib_tools_qlocale.cpp 0
QLocale supports the concept of a default locale, which is
determined from the system's locale settings at application
@@ -63,7 +63,7 @@
The following example illustrates how to use QLocale directly:
- \snippet doc/src/snippets/code/src_corelib_tools_qlocale.cpp 1
+ \snippet code/src_corelib_tools_qlocale.cpp 1
When a language/country pair is specified in the constructor, one
of three things can happen:
@@ -83,7 +83,7 @@
An alternative method for constructing a QLocale object is by
specifying the locale name.
- \snippet doc/src/snippets/code/src_corelib_tools_qlocale.cpp 2
+ \snippet code/src_corelib_tools_qlocale.cpp 2
This constructor converts the locale name to a language/country
pair; it does not use the system locale database.
@@ -662,7 +662,7 @@
will fail if they encounter group separators in their input. The default
is to accept numbers containing correctly placed group separators.
- \sa setNumberOptions() numberOptions()
+ \sa setNumberOptions(), numberOptions()
*/
/*!
diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/tools/qlocale_data_p.h
index aa63bb75ec..ffade8fcda 100644
--- a/src/corelib/tools/qlocale_data_p.h
+++ b/src/corelib/tools/qlocale_data_p.h
@@ -306,7 +306,7 @@ static const quint16 locale_index[] = {
0 // trailing 0
};
-static const QLocalePrivate locale_data[] = {
+static const QLocaleData locale_data[] = {
// lang script terr dec group list prcnt zero minus plus exp quotStart quotEnd altQuotStart altQuotEnd lpStart lpMid lpEnd lpTwo sDtFmt lDtFmt sTmFmt lTmFmt ssMonth slMonth sMonth lMonth sDays lDays am,len pm,len
{ 1, 0, 0, 46, 44, 59, 37, 48, 45, 43, 101, 34, 34, 39, 39, 0,6 , 0,6 , 0,6 , 0,6 , 0,10 , 10,17 , 0,8 , 8,10 , 0,48 , 48,86 , 134,24 , 0,48 , 48,86 , 158,27 , 0,28 , 28,57 , 85,14 , 0,28 , 28,57 , 99,14 , 0,2 , 0,2 , {0,0,0}, 0,0 , 0,7 , 0,4 , 4,0 , 0,0 , 0,0 , 2, 1, 1, 6, 7 }, // C/AnyScript/AnyCountry
{ 3, 0, 69, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 27,8 , 35,18 , 18,7 , 25,12 , 185,48 , 233,111 , 134,24 , 185,48 , 233,111 , 134,24 , 113,28 , 141,55 , 85,14 , 113,28 , 141,55 , 85,14 , 2,2 , 2,2 , {69,84,66}, 0,2 , 7,24 , 4,4 , 4,0 , 0,6 , 6,10 , 2, 1, 6, 6, 7 }, // Afan/AnyScript/Ethiopia
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index 377a60881f..673135587b 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -126,20 +126,71 @@ private:
};
#endif
-struct Q_CORE_EXPORT QLocalePrivate
+struct QLocaleData
{
public:
- QChar decimal() const { return QChar(m_decimal); }
- QChar group() const { return QChar(m_group); }
- QChar list() const { return QChar(m_list); }
- QChar percent() const { return QChar(m_percent); }
- QChar zero() const { return QChar(m_zero); }
- QChar plus() const { return QChar(m_plus); }
- QChar minus() const { return QChar(m_minus); }
- QChar exponential() const { return QChar(m_exponential); }
-
- quint16 languageId() const { return m_language_id; }
- quint16 countryId() const { return m_country_id; }
+ static const QLocaleData *findLocaleData(QLocale::Language language,
+ QLocale::Script script,
+ QLocale::Country country);
+
+ quint16 m_language_id, m_script_id, m_country_id;
+
+ quint16 m_decimal, m_group, m_list, m_percent, m_zero, m_minus, m_plus, m_exponential;
+ quint16 m_quotation_start, m_quotation_end;
+ quint16 m_alternate_quotation_start, m_alternate_quotation_end;
+
+ quint16 m_list_pattern_part_start_idx, m_list_pattern_part_start_size;
+ quint16 m_list_pattern_part_mid_idx, m_list_pattern_part_mid_size;
+ quint16 m_list_pattern_part_end_idx, m_list_pattern_part_end_size;
+ quint16 m_list_pattern_part_two_idx, m_list_pattern_part_two_size;
+ quint16 m_short_date_format_idx, m_short_date_format_size;
+ quint16 m_long_date_format_idx, m_long_date_format_size;
+ quint16 m_short_time_format_idx, m_short_time_format_size;
+ quint16 m_long_time_format_idx, m_long_time_format_size;
+ quint16 m_standalone_short_month_names_idx, m_standalone_short_month_names_size;
+ quint16 m_standalone_long_month_names_idx, m_standalone_long_month_names_size;
+ quint16 m_standalone_narrow_month_names_idx, m_standalone_narrow_month_names_size;
+ quint16 m_short_month_names_idx, m_short_month_names_size;
+ quint16 m_long_month_names_idx, m_long_month_names_size;
+ quint16 m_narrow_month_names_idx, m_narrow_month_names_size;
+ quint16 m_standalone_short_day_names_idx, m_standalone_short_day_names_size;
+ quint16 m_standalone_long_day_names_idx, m_standalone_long_day_names_size;
+ quint16 m_standalone_narrow_day_names_idx, m_standalone_narrow_day_names_size;
+ quint16 m_short_day_names_idx, m_short_day_names_size;
+ quint16 m_long_day_names_idx, m_long_day_names_size;
+ quint16 m_narrow_day_names_idx, m_narrow_day_names_size;
+ quint16 m_am_idx, m_am_size;
+ quint16 m_pm_idx, m_pm_size;
+ char m_currency_iso_code[3];
+ quint16 m_currency_symbol_idx, m_currency_symbol_size;
+ quint16 m_currency_display_name_idx, m_currency_display_name_size;
+ quint8 m_currency_format_idx, m_currency_format_size;
+ quint8 m_currency_negative_format_idx, m_currency_negative_format_size;
+ quint16 m_language_endonym_idx, m_language_endonym_size;
+ quint16 m_country_endonym_idx, m_country_endonym_size;
+ quint16 m_currency_digits : 2;
+ quint16 m_currency_rounding : 3;
+ quint16 m_first_day_of_week : 3;
+ quint16 m_weekend_start : 3;
+ quint16 m_weekend_end : 3;
+};
+
+class Q_CORE_EXPORT QLocalePrivate : public QSharedData
+{
+public:
+ QLocalePrivate() : m_index(0), m_numberOptions(0), m_data(0) {}
+
+ QChar decimal() const { return QChar(m_data->m_decimal); }
+ QChar group() const { return QChar(m_data->m_group); }
+ QChar list() const { return QChar(m_data->m_list); }
+ QChar percent() const { return QChar(m_data->m_percent); }
+ QChar zero() const { return QChar(m_data->m_zero); }
+ QChar plus() const { return QChar(m_data->m_plus); }
+ QChar minus() const { return QChar(m_data->m_minus); }
+ QChar exponential() const { return QChar(m_data->m_exponential); }
+
+ quint16 languageId() const { return m_data->m_language_id; }
+ quint16 countryId() const { return m_data->m_country_id; }
QString bcp47Name() const;
@@ -152,10 +203,6 @@ public:
static QLocale::Country codeToCountry(const QString &code);
static void getLangAndCountry(const QString &name, QLocale::Language &lang,
QLocale::Script &script, QLocale::Country &cntry);
- static const QLocalePrivate *findLocale(QLocale::Language language,
- QLocale::Script script,
- QLocale::Country country);
-
QLocale::MeasurementSystem measurementSystem() const;
@@ -238,48 +285,11 @@ public:
QString dateTimeToString(const QString &format, const QDate *date, const QTime *time,
const QLocale *q) const;
- quint16 m_language_id, m_script_id, m_country_id;
-
- quint16 m_decimal, m_group, m_list, m_percent,
- m_zero, m_minus, m_plus, m_exponential;
- quint16 m_quotation_start, m_quotation_end;
- quint16 m_alternate_quotation_start, m_alternate_quotation_end;
-
- quint16 m_list_pattern_part_start_idx, m_list_pattern_part_start_size;
- quint16 m_list_pattern_part_mid_idx, m_list_pattern_part_mid_size;
- quint16 m_list_pattern_part_end_idx, m_list_pattern_part_end_size;
- quint16 m_list_pattern_part_two_idx, m_list_pattern_part_two_size;
- quint16 m_short_date_format_idx, m_short_date_format_size;
- quint16 m_long_date_format_idx, m_long_date_format_size;
- quint16 m_short_time_format_idx, m_short_time_format_size;
- quint16 m_long_time_format_idx, m_long_time_format_size;
- quint16 m_standalone_short_month_names_idx, m_standalone_short_month_names_size;
- quint16 m_standalone_long_month_names_idx, m_standalone_long_month_names_size;
- quint16 m_standalone_narrow_month_names_idx, m_standalone_narrow_month_names_size;
- quint16 m_short_month_names_idx, m_short_month_names_size;
- quint16 m_long_month_names_idx, m_long_month_names_size;
- quint16 m_narrow_month_names_idx, m_narrow_month_names_size;
- quint16 m_standalone_short_day_names_idx, m_standalone_short_day_names_size;
- quint16 m_standalone_long_day_names_idx, m_standalone_long_day_names_size;
- quint16 m_standalone_narrow_day_names_idx, m_standalone_narrow_day_names_size;
- quint16 m_short_day_names_idx, m_short_day_names_size;
- quint16 m_long_day_names_idx, m_long_day_names_size;
- quint16 m_narrow_day_names_idx, m_narrow_day_names_size;
- quint16 m_am_idx, m_am_size;
- quint16 m_pm_idx, m_pm_size;
- char m_currency_iso_code[3];
- quint16 m_currency_symbol_idx, m_currency_symbol_size;
- quint16 m_currency_display_name_idx, m_currency_display_name_size;
- quint8 m_currency_format_idx, m_currency_format_size;
- quint8 m_currency_negative_format_idx, m_currency_negative_format_size;
- quint16 m_language_endonym_idx, m_language_endonym_size;
- quint16 m_country_endonym_idx, m_country_endonym_size;
- quint16 m_currency_digits : 2;
- quint16 m_currency_rounding : 3;
- quint16 m_first_day_of_week : 3;
- quint16 m_weekend_start : 3;
- quint16 m_weekend_end : 3;
-
+private:
+ friend class QLocale;
+ quint16 m_index;
+ quint16 m_numberOptions;
+ const QLocaleData *m_data;
};
inline char QLocalePrivate::digitToCLocale(QChar in) const
diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp
index e88c511ae9..5f7a9da95d 100644
--- a/src/corelib/tools/qlocale_unix.cpp
+++ b/src/corelib/tools/qlocale_unix.cpp
@@ -244,6 +244,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
return lc_messages.createSeparatedList(in.value<QStringList>());
case LocaleChanged:
Q_ASSERT(false);
+ case LanguageId:
+ return lc_messages.language();
default:
break;
}
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 90521d343c..8002e7c1f0 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -388,21 +388,21 @@ void QMapDataBase::freeData(QMapDataBase *d)
\endlist
Here's an example QMap with QString keys and \c int values:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 0
+ \snippet code/src_corelib_tools_qmap.cpp 0
To insert a (key, value) pair into the map, you can use operator[]():
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 1
+ \snippet code/src_corelib_tools_qmap.cpp 1
This inserts the following three (key, value) pairs into the
QMap: ("one", 1), ("three", 3), and ("seven", 7). Another way to
insert items into the map is to use insert():
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 2
+ \snippet code/src_corelib_tools_qmap.cpp 2
To look up a value, use operator[]() or value():
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 3
+ \snippet code/src_corelib_tools_qmap.cpp 3
If there is no item with the specified key in the map, these
functions return a \l{default-constructed value}.
@@ -410,12 +410,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
If you want to check whether the map contains a certain key, use
contains():
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 4
+ \snippet code/src_corelib_tools_qmap.cpp 4
There is also a value() overload that uses its second argument as
a default value if there is no item with the specified key:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 5
+ \snippet code/src_corelib_tools_qmap.cpp 5
In general, we recommend that you use contains() and value()
rather than operator[]() for looking up a key in a map. The
@@ -424,7 +424,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
const). For example, the following code snippet will create 1000
items in memory:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 6
+ \snippet code/src_corelib_tools_qmap.cpp 6
To avoid this problem, replace \c map[i] with \c map.value(i)
in the code above.
@@ -436,11 +436,11 @@ void QMapDataBase::freeData(QMapDataBase *d)
QMap::iterator). Here's how to iterate over a QMap<QString, int>
using a Java-style iterator:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 7
+ \snippet code/src_corelib_tools_qmap.cpp 7
Here's the same code, but using an STL-style iterator this time:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 8
+ \snippet code/src_corelib_tools_qmap.cpp 8
The items are traversed in ascending key order.
@@ -448,7 +448,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
insert() with a key that already exists in the QMap, the
previous value will be erased. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 9
+ \snippet code/src_corelib_tools_qmap.cpp 9
However, you can store multiple values per key by using
insertMulti() instead of insert() (or using the convenience
@@ -456,19 +456,19 @@ void QMapDataBase::freeData(QMapDataBase *d)
single key, you can use values(const Key &key), which returns a
QList<T>:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 10
+ \snippet code/src_corelib_tools_qmap.cpp 10
The items that share the same key are available from most
recently to least recently inserted. Another approach is to call
find() to get the STL-style iterator for the first item with a
key and iterate from there:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 11
+ \snippet code/src_corelib_tools_qmap.cpp 11
If you only need to extract the values from a map (not the keys),
you can also use \l{foreach}:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 12
+ \snippet code/src_corelib_tools_qmap.cpp 12
Items can be removed from the map in several ways. One way is to
call remove(); this will remove any item with the given key.
@@ -484,7 +484,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
< y} nor \c{y < x} is true.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 13
+ \snippet code/src_corelib_tools_qmap.cpp 13
In the example, we start by comparing the employees' names. If
they're equal, we compare their dates of birth to break the tie.
@@ -881,7 +881,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
the iterator. For example, here's some code that iterates over all
the items with the same key:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 14
+ \snippet code/src_corelib_tools_qmap.cpp 14
\sa constFind(), value(), values(), lowerBound(), upperBound(), QMultiMap::find()
*/
@@ -911,7 +911,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
key.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 15
+ \snippet code/src_corelib_tools_qmap.cpp 15
If the map contains multiple items with key \a key, this
function returns an iterator that points to the most recently
@@ -919,7 +919,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
the iterator. For example, here's some code that iterates over all
the items with the same key:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 16
+ \snippet code/src_corelib_tools_qmap.cpp 16
\sa qLowerBound(), upperBound(), find()
*/
@@ -937,7 +937,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
nearest item with a greater key.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 17
+ \snippet code/src_corelib_tools_qmap.cpp 17
\sa qUpperBound(), lowerBound(), find()
*/
@@ -1042,7 +1042,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
start iterating. Here's a typical loop that prints all the (key,
value) pairs stored in a map:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 18
+ \snippet code/src_corelib_tools_qmap.cpp 18
Unlike QHash, which stores its items in an arbitrary order, QMap
stores its items ordered by key. Items that share the same key
@@ -1055,22 +1055,22 @@ void QMapDataBase::freeData(QMapDataBase *d)
Here's an example that increments every value stored in the QMap
by 2:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 19
+ \snippet code/src_corelib_tools_qmap.cpp 19
Here's an example that removes all the items whose key is a
string that starts with an underscore character:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 20
+ \snippet code/src_corelib_tools_qmap.cpp 20
The call to QMap::erase() removes the item pointed to by the
iterator from the map, and returns an iterator to the next item.
Here's another way of removing an item while iterating:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 21
+ \snippet code/src_corelib_tools_qmap.cpp 21
It might be tempting to write code like this:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 22
+ \snippet code/src_corelib_tools_qmap.cpp 22
However, this will potentially crash in \c{++i}, because \c i is
a dangling iterator after the call to erase().
@@ -1122,7 +1122,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QMap::begin() QMap::end()
+ \sa QMap::begin(), QMap::end()
*/
/*! \fn QMap::iterator::iterator(QMapData::Node *node)
@@ -1148,7 +1148,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
You can change the value of an item by using value() on
the left side of an assignment, for example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 23
+ \snippet code/src_corelib_tools_qmap.cpp 23
\sa key(), operator*()
*/
@@ -1289,7 +1289,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
QMap::find() before you can start iterating. Here's a typical
loop that prints all the (key, value) pairs stored in a map:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 24
+ \snippet code/src_corelib_tools_qmap.cpp 24
Unlike QHash, which stores its items in an arbitrary order, QMap
stores its items ordered by key. Items that share the same key
@@ -1344,7 +1344,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QMap::constBegin() QMap::constEnd()
+ \sa QMap::constBegin(), QMap::constEnd()
*/
/*! \fn QMap::const_iterator::const_iterator(QMapData::Node *node)
@@ -1530,7 +1530,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
operator+=().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 25
+ \snippet code/src_corelib_tools_qmap.cpp 25
Unlike QMap, QMultiMap provides no operator[]. Use value() or
replace() if you want to access the most recently inserted item
@@ -1539,7 +1539,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
If you want to retrieve all the values for a single key, you can
use values(const Key &key), which returns a QList<T>:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 26
+ \snippet code/src_corelib_tools_qmap.cpp 26
The items that share the same key are available from most
recently to least recently inserted.
@@ -1548,7 +1548,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
the iterator for the first item with a key and iterate from
there:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 27
+ \snippet code/src_corelib_tools_qmap.cpp 27
QMultiMap's key and value data types must be \l{assignable data
types}. This covers most data types you are likely to encounter,
diff --git a/src/corelib/tools/qpair.qdoc b/src/corelib/tools/qpair.qdoc
index fdf1eafc23..ddaf82497e 100644
--- a/src/corelib/tools/qpair.qdoc
+++ b/src/corelib/tools/qpair.qdoc
@@ -40,12 +40,12 @@
Here's an example of a QPair that stores one QString and one \c
double value:
- \snippet doc/src/snippets/code/doc_src_qpair.cpp 0
+ \snippet code/doc_src_qpair.cpp 0
The components are accessible as public data members called \l
first and \l second. For example:
- \snippet doc/src/snippets/code/doc_src_qpair.cpp 1
+ \snippet code/doc_src_qpair.cpp 1
QPair's template data types (T1 and T2) must be \l{assignable
data types}. You cannot, for example, store a QWidget as a value;
@@ -95,12 +95,6 @@
\sa qMakePair()
*/
-/*!
- \fn QPair<T1, T2> &QPair::operator=(const QPair<T1, T2> &other)
-
- Assigns \a other to this pair.
-*/
-
/*! \fn bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
\relates QPair
@@ -186,7 +180,7 @@
Returns a QPair\<T1, T2\> that contains \a value1 and \a value2.
Example:
- \snippet doc/src/snippets/code/doc_src_qpair.cpp 2
+ \snippet code/doc_src_qpair.cpp 2
This is equivalent to QPair<T1, T2>(\a value1, \a value2), but
usually requires less typing.
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index ecbe9deb9f..edc103f0b2 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
Given a point \e p, the following statements are all equivalent:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 0
+ \snippet code/src_corelib_tools_qpoint.cpp 0
A QPoint object can also be used as a vector: Addition and
subtraction are defined as for vectors (each component is added
@@ -126,7 +126,7 @@ QT_BEGIN_NAMESPACE
Sets the x coordinate of this point to the given \a x coordinate.
- \sa x() setY()
+ \sa x(), setY()
*/
/*!
@@ -134,7 +134,7 @@ QT_BEGIN_NAMESPACE
Sets the y coordinate of this point to the given \a y coordinate.
- \sa y() setX()
+ \sa y(), setX()
*/
@@ -145,9 +145,9 @@ QT_BEGIN_NAMESPACE
Using a reference makes it possible to directly manipulate x. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 1
+ \snippet code/src_corelib_tools_qpoint.cpp 1
- \sa x() setX()
+ \sa x(), setX()
*/
/*!
@@ -158,7 +158,7 @@ QT_BEGIN_NAMESPACE
Using a reference makes it possible to directly manipulate y. For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 2
+ \snippet code/src_corelib_tools_qpoint.cpp 2
\sa y(), setY()
*/
@@ -170,7 +170,7 @@ QT_BEGIN_NAMESPACE
Adds the given \a point to this point and returns a reference to
this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 3
+ \snippet code/src_corelib_tools_qpoint.cpp 3
\sa operator-=()
*/
@@ -181,7 +181,7 @@ QT_BEGIN_NAMESPACE
Subtracts the given \a point from this point and returns a
reference to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 4
+ \snippet code/src_corelib_tools_qpoint.cpp 4
\sa operator+=()
*/
@@ -204,7 +204,7 @@ QT_BEGIN_NAMESPACE
Multiplies this point's coordinates by the given \a factor, and
returns a reference to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 5
+ \snippet code/src_corelib_tools_qpoint.cpp 5
Note that the result is rounded to the nearest integer as points are held as
integers. Use QPointF for floating point accuracy.
@@ -331,7 +331,7 @@ QT_BEGIN_NAMESPACE
Divides both x and y by the given \a divisor, and returns a reference to this
point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 6
+ \snippet code/src_corelib_tools_qpoint.cpp 6
Note that the result is rounded to the nearest integer as points are held as
integers. Use QPointF for floating point accuracy.
@@ -408,12 +408,12 @@ QDataStream &operator>>(QDataStream &s, QPoint &p)
traditionally known as the "Manhattan length" of the vector from
the origin to the point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 7
+ \snippet code/src_corelib_tools_qpoint.cpp 7
This is a useful, and quick to calculate, approximation to the
true length:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 8
+ \snippet code/src_corelib_tools_qpoint.cpp 8
The tradition of "Manhattan length" arises because such distances
apply to travelers who can only travel on a rectangular grid, like
@@ -451,7 +451,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Given a point \e p, the following statements are all equivalent:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 9
+ \snippet code/src_corelib_tools_qpoint.cpp 9
A QPointF object can also be used as a vector: Addition and
subtraction are defined as for vectors (each component is added
@@ -534,7 +534,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Sets the x coordinate of this point to the given \a x coordinate.
- \sa x() setY()
+ \sa x(), setY()
*/
/*!
@@ -552,7 +552,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Using a reference makes it possible to directly manipulate x. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 10
+ \snippet code/src_corelib_tools_qpoint.cpp 10
\sa x(), setX()
*/
@@ -564,9 +564,9 @@ QDebug operator<<(QDebug d, const QPointF &p)
Using a reference makes it possible to directly manipulate y. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 11
+ \snippet code/src_corelib_tools_qpoint.cpp 11
- \sa y() setY()
+ \sa y(), setY()
*/
/*!
@@ -575,7 +575,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Adds the given \a point to this point and returns a reference to
this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 12
+ \snippet code/src_corelib_tools_qpoint.cpp 12
\sa operator-=()
*/
@@ -586,7 +586,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Subtracts the given \a point from this point and returns a reference
to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 13
+ \snippet code/src_corelib_tools_qpoint.cpp 13
\sa operator+=()
*/
@@ -597,7 +597,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Multiplies this point's coordinates by the given \a factor, and
returns a reference to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 14
+ \snippet code/src_corelib_tools_qpoint.cpp 14
\sa operator/=()
*/
@@ -608,7 +608,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Divides both x and y by the given \a divisor, and returns a reference
to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 15
+ \snippet code/src_corelib_tools_qpoint.cpp 15
\sa operator*=()
*/
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index 0eb22807e8..3b986cd81e 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -55,26 +55,26 @@ public:
Q_DECL_CONSTEXPR QPoint();
Q_DECL_CONSTEXPR QPoint(int xpos, int ypos);
- Q_DECL_CONSTEXPR bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isNull() const;
- Q_DECL_CONSTEXPR int x() const;
- Q_DECL_CONSTEXPR int y() const;
- void setX(int x);
- void setY(int y);
+ Q_DECL_CONSTEXPR inline int x() const;
+ Q_DECL_CONSTEXPR inline int y() const;
+ inline void setX(int x);
+ inline void setY(int y);
- Q_DECL_CONSTEXPR int manhattanLength() const;
+ Q_DECL_CONSTEXPR inline int manhattanLength() const;
- int &rx();
- int &ry();
+ inline int &rx();
+ inline int &ry();
- QPoint &operator+=(const QPoint &p);
- QPoint &operator-=(const QPoint &p);
+ inline QPoint &operator+=(const QPoint &p);
+ inline QPoint &operator-=(const QPoint &p);
- QPoint &operator*=(float c);
- QPoint &operator*=(double c);
- QPoint &operator*=(int c);
+ inline QPoint &operator*=(float c);
+ inline QPoint &operator*=(double c);
+ inline QPoint &operator*=(int c);
- QPoint &operator/=(qreal c);
+ inline QPoint &operator/=(qreal c);
friend Q_DECL_CONSTEXPR inline bool operator==(const QPoint &, const QPoint &);
friend Q_DECL_CONSTEXPR inline bool operator!=(const QPoint &, const QPoint &);
@@ -212,22 +212,22 @@ public:
Q_DECL_CONSTEXPR QPointF(const QPoint &p);
Q_DECL_CONSTEXPR QPointF(qreal xpos, qreal ypos);
- Q_DECL_CONSTEXPR qreal manhattanLength() const;
+ Q_DECL_CONSTEXPR inline qreal manhattanLength() const;
- bool isNull() const;
+ inline bool isNull() const;
- Q_DECL_CONSTEXPR qreal x() const;
- Q_DECL_CONSTEXPR qreal y() const;
- void setX(qreal x);
- void setY(qreal y);
+ Q_DECL_CONSTEXPR inline qreal x() const;
+ Q_DECL_CONSTEXPR inline qreal y() const;
+ inline void setX(qreal x);
+ inline void setY(qreal y);
- qreal &rx();
- qreal &ry();
+ inline qreal &rx();
+ inline qreal &ry();
- QPointF &operator+=(const QPointF &p);
- QPointF &operator-=(const QPointF &p);
- QPointF &operator*=(qreal c);
- QPointF &operator/=(qreal c);
+ inline QPointF &operator+=(const QPointF &p);
+ inline QPointF &operator-=(const QPointF &p);
+ inline QPointF &operator*=(qreal c);
+ inline QPointF &operator/=(qreal c);
friend Q_DECL_CONSTEXPR inline bool operator==(const QPointF &, const QPointF &);
friend Q_DECL_CONSTEXPR inline bool operator!=(const QPointF &, const QPointF &);
diff --git a/src/corelib/tools/qqueue.cpp b/src/corelib/tools/qqueue.cpp
index 06d996a542..c5aa4c6bad 100644
--- a/src/corelib/tools/qqueue.cpp
+++ b/src/corelib/tools/qqueue.cpp
@@ -57,7 +57,7 @@
the head item without removing it.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qqueue.cpp 0
+ \snippet code/src_corelib_tools_qqueue.cpp 0
The example will output 1, 2, 3 in that order.
diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp
index aeab97803d..8c1eea8df7 100644
--- a/src/corelib/tools/qrect.cpp
+++ b/src/corelib/tools/qrect.cpp
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
height integers, or from a QPoint and a QSize. The following code
creates two identical rectangles.
- \snippet doc/src/snippets/code/src_corelib_tools_qrect.cpp 0
+ \snippet code/src_corelib_tools_qrect.cpp 0
There is a third constructor that creates a QRect using the
top-left and bottom-right coordinates, but we recommend that you
@@ -640,16 +640,6 @@ QRect QRect::normalized() const
\sa center()
*/
-void QRect::moveCenter(const QPoint &p)
-{
- int w = x2 - x1;
- int h = y2 - y1;
- x1 = p.x() - w/2;
- y1 = p.y() - h/2;
- x2 = x1 + w;
- y2 = y1 + h;
-}
-
/*!
\fn void QRect::moveTo(int x, int y)
@@ -1243,7 +1233,7 @@ QDebug operator<<(QDebug dbg, const QRect &r) {
height integers, or from a QPoint and a QSize. The following code
creates two identical rectangles.
- \snippet doc/src/snippets/code/src_corelib_tools_qrect.cpp 1
+ \snippet code/src_corelib_tools_qrect.cpp 1
There is also a third constructor creating a QRectF from a QRect,
and a corresponding toRect() function that returns a QRect object
@@ -1791,7 +1781,7 @@ QRectF QRectF::normalized() const
\a y1), and the coordinates of its bottom-right corner to (\a x2,
\a y2).
- \sa getCoords() setRect()
+ \sa getCoords(), setRect()
*/
/*!
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index 4bf10061ab..ff318dbe6f 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -62,81 +62,81 @@ public:
Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QSize &size);
Q_DECL_CONSTEXPR QRect(int left, int top, int width, int height);
- Q_DECL_CONSTEXPR bool isNull() const;
- Q_DECL_CONSTEXPR bool isEmpty() const;
- Q_DECL_CONSTEXPR bool isValid() const;
-
- Q_DECL_CONSTEXPR int left() const;
- Q_DECL_CONSTEXPR int top() const;
- Q_DECL_CONSTEXPR int right() const;
- Q_DECL_CONSTEXPR int bottom() const;
+ Q_DECL_CONSTEXPR inline bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isEmpty() const;
+ Q_DECL_CONSTEXPR inline bool isValid() const;
+
+ Q_DECL_CONSTEXPR inline int left() const;
+ Q_DECL_CONSTEXPR inline int top() const;
+ Q_DECL_CONSTEXPR inline int right() const;
+ Q_DECL_CONSTEXPR inline int bottom() const;
QRect normalized() const;
- Q_DECL_CONSTEXPR int x() const;
- Q_DECL_CONSTEXPR int y() const;
- void setLeft(int pos);
- void setTop(int pos);
- void setRight(int pos);
- void setBottom(int pos);
- void setX(int x);
- void setY(int y);
-
- void setTopLeft(const QPoint &p);
- void setBottomRight(const QPoint &p);
- void setTopRight(const QPoint &p);
- void setBottomLeft(const QPoint &p);
-
- Q_DECL_CONSTEXPR QPoint topLeft() const;
- Q_DECL_CONSTEXPR QPoint bottomRight() const;
- Q_DECL_CONSTEXPR QPoint topRight() const;
- Q_DECL_CONSTEXPR QPoint bottomLeft() const;
- Q_DECL_CONSTEXPR QPoint center() const;
-
- void moveLeft(int pos);
- void moveTop(int pos);
- void moveRight(int pos);
- void moveBottom(int pos);
- void moveTopLeft(const QPoint &p);
- void moveBottomRight(const QPoint &p);
- void moveTopRight(const QPoint &p);
- void moveBottomLeft(const QPoint &p);
- void moveCenter(const QPoint &p);
+ Q_DECL_CONSTEXPR inline int x() const;
+ Q_DECL_CONSTEXPR inline int y() const;
+ inline void setLeft(int pos);
+ inline void setTop(int pos);
+ inline void setRight(int pos);
+ inline void setBottom(int pos);
+ inline void setX(int x);
+ inline void setY(int y);
+
+ inline void setTopLeft(const QPoint &p);
+ inline void setBottomRight(const QPoint &p);
+ inline void setTopRight(const QPoint &p);
+ inline void setBottomLeft(const QPoint &p);
+
+ Q_DECL_CONSTEXPR inline QPoint topLeft() const;
+ Q_DECL_CONSTEXPR inline QPoint bottomRight() const;
+ Q_DECL_CONSTEXPR inline QPoint topRight() const;
+ Q_DECL_CONSTEXPR inline QPoint bottomLeft() const;
+ Q_DECL_CONSTEXPR inline QPoint center() const;
+
+ inline void moveLeft(int pos);
+ inline void moveTop(int pos);
+ inline void moveRight(int pos);
+ inline void moveBottom(int pos);
+ inline void moveTopLeft(const QPoint &p);
+ inline void moveBottomRight(const QPoint &p);
+ inline void moveTopRight(const QPoint &p);
+ inline void moveBottomLeft(const QPoint &p);
+ inline void moveCenter(const QPoint &p);
inline void translate(int dx, int dy);
inline void translate(const QPoint &p);
Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const;
Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const;
- void moveTo(int x, int t);
- void moveTo(const QPoint &p);
+ inline void moveTo(int x, int t);
+ inline void moveTo(const QPoint &p);
- void setRect(int x, int y, int w, int h);
+ inline void setRect(int x, int y, int w, int h);
inline void getRect(int *x, int *y, int *w, int *h) const;
- void setCoords(int x1, int y1, int x2, int y2);
+ inline void setCoords(int x1, int y1, int x2, int y2);
inline void getCoords(int *x1, int *y1, int *x2, int *y2) const;
inline void adjust(int x1, int y1, int x2, int y2);
Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const;
- Q_DECL_CONSTEXPR QSize size() const;
- Q_DECL_CONSTEXPR int width() const;
- Q_DECL_CONSTEXPR int height() const;
- void setWidth(int w);
- void setHeight(int h);
- void setSize(const QSize &s);
+ Q_DECL_CONSTEXPR inline QSize size() const;
+ Q_DECL_CONSTEXPR inline int width() const;
+ Q_DECL_CONSTEXPR inline int height() const;
+ inline void setWidth(int w);
+ inline void setHeight(int h);
+ inline void setSize(const QSize &s);
QRect operator|(const QRect &r) const;
QRect operator&(const QRect &r) const;
- QRect& operator|=(const QRect &r);
- QRect& operator&=(const QRect &r);
+ inline QRect& operator|=(const QRect &r);
+ inline QRect& operator&=(const QRect &r);
- bool contains(const QPoint &p, bool proper=false) const;
- 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 united(const QRect &other) const;
- QRect intersected(const QRect &other) const;
+ bool contains(const QPoint &p, bool proper=false) const;
+ inline bool contains(int x, int y) const;
+ inline bool contains(int x, int y, bool proper) const;
+ inline QRect united(const QRect &other) const;
+ inline QRect intersected(const QRect &other) const;
bool intersects(const QRect &r) const;
#if QT_DEPRECATED_SINCE(5, 0)
@@ -144,8 +144,8 @@ public:
QT_DEPRECATED QRect intersect(const QRect &r) const { return intersected(r); }
#endif
- friend Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator==(const QRect &, const QRect &);
- friend Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator!=(const QRect &, const QRect &);
+ friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &);
+ friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &);
private:
int x1;
@@ -155,8 +155,8 @@ private:
};
Q_DECLARE_TYPEINFO(QRect, Q_MOVABLE_TYPE);
-Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator==(const QRect &, const QRect &);
-Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator!=(const QRect &, const QRect &);
+Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &);
+Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &);
/*****************************************************************************
@@ -341,6 +341,16 @@ inline void QRect::moveBottomLeft(const QPoint &p)
moveBottom(p.y());
}
+inline void QRect::moveCenter(const QPoint &p)
+{
+ int w = x2 - x1;
+ int h = y2 - y1;
+ x1 = p.x() - w/2;
+ y1 = p.y() - h/2;
+ x2 = x1 + w;
+ y2 = y1 + h;
+}
+
inline void QRect::getRect(int *ax, int *ay, int *aw, int *ah) const
{
*ax = x1;
@@ -452,9 +462,9 @@ public:
Q_DECL_CONSTEXPR QRectF(qreal left, qreal top, qreal width, qreal height);
Q_DECL_CONSTEXPR QRectF(const QRect &rect);
- Q_DECL_CONSTEXPR bool isNull() const;
- Q_DECL_CONSTEXPR bool isEmpty() const;
- Q_DECL_CONSTEXPR bool isValid() const;
+ Q_DECL_CONSTEXPR inline bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isEmpty() const;
+ Q_DECL_CONSTEXPR inline bool isValid() const;
QRectF normalized() const;
Q_DECL_CONSTEXPR inline qreal left() const { return xp; }
@@ -477,56 +487,56 @@ public:
Q_DECL_CONSTEXPR inline QPointF bottomLeft() const { return QPointF(xp, yp+h); }
Q_DECL_CONSTEXPR inline QPointF center() const;
- void setTopLeft(const QPointF &p);
- void setBottomRight(const QPointF &p);
- void setTopRight(const QPointF &p);
- void setBottomLeft(const QPointF &p);
+ inline void setTopLeft(const QPointF &p);
+ inline void setBottomRight(const QPointF &p);
+ inline void setTopRight(const QPointF &p);
+ inline void setBottomLeft(const QPointF &p);
- void moveLeft(qreal pos);
- void moveTop(qreal pos);
- void moveRight(qreal pos);
- void moveBottom(qreal pos);
- void moveTopLeft(const QPointF &p);
- void moveBottomRight(const QPointF &p);
- void moveTopRight(const QPointF &p);
- void moveBottomLeft(const QPointF &p);
- void moveCenter(const QPointF &p);
+ inline void moveLeft(qreal pos);
+ inline void moveTop(qreal pos);
+ inline void moveRight(qreal pos);
+ inline void moveBottom(qreal pos);
+ inline void moveTopLeft(const QPointF &p);
+ inline void moveBottomRight(const QPointF &p);
+ inline void moveTopRight(const QPointF &p);
+ inline void moveBottomLeft(const QPointF &p);
+ inline void moveCenter(const QPointF &p);
- void translate(qreal dx, qreal dy);
- void translate(const QPointF &p);
+ inline void translate(qreal dx, qreal dy);
+ inline void translate(const QPointF &p);
- Q_DECL_CONSTEXPR QRectF translated(qreal dx, qreal dy) const;
- Q_DECL_CONSTEXPR QRectF translated(const QPointF &p) const;
+ Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const;
+ Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const;
- void moveTo(qreal x, qreal t);
- void moveTo(const QPointF &p);
+ inline void moveTo(qreal x, qreal t);
+ inline void moveTo(const QPointF &p);
- void setRect(qreal x, qreal y, qreal w, qreal h);
- void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const;
+ inline void setRect(qreal x, qreal y, qreal w, qreal h);
+ inline void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const;
- void setCoords(qreal x1, qreal y1, qreal x2, qreal y2);
- void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const;
+ inline void setCoords(qreal x1, qreal y1, qreal x2, qreal y2);
+ inline void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const;
inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2);
Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const;
- Q_DECL_CONSTEXPR QSizeF size() const;
- Q_DECL_CONSTEXPR qreal width() const;
- Q_DECL_CONSTEXPR qreal height() const;
- void setWidth(qreal w);
- void setHeight(qreal h);
- void setSize(const QSizeF &s);
+ Q_DECL_CONSTEXPR inline QSizeF size() const;
+ Q_DECL_CONSTEXPR inline qreal width() const;
+ Q_DECL_CONSTEXPR inline qreal height() const;
+ inline void setWidth(qreal w);
+ inline void setHeight(qreal h);
+ inline void setSize(const QSizeF &s);
QRectF operator|(const QRectF &r) const;
QRectF operator&(const QRectF &r) const;
- QRectF& operator|=(const QRectF &r);
- QRectF& operator&=(const QRectF &r);
+ inline QRectF& operator|=(const QRectF &r);
+ inline QRectF& operator&=(const QRectF &r);
- bool contains(const QPointF &p) const;
- bool contains(qreal x, qreal y) const;
bool contains(const QRectF &r) const;
- QRectF united(const QRectF &other) const;
- QRectF intersected(const QRectF &other) const;
+ bool contains(const QPointF &p) const;
+ inline bool contains(qreal x, qreal y) const;
+ inline QRectF united(const QRectF &other) const;
+ inline QRectF intersected(const QRectF &other) const;
bool intersects(const QRectF &r) const;
#if QT_DEPRECATED_SINCE(5, 0)
@@ -534,10 +544,10 @@ public:
QT_DEPRECATED QRectF intersect(const QRectF &r) const { return intersected(r); }
#endif
- friend Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator==(const QRectF &, const QRectF &);
- friend Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator!=(const QRectF &, const QRectF &);
+ friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &);
+ friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &);
- Q_DECL_CONSTEXPR QRect toRect() const;
+ Q_DECL_CONSTEXPR inline QRect toRect() const;
QRect toAlignedRect() const;
private:
@@ -548,8 +558,8 @@ private:
};
Q_DECLARE_TYPEINFO(QRectF, Q_MOVABLE_TYPE);
-Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator==(const QRectF &, const QRectF &);
-Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator!=(const QRectF &, const QRectF &);
+Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &);
+Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &);
/*****************************************************************************
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 1db0fcf44c..e2167c5999 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -437,7 +437,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
When the number of matches cannot be determined in advance, a
common idiom is to use cap() in a loop. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 0
+ \snippet code/src_corelib_tools_qregexp.cpp 0
\target assertions
\section1 Assertions
@@ -532,7 +532,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
To test a string against a wildcard expression, use exactMatch().
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 1
+ \snippet code/src_corelib_tools_qregexp.cpp 1
\target perl-users
\section1 Notes for Perl Users
@@ -555,7 +555,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
applied to all the quantifiers in the pattern. For example, to
match the Perl regexp \b{ro+?m} requires:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 2
+ \snippet code/src_corelib_tools_qregexp.cpp 2
The equivalent of Perl's \c{/i} option is
setCaseSensitivity(Qt::CaseInsensitive).
@@ -584,7 +584,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
the other hand, C++'s rules for literal strings can be used to
achieve the same:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 3
+ \snippet code/src_corelib_tools_qregexp.cpp 3
Both zero-width positive and zero-width negative lookahead
assertions (?=pattern) and (?!pattern) are supported with the same
@@ -603,12 +603,12 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
\target code-examples
\section1 Code Examples
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 4
+ \snippet code/src_corelib_tools_qregexp.cpp 4
The third string matches '\underline{6}'. This is a simple validation
regexp for integers in the range 0 to 99.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 5
+ \snippet code/src_corelib_tools_qregexp.cpp 5
The second string matches '\underline{This_is-OK}'. We've used the
character set abbreviation '\\S' (non-whitespace) and the anchors
@@ -618,25 +618,25 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
'letter' or 'correspondence' but only match whole words i.e. not
'email'
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 6
+ \snippet code/src_corelib_tools_qregexp.cpp 6
The second string matches "Please write the \underline{letter}". The
word 'letter' is also captured (because of the parentheses). We
can see what text we've captured like this:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 7
+ \snippet code/src_corelib_tools_qregexp.cpp 7
This will capture the text from the first set of capturing
parentheses (counting capturing left parentheses from left to
right). The parentheses are counted from 1 since cap(0) is the
whole matched regexp (equivalent to '&' in most regexp engines).
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 8
+ \snippet code/src_corelib_tools_qregexp.cpp 8
Here we've passed the QRegExp to QString's replace() function to
replace the matched text with new text.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 9
+ \snippet code/src_corelib_tools_qregexp.cpp 9
We've used the indexIn() function to repeatedly match the regexp in
the string. Note that instead of moving forward by one character
@@ -650,7 +650,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
One common use of regexps is to split lines of delimited data into
their component fields.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 10
+ \snippet code/src_corelib_tools_qregexp.cpp 10
In this example our input lines have the format company name, web
address and country. Unfortunately the regexp is rather long and
@@ -660,13 +660,13 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
QString::split() function can take a separator string or regexp
as an argument and split a string accordingly.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 11
+ \snippet code/src_corelib_tools_qregexp.cpp 11
Here field[0] is the company, field[1] the web address and so on.
To imitate the matching of a shell we can use wildcard mode.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 12
+ \snippet code/src_corelib_tools_qregexp.cpp 12
Wildcard matching can be convenient because of its simplicity, but
any wildcard regexp can be defined using full regexps, e.g.
@@ -4204,7 +4204,6 @@ void QRegExp::setMinimal(bool minimal)
priv->minimal = minimal;
}
-// ### Qt 5: make non-const
/*!
Returns true if \a str is matched exactly by this regular
expression; otherwise returns false. You can determine how much of
@@ -4220,12 +4219,9 @@ void QRegExp::setMinimal(bool minimal)
bluebell, \c blutak and \c lightblue, exactMatch() returns false
and matchedLength() will return 4, 3 and 0 respectively.
- Although const, this function sets matchedLength(),
- capturedTexts(), and pos().
-
\sa indexIn(), lastIndexIn()
*/
-bool QRegExp::exactMatch(const QString &str) const
+bool QRegExp::exactMatch(const QString &str)
{
prepareEngineForMatch(priv, str);
priv->matchState.match(str.unicode(), str.length(), 0, priv->minimal, true, 0);
@@ -4238,7 +4234,6 @@ bool QRegExp::exactMatch(const QString &str) const
}
}
-// ### Qt 5: make non-const
/*!
Attempts to find a match in \a str from position \a offset (0 by
default). If \a offset is -1, the search starts at the last
@@ -4255,10 +4250,7 @@ bool QRegExp::exactMatch(const QString &str) const
QString::replace().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 13
-
- Although const, this function sets matchedLength(),
- capturedTexts() and pos().
+ \snippet code/src_corelib_tools_qregexp.cpp 13
If the QRegExp is a wildcard expression (see setPatternSyntax())
and want to test a string against the whole wildcard expression,
@@ -4267,7 +4259,7 @@ bool QRegExp::exactMatch(const QString &str) const
\sa lastIndexIn(), exactMatch()
*/
-int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const
+int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode)
{
prepareEngineForMatch(priv, str);
if (offset < 0)
@@ -4277,7 +4269,6 @@ int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const
return priv->matchState.captured[0];
}
-// ### Qt 5: make non-const
/*!
Attempts to find a match backwards in \a str from position \a
offset. If \a offset is -1 (the default), the search starts at the
@@ -4289,16 +4280,13 @@ int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const
The \a caretMode parameter can be used to instruct whether \b{^}
should match at index 0 or at \a offset.
- Although const, this function sets matchedLength(),
- capturedTexts() and pos().
-
\warning Searching backwards is much slower than searching
forwards.
\sa indexIn(), exactMatch()
*/
-int QRegExp::lastIndexIn(const QString &str, int offset, CaretMode caretMode) const
+int QRegExp::lastIndexIn(const QString &str, int offset, CaretMode caretMode)
{
prepareEngineForMatch(priv, str);
if (offset < 0)
@@ -4332,14 +4320,6 @@ int QRegExp::matchedLength() const
#ifndef QT_NO_REGEXP_CAPTURE
/*!
- \fn int QRegExp::numCaptures() const
- \obsolete
- Returns the number of captures contained in the regular expression.
-
- \sa captureCount()
- */
-
-/*!
\since 4.6
Returns the number of captures contained in the regular expression.
*/
@@ -4357,17 +4337,17 @@ int QRegExp::captureCount() const
(capturing) subexpression of the regexp.
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 14
+ \snippet code/src_corelib_tools_qregexp.cpp 14
The above example also captures elements that may be present but
which we have no interest in. This problem can be solved by using
non-capturing parentheses:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 15
+ \snippet code/src_corelib_tools_qregexp.cpp 15
Note that if you want to iterate over the list, you should iterate
over a copy, e.g.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 16
+ \snippet code/src_corelib_tools_qregexp.cpp 16
Some regexps can match an indeterminate number of times. For
example if the input string is "Offsets: 12 14 99 231 7" and the
@@ -4420,7 +4400,7 @@ QStringList QRegExp::capturedTexts()
match has index 0 and the parenthesized subexpressions have
indexes starting from 1 (excluding non-capturing parentheses).
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 17
+ \snippet code/src_corelib_tools_qregexp.cpp 17
The order of elements matched by cap() is as follows. The first
element, cap(0), is the entire matching string. Each subsequent
@@ -4449,7 +4429,7 @@ QString QRegExp::cap(int nth)
of the whole match.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 18
+ \snippet code/src_corelib_tools_qregexp.cpp 18
For zero-length matches, pos() always returns -1. (For example, if
cap(4) would return an empty string, pos(4) returns -1.) This is
@@ -4504,11 +4484,11 @@ QString QRegExp::errorString()
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 19
+ \snippet code/src_corelib_tools_qregexp.cpp 19
This function is useful to construct regexp patterns dynamically:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 20
+ \snippet code/src_corelib_tools_qregexp.cpp 20
\sa setPatternSyntax()
*/
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 0455e1603e..234bb624e4 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -93,10 +93,10 @@ public:
bool isMinimal() const;
void setMinimal(bool minimal);
- bool exactMatch(const QString &str) const;
+ bool exactMatch(const QString &str);
- int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero) const;
- int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero) const;
+ int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero);
+ int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero);
int matchedLength() const;
#ifndef QT_NO_REGEXP_CAPTURE
int captureCount() const;
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 393b2bbb7d..ff423901e8 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -122,23 +122,23 @@ QT_BEGIN_NAMESPACE
You can set the pattern string by passing a string to the QRegularExpression
constructor:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 0
+ \snippet code/src_corelib_tools_qregularexpression.cpp 0
This sets the pattern string to \c{a pattern}. You can also use the
setPattern() function to set a pattern on an existing QRegularExpression
object:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 1
+ \snippet code/src_corelib_tools_qregularexpression.cpp 1
Note that due to C++ literal strings rules, you must escape all backslashes
inside the pattern string with another backslash:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 2
+ \snippet code/src_corelib_tools_qregularexpression.cpp 2
The pattern() function returns the pattern that is currently set for a
QRegularExpression object:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 3
+ \snippet code/src_corelib_tools_qregularexpression.cpp 3
\section1 Pattern options
@@ -149,17 +149,17 @@ QT_BEGIN_NAMESPACE
You can set the options by passing them to the QRegularExpression
constructor, as in:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 4
+ \snippet code/src_corelib_tools_qregularexpression.cpp 4
Alternatively, you can use the setPatternOptions() function on an existing
QRegularExpressionObject:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 5
+ \snippet code/src_corelib_tools_qregularexpression.cpp 5
It is possible to get the pattern options currently set on a
QRegularExpression object by using the patternOptions() function:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 6
+ \snippet code/src_corelib_tools_qregularexpression.cpp 6
Please refer to the QRegularExpression::PatternOption enum documentation for
more information about each pattern option.
@@ -187,20 +187,20 @@ QT_BEGIN_NAMESPACE
QRegularExpressionMatch object that can be used to inspect the results of
the match. For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 7
+ \snippet code/src_corelib_tools_qregularexpression.cpp 7
If a match is successful, the (implicit) capturing group number 0 can be
used to retrieve the substring matched by the entire pattern (see also the
section about \l{extracting captured substrings}):
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 8
+ \snippet code/src_corelib_tools_qregularexpression.cpp 8
It's also possible to start a match at an arbitrary offset inside the
subject string by passing the offset as an argument of the
match() function. In the following example \c{"12 abc"}
is not matched because the match is started at offset 1:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 9
+ \snippet code/src_corelib_tools_qregularexpression.cpp 9
\target extracting captured substrings
\section2 Extracting captured substrings
@@ -210,7 +210,7 @@ QT_BEGIN_NAMESPACE
\l{QRegularExpressionMatch::}{captured()} function will return the string
captured by the n-th capturing group:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 10
+ \snippet code/src_corelib_tools_qregularexpression.cpp 10
Capturing groups in the pattern are numbered starting from 1, and the
implicit capturing group 0 is used to capture the substring that matched
@@ -221,12 +221,12 @@ QT_BEGIN_NAMESPACE
\l{QRegularExpressionMatch::}{capturedStart()} and the
\l{QRegularExpressionMatch::}{capturedEnd()} functions:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 11
+ \snippet code/src_corelib_tools_qregularexpression.cpp 11
All of these functions have an overload taking a QString as a parameter
in order to extract \e{named} captured substrings. For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 12
+ \snippet code/src_corelib_tools_qregularexpression.cpp 12
\target global matching
\section1 Global matching
@@ -240,7 +240,7 @@ QT_BEGIN_NAMESPACE
which is a Java-like forward iterator that can be used to iterate over the
results. For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 13
+ \snippet code/src_corelib_tools_qregularexpression.cpp 13
Since it's a Java-like iterator, the QRegularExpressionMatchIterator will
point immediately before the first result. Every result is returned as a
@@ -250,7 +250,7 @@ QT_BEGIN_NAMESPACE
\l{QRegularExpressionMatchIterator::}{next()} will return the next result
and advance the iterator. Continuing from the previous example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 14
+ \snippet code/src_corelib_tools_qregularexpression.cpp 14
You can also use \l{QRegularExpressionMatchIterator::}{peekNext()} to get
the next result without advancing the iterator.
@@ -326,17 +326,17 @@ QT_BEGIN_NAMESPACE
This behaviour is implemented by the PartialPreferCompleteMatch match type.
For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 15
+ \snippet code/src_corelib_tools_qregularexpression.cpp 15
If matching the same regular expression against the subject string leads to
a complete match, it is reported as usual:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 16
+ \snippet code/src_corelib_tools_qregularexpression.cpp 16
Another example with a different pattern, showing the behaviour of
preferring a complete match over a partial one:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 17
+ \snippet code/src_corelib_tools_qregularexpression.cpp 17
In this case, the subpattern \c{abc\\w+X} partially matches the subject
string; however, the subpattern \c{def} matches the subject string
@@ -346,7 +346,7 @@ QT_BEGIN_NAMESPACE
match), then the QRegularExpressionMatch object will report the first one
that is found. For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 18
+ \snippet code/src_corelib_tools_qregularexpression.cpp 18
\section2 Incremental/multi-segment matching
@@ -369,13 +369,13 @@ QT_BEGIN_NAMESPACE
as soon as it is found, and other match alternatives are not tried
(even if they could lead to a complete match). For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 19
+ \snippet code/src_corelib_tools_qregularexpression.cpp 19
This happens because when matching the first branch of the alternation
operator a partial match is found, and therefore matching stops, without
trying the second branch. Another example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 20
+ \snippet code/src_corelib_tools_qregularexpression.cpp 20
This shows what could seem a counterintuitve behaviour of quantifiers:
since \c{?} is greedy, then the engine tries first to continue the match
@@ -383,7 +383,7 @@ QT_BEGIN_NAMESPACE
subject string, and therefore a partial match is reported. This is
even more surprising in the following example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 21
+ \snippet code/src_corelib_tools_qregularexpression.cpp 21
It's easy to understand this behaviour if we remember that the engine
expects the subject string to be only a substring of the whole text we're
@@ -404,13 +404,13 @@ QT_BEGIN_NAMESPACE
syntax errors in the pattern string. The isValid() function will return
true if the regular expression is valid, or false otherwise:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 22
+ \snippet code/src_corelib_tools_qregularexpression.cpp 22
You can get more information about the specific error by calling the
errorString() function; moreover, the patternErrorOffset() function
will return the offset inside the pattern string
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 23
+ \snippet code/src_corelib_tools_qregularexpression.cpp 23
If a match is attempted with an invalid QRegularExpression, then the
returned QRegularExpressionMatch object will be invalid as well (that is,
@@ -455,19 +455,19 @@ QT_BEGIN_NAMESPACE
putting the pattern between the \c{^} and the \c{$} anchors is enough
in most cases:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 24
+ \snippet code/src_corelib_tools_qregularexpression.cpp 24
However, remember that the \c{$} anchor not only matches at the end of the
string, but also at a newline character right before the end of the string;
that is, the previous pattern matches against the string "this pattern must
- match exactly\n". Also, the behaviour of both the \c{^} and the \c{$}
+ match exactly\\n". Also, the behaviour of both the \c{^} and the \c{$}
anchors changes if the MultiLineOption is set either explicitely (as a
pattern option) or implicitly (as a directive inside the pattern string).
Therefore, in the most general case, you should wrap the pattern between
the \c{\A} and the \c{\z} anchors:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 25
+ \snippet code/src_corelib_tools_qregularexpression.cpp 25
Note the usage of the non-capturing group in order to preserve the meaning
of the branch operator inside the pattern.
@@ -566,7 +566,7 @@ QT_BEGIN_NAMESPACE
returns each substring captured, either by the capturing group's index or
by its name:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 29
+ \snippet code/src_corelib_tools_qregularexpression.cpp 29
For each captured substring it is possible to query its starting and ending
offsets in the subject string by calling the capturedStart() and the
@@ -616,7 +616,7 @@ QT_BEGIN_NAMESPACE
For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 30
+ \snippet code/src_corelib_tools_qregularexpression.cpp 30
Moreover, QRegularExpressionMatchIterator offers a peekNext() function
to get the next result \e{without} advancing the iterator.
@@ -1590,11 +1590,11 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const
meaning when used as a regular expression pattern string, and returns
the escaped string. For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 26
+ \snippet code/src_corelib_tools_qregularexpression.cpp 26
This is very convenient in order to build patterns from arbitrary strings:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 27
+ \snippet code/src_corelib_tools_qregularexpression.cpp 27
\note This function implements Perl's quotemeta algorithm and escapes with
a backslash all characters in \a str, except for the characters in the
@@ -1721,7 +1721,7 @@ QRegularExpression::MatchOptions QRegularExpressionMatch::matchOptions() const
including the implicit capturing group 0. This can be used to extract all
the substrings that were captured:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 28
+ \snippet code/src_corelib_tools_qregularexpression.cpp 28
Note that some of the capturing groups with an index less than
lastCapturedIndex() could have not matched, and therefore captured nothing.
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 5ecca89229..bf2cac453b 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -61,12 +61,12 @@ QT_BEGIN_NAMESPACE
Consider this function which does heap allocations, and have various exit points:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 0
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 0
It's encumbered by the manual delete calls. With QScopedPointer, the code
can be simplified to:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 1
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 1
The code the compiler generates for QScopedPointer is the same as when
writing it manually. Code that makes use of \a delete are candidates for
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
The const qualification on a regular C++ pointer can also be expressed with
a QScopedPointer:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 2
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 2
\section1 Custom cleanup handlers
@@ -99,7 +99,7 @@ QT_BEGIN_NAMESPACE
You can pass your own classes as handlers, provided that they have a public
static function \c{void cleanup(T *pointer)}.
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 5
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 5
\section1 Forward Declared Pointers
@@ -111,7 +111,7 @@ QT_BEGIN_NAMESPACE
points to a forward declared class must have non-inline constructors,
destructors and assignment operators:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 4
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 4
Otherwise, the compiler output a warning about not being able to destruct
\c MyPrivateClass.
@@ -168,7 +168,7 @@ QT_BEGIN_NAMESPACE
Returns \c true if this object is not \c null. This function is suitable
for use in \tt if-constructs, like:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 3
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 3
\sa isNull()
*/
diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc
index b03cce884d..51d9caad70 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -40,19 +40,19 @@
Here's an example QSet with QString values:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 0
+ \snippet code/doc_src_qset.cpp 0
To insert a value into the set, use insert():
- \snippet doc/src/snippets/code/doc_src_qset.cpp 1
+ \snippet code/doc_src_qset.cpp 1
Another way to insert items into the set is to use operator<<():
- \snippet doc/src/snippets/code/doc_src_qset.cpp 2
+ \snippet code/doc_src_qset.cpp 2
To test whether an item belongs to the set or not, use contains():
- \snippet doc/src/snippets/code/doc_src_qset.cpp 3
+ \snippet code/doc_src_qset.cpp 3
If you want to navigate through all the values stored in a QSet,
you can use an iterator. QSet supports both \l{Java-style
@@ -60,18 +60,18 @@
iterators} (QSet::iterator and QSet::const_iterator). Here's how
to iterate over a QSet<QWidget *> using a Java-style iterator:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 4
+ \snippet code/doc_src_qset.cpp 4
Here's the same code, but using an STL-style iterator:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 5
+ \snippet code/doc_src_qset.cpp 5
QSet is unordered, so an iterator's sequence cannot be assumed to
be predictable. If ordering by key is required, use a QMap.
To navigate through a QSet, you can also use \l{foreach}:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 6
+ \snippet code/doc_src_qset.cpp 6
Items can be removed from the set using remove(). There is also a
clear() function that removes all items.
@@ -194,7 +194,7 @@
This function is useful for code that needs to build a huge set
and wants to avoid repeated reallocation. For example:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 7
+ \snippet code/doc_src_qset.cpp 7
Ideally, \a size should be slightly more than the maximum number
of elements expected in the set. \a size doesn't have to be prime,
@@ -618,18 +618,18 @@
start iterating. Here's a typical loop that prints all the items
stored in a set:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 8
+ \snippet code/doc_src_qset.cpp 8
Here's a loop that removes certain items (all those that start
with 'J') from a set while iterating:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 9
+ \snippet code/doc_src_qset.cpp 9
STL-style iterators can be used as arguments to \l{generic
algorithms}. For example, here's how to find an item in the set
using the qFind() algorithm:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 10
+ \snippet code/doc_src_qset.cpp 10
Multiple iterators can be used on the same set. However, you may
not attempt to modify the container while iterating on it.
@@ -661,13 +661,13 @@
start iterating. Here's a typical loop that prints all the items
stored in a set:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 11
+ \snippet code/doc_src_qset.cpp 11
STL-style iterators can be used as arguments to \l{generic
algorithms}. For example, here's how to find an item in the set
using the qFind() algorithm:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 12
+ \snippet code/doc_src_qset.cpp 12
Multiple iterators can be used on the same set. However, you may
not attempt to modify the container while iterating on it.
@@ -901,7 +901,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 13
+ \snippet code/doc_src_qset.cpp 13
\sa fromList(), QList::fromSet(), qSort()
*/
@@ -926,7 +926,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 14
+ \snippet code/doc_src_qset.cpp 14
\sa toList(), QList::toSet()
*/
diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp
index ffc8ac601d..4c33bebd7b 100644
--- a/src/corelib/tools/qshareddata.cpp
+++ b/src/corelib/tools/qshareddata.cpp
@@ -99,7 +99,7 @@ QT_BEGIN_NAMESPACE
implicitly shared \c Employee class. In the header file we define the
two classes \c Employee and \c EmployeeData.
- \snippet doc/src/snippets/sharedemployee/employee.h 0
+ \snippet sharedemployee/employee.h 0
In class \c Employee, note the single data member, a \e {d pointer}
of type \c {QSharedDataPointer<EmployeeData>}. All accesses of
@@ -121,14 +121,14 @@ QT_BEGIN_NAMESPACE
straightforward. Both create a new instance of \c EmployeeData
and assign it to the \e{d pointer} .
- \snippet doc/src/snippets/sharedemployee/employee.h 1
+ \snippet sharedemployee/employee.h 1
\codeline
- \snippet doc/src/snippets/sharedemployee/employee.h 2
+ \snippet sharedemployee/employee.h 2
Note that class \c Employee also has a trivial copy constructor
defined, which is not strictly required in this case.
- \snippet doc/src/snippets/sharedemployee/employee.h 7
+ \snippet sharedemployee/employee.h 7
The copy constructor is not strictly required here, because class \c
EmployeeData is included in the same file as class \c Employee
@@ -162,9 +162,9 @@ QT_BEGIN_NAMESPACE
detach() to ensure that the function operates on its own copy of the
data.
- \snippet doc/src/snippets/sharedemployee/employee.h 3
+ \snippet sharedemployee/employee.h 3
\codeline
- \snippet doc/src/snippets/sharedemployee/employee.h 4
+ \snippet sharedemployee/employee.h 4
Note that if detach() is called more than once in a member function
due to multiple dereferences of the \e {d pointer}, detach() will
@@ -180,9 +180,9 @@ QT_BEGIN_NAMESPACE
In \c Employee's \e const member functions, dereferencing the \e {d
pointer} does \e not cause detach() to be called.
- \snippet doc/src/snippets/sharedemployee/employee.h 5
+ \snippet sharedemployee/employee.h 5
\codeline
- \snippet doc/src/snippets/sharedemployee/employee.h 6
+ \snippet sharedemployee/employee.h 6
Notice that there is no need to implement a copy constructor or an
assignment operator for the \c Employee class, because the copy
@@ -199,7 +199,7 @@ QT_BEGIN_NAMESPACE
Consider a simple example that creates two instances of the
implicitly shared \c Employee class.
- \snippet doc/src/snippets/sharedemployee/main.cpp 0
+ \snippet sharedemployee/main.cpp 0
After the second employee e2 is created and e1 is assigned to it,
both \c e1 and \c e2 refer to Albrecht Durer, employee 1001. Both \c
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index fb6219273f..ac21e5beb9 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Intel Corporation.
** Contact: http://www.qt-project.org/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -46,9 +47,12 @@
#if defined(Q_OS_WIN)
# if defined(Q_OS_WINCE)
# include <qt_windows.h>
+# include <cmnintrin.h>
# endif
# if !defined(Q_CC_GNU)
-# include <intrin.h>
+# ifndef Q_OS_WINCE
+# include <intrin.h>
+# endif
# endif
#elif defined(Q_OS_LINUX) && defined(__arm__)
#include "private/qcore_unix_p.h"
@@ -98,7 +102,7 @@ static inline uint detectProcessorFeatures()
return features;
}
-#elif defined(__arm__) || defined(__arm) || defined(QT_HAVE_IWMMXT) || defined(QT_HAVE_NEON)
+#elif defined(Q_PROCESSOR_ARM) || defined(QT_HAVE_IWMMXT) || defined(QT_HAVE_NEON)
static inline uint detectProcessorFeatures()
{
uint features = 0;
@@ -142,17 +146,22 @@ static inline uint detectProcessorFeatures()
return features;
}
-#elif defined(__i386__) || defined(_M_IX86)
-static inline uint detectProcessorFeatures()
-{
- uint features = 0;
+#elif defined(Q_PROCESSOR_X86)
- unsigned int extended_result = 0;
- unsigned int feature_result = 0;
- uint result = 0;
- /* see p. 118 of amd64 instruction set manual Vol3 */
+#ifdef Q_PROCESSOR_X86_32
+# define PICreg "%%ebx"
+#else
+# define PICreg "%%rbx"
+#endif
+
+static int maxBasicCpuidSupported()
+{
#if defined(Q_CC_GNU)
- long cpuid_supported, tmp1;
+ qintptr tmp1;
+
+# ifdef Q_PROCESSOR_X86_32
+ // check if the CPUID instruction is supported
+ long cpuid_supported;
asm ("pushf\n"
"pop %0\n"
"mov %0, %1\n"
@@ -164,146 +173,141 @@ static inline uint detectProcessorFeatures()
"xor %1, %0\n" // %eax is now 0 if CPUID is not supported
: "=a" (cpuid_supported), "=r" (tmp1)
);
- if (cpuid_supported) {
- asm ("xchg %%ebx, %2\n"
- "cpuid\n"
- "xchg %%ebx, %2\n"
- : "=&c" (feature_result), "=d" (result), "=&r" (tmp1)
- : "a" (1));
-
- asm ("xchg %%ebx, %1\n"
- "cpuid\n"
- "cmp $0x80000000, %%eax\n"
- "jnbe 1f\n"
- "xor %0, %0\n"
- "jmp 2f\n"
- "1:\n"
- "mov $0x80000001, %%eax\n"
- "cpuid\n"
- "2:\n"
- "xchg %%ebx, %1\n"
- : "=&d" (extended_result), "=&r" (tmp1)
- : "a" (0x80000000)
- : "%ecx"
- );
- }
+ if (!cpuid_supported)
+ return 0;
+# endif
-#elif defined (Q_OS_WIN)
- _asm {
- push eax
- push ebx
- push ecx
- push edx
- pushfd
- pop eax
- mov ebx, eax
- xor eax, 00200000h
- push eax
- popfd
- pushfd
- pop eax
- mov edx, 0
- xor eax, ebx
- jz skip
-
- mov eax, 1
- cpuid
- mov result, edx
- mov feature_result, ecx
- skip:
- pop edx
- pop ecx
- pop ebx
- pop eax
- }
+ int result;
+ asm ("xchg " PICreg", %1\n"
+ "cpuid\n"
+ "xchg " PICreg", %1\n"
+ : "=&a" (result), "=&r" (tmp1)
+ : "0" (0)
+ : "ecx", "edx");
+ return result;
+#elif defined(Q_OS_WIN)
+ // Use the __cpuid function; if the CPUID instruction isn't supported, it will return 0
+ int info[4];
+ __cpuid(info, 0);
+ return info[0];
+#else
+ return 0;
+#endif
+}
- _asm {
- push eax
- push ebx
- push ecx
- push edx
- pushfd
- pop eax
- mov ebx, eax
- xor eax, 00200000h
- push eax
- popfd
- pushfd
- pop eax
- mov edx, 0
- xor eax, ebx
- jz skip2
-
- mov eax, 80000000h
- cpuid
- cmp eax, 80000000h
- jbe skip2
- mov eax, 80000001h
- cpuid
- mov extended_result, edx
- skip2:
- pop edx
- pop ecx
- pop ebx
- pop eax
- }
+static void cpuidFeatures01(uint &ecx, uint &edx)
+{
+#if defined(Q_CC_GNU)
+ qintptr tmp1;
+ asm ("xchg " PICreg", %2\n"
+ "cpuid\n"
+ "xchg " PICreg", %2\n"
+ : "=&c" (ecx), "=&d" (edx), "=&r" (tmp1)
+ : "a" (1));
+#elif defined(Q_OS_WIN)
+ int info[4];
+ __cpuid(info, 1);
+ ecx = info[2];
+ edx = info[3];
#endif
+}
+static void cpuidFeatures07_00(uint &ebx)
+{
+#if defined(Q_CC_GNU)
+ quintptr rbx; // in case it's 64-bit
+ asm ("xchg " PICreg", %0\n"
+ "cpuid\n"
+ "xchg " PICreg", %0\n"
+ : "=&r" (rbx)
+ : "a" (7), "c" (0)
+ : "%edx");
+ ebx = rbx;
+#elif defined(Q_OS_WIN)
+ int info[4];
+ __cpuidex(info, 7, 0);
+ ebx = info[1];
+#endif
+}
- // result now contains the standard feature bits
- if (result & (1u << 26))
- features |= SSE2;
- if (feature_result & (1u))
- features |= SSE3;
- if (feature_result & (1u << 9))
- features |= SSSE3;
- if (feature_result & (1u << 19))
- features |= SSE4_1;
- if (feature_result & (1u << 20))
- features |= SSE4_2;
- if (feature_result & (1u << 28))
- features |= AVX;
+#ifdef Q_OS_WIN
+namespace QtXgetbvHack {
+ inline quint64 _xgetbv(int) { return 0; }
+}
+using namespace QtXgetbvHack;
+#endif
- return features;
+static void xgetbv(int in, uint &eax, uint &edx)
+{
+#ifdef Q_OS_WIN
+ quint64 result = _xgetbv(in);
+ eax = result;
+ edx = result >> 32;
+#elif defined(Q_CC_GNU)
+ asm (".byte 0x0F, 0x01, 0xD0" // xgetbv instruction
+ : "=a" (eax), "=d" (edx)
+ : "c" (in));
+#endif
}
-#elif defined(__x86_64) || defined(Q_OS_WIN64)
static inline uint detectProcessorFeatures()
{
- uint features = SSE2;
- uint feature_result = 0;
-
-#if defined (Q_OS_WIN64)
- {
- int info[4];
- __cpuid(info, 1);
- feature_result = info[2];
- }
-#elif defined(Q_CC_GNU)
- quint64 tmp;
- asm ("xchg %%rbx, %1\n"
- "cpuid\n"
- "xchg %%rbx, %1\n"
- : "=&c" (feature_result), "=&r" (tmp)
- : "a" (1)
- : "%edx"
- );
+ uint features = 0;
+ int cpuidLevel = maxBasicCpuidSupported();
+ if (cpuidLevel < 1)
+ return 0;
+
+ uint cpuid01ECX = 0, cpuid01EDX = 0;
+ cpuidFeatures01(cpuid01ECX, cpuid01EDX);
+#if defined(Q_PROCESSOR_X86_32)
+ // x86 might not have SSE2 support
+ if (cpuid01EDX & (1u << 26))
+ features |= SSE2;
+#else
+ // x86-64 or x32
+ features = SSE2;
#endif
- if (feature_result & (1u))
+ // common part between 32- and 64-bit
+ if (cpuid01ECX & (1u))
features |= SSE3;
- if (feature_result & (1u << 9))
+ if (cpuid01ECX & (1u << 9))
features |= SSSE3;
- if (feature_result & (1u << 19))
+ if (cpuid01ECX & (1u << 19))
features |= SSE4_1;
- if (feature_result & (1u << 20))
+ if (cpuid01ECX & (1u << 20))
features |= SSE4_2;
- if (feature_result & (1u << 28))
- features |= AVX;
+ if (cpuid01ECX & (1u << 25))
+ features |= 0; // AES, enable if needed
+
+ uint xgetbvA = 0, xgetbvD = 0;
+ if (cpuid01ECX & (1u << 27)) {
+ // XGETBV enabled
+ xgetbv(0, xgetbvA, xgetbvD);
+ }
+
+ uint cpuid0700EBX = 0;
+ if (cpuidLevel >= 7)
+ cpuidFeatures07_00(cpuid0700EBX);
+
+ if ((xgetbvA & 6) == 6) {
+ // support for YMM and XMM registers is enabled
+ if (cpuid01ECX & (1u << 28))
+ features |= AVX;
+
+ if (cpuid0700EBX & (1u << 5))
+ features |= AVX2;
+ }
+
+ if (cpuid0700EBX & (1u << 4))
+ features |= HLE; // Hardware Lock Ellision
+ if (cpuid0700EBX & (1u << 11))
+ features |= RTM; // Restricted Transactional Memory
return features;
}
+
#else
static inline uint detectProcessorFeatures()
{
@@ -322,6 +326,9 @@ static inline uint detectProcessorFeatures()
sse4.1
sse4.2
avx
+ avx2
+ hle
+ rtm
*/
// begin generated
@@ -334,11 +341,14 @@ static const char features_string[] =
" sse4.1\0"
" sse4.2\0"
" avx\0"
+ " avx2\0"
+ " hle\0"
+ " rtm\0"
"\0";
static const int features_indices[] = {
0, 8, 14, 20, 26, 33, 41, 49,
- -1
+ 54, 60, 65, -1
};
// end generated
@@ -384,8 +394,12 @@ static const uint minFeature = None
#else
int ffs(int i)
{
+#ifndef Q_OS_WINCE
unsigned long result;
return _BitScanForward(&result, i) ? result : 0;
+#else
+ return 0;
+#endif
}
#endif
#endif // Q_OS_WIN
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 88ac7597e2..6374e20135 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -129,7 +129,10 @@ enum CPUFeatures {
SSSE3 = 0x10,
SSE4_1 = 0x20,
SSE4_2 = 0x40,
- AVX = 0x80
+ AVX = 0x80,
+ AVX2 = 0x100,
+ HLE = 0x200,
+ RTM = 0x400
};
Q_CORE_EXPORT uint qDetectCPUFeatures();
diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp
index b276d2d2e0..b4b99d26ff 100644
--- a/src/corelib/tools/qsize.cpp
+++ b/src/corelib/tools/qsize.cpp
@@ -194,7 +194,7 @@ void QSize::transpose()
\endlist
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 0
+ \snippet code/src_corelib_tools_qsize.cpp 0
\sa setWidth(), setHeight(), scaled()
*/
@@ -252,7 +252,7 @@ QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const
Using a reference makes it possible to manipulate the width
directly. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 1
+ \snippet code/src_corelib_tools_qsize.cpp 1
\sa rheight(), setWidth()
*/
@@ -265,7 +265,7 @@ QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const
Using a reference makes it possible to manipulate the height
directly. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 2
+ \snippet code/src_corelib_tools_qsize.cpp 2
\sa rwidth(), setHeight()
*/
@@ -276,7 +276,7 @@ QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const
Adds the given \a size to \e this size, and returns a reference to
this size. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 3
+ \snippet code/src_corelib_tools_qsize.cpp 3
*/
/*!
@@ -285,7 +285,7 @@ QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const
Subtracts the given \a size from \e this size, and returns a
reference to this size. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 4
+ \snippet code/src_corelib_tools_qsize.cpp 4
*/
/*!
@@ -622,7 +622,7 @@ void QSizeF::transpose()
\endlist
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 5
+ \snippet code/src_corelib_tools_qsize.cpp 5
\sa setWidth(), setHeight(), scaled()
*/
@@ -636,11 +636,11 @@ void QSizeF::transpose()
*/
/*!
- \fn QSizeF QSizeF::scaled(int width, int height, Qt::AspectRatioMode mode) const
+ \fn QSizeF QSizeF::scaled(qreal width, qreal height, Qt::AspectRatioMode mode) const
\since 5.0
Returns a size scaled to a rectangle with the given \a width and
- \a height, according to the specified \mode.
+ \a height, according to the specified \a mode.
\sa scale()
*/
@@ -679,7 +679,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
Using a reference makes it possible to manipulate the width
directly. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 6
+ \snippet code/src_corelib_tools_qsize.cpp 6
\sa rheight(), setWidth()
*/
@@ -692,7 +692,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
Using a reference makes it possible to manipulate the height
directly. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 7
+ \snippet code/src_corelib_tools_qsize.cpp 7
\sa rwidth(), setHeight()
*/
@@ -703,7 +703,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
Adds the given \a size to this size and returns a reference to
this size. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 8
+ \snippet code/src_corelib_tools_qsize.cpp 8
*/
/*!
@@ -712,7 +712,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
Subtracts the given \a size from this size and returns a reference
to this size. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 9
+ \snippet code/src_corelib_tools_qsize.cpp 9
*/
/*!
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index 88af9e876b..0f8ef24acf 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -55,32 +55,32 @@ public:
Q_DECL_CONSTEXPR QSize();
Q_DECL_CONSTEXPR QSize(int w, int h);
- Q_DECL_CONSTEXPR bool isNull() const;
- Q_DECL_CONSTEXPR bool isEmpty() const;
- Q_DECL_CONSTEXPR bool isValid() const;
-
- Q_DECL_CONSTEXPR int width() const;
- Q_DECL_CONSTEXPR int height() const;
- void setWidth(int w);
- void setHeight(int h);
+ Q_DECL_CONSTEXPR inline bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isEmpty() const;
+ Q_DECL_CONSTEXPR inline bool isValid() const;
+
+ Q_DECL_CONSTEXPR inline int width() const;
+ Q_DECL_CONSTEXPR inline int height() const;
+ inline void setWidth(int w);
+ inline void setHeight(int h);
void transpose();
- Q_DECL_CONSTEXPR QSize transposed() const;
+ Q_DECL_CONSTEXPR inline QSize transposed() const;
- void scale(int w, int h, Qt::AspectRatioMode mode);
- void scale(const QSize &s, Qt::AspectRatioMode mode);
+ inline void scale(int w, int h, Qt::AspectRatioMode mode);
+ inline void scale(const QSize &s, Qt::AspectRatioMode mode);
QSize scaled(int w, int h, Qt::AspectRatioMode mode) const;
QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const;
- Q_DECL_CONSTEXPR QSize expandedTo(const QSize &) const;
- Q_DECL_CONSTEXPR QSize boundedTo(const QSize &) const;
+ Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const;
+ Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const;
- int &rwidth();
- int &rheight();
+ inline int &rwidth();
+ inline int &rheight();
- QSize &operator+=(const QSize &);
- QSize &operator-=(const QSize &);
- QSize &operator*=(qreal c);
- QSize &operator/=(qreal c);
+ inline QSize &operator+=(const QSize &);
+ inline QSize &operator-=(const QSize &);
+ inline QSize &operator*=(qreal c);
+ inline QSize &operator/=(qreal c);
friend inline Q_DECL_CONSTEXPR bool operator==(const QSize &, const QSize &);
friend inline Q_DECL_CONSTEXPR bool operator!=(const QSize &, const QSize &);
@@ -215,32 +215,32 @@ public:
Q_DECL_CONSTEXPR QSizeF(const QSize &sz);
Q_DECL_CONSTEXPR QSizeF(qreal w, qreal h);
- bool isNull() const;
- Q_DECL_CONSTEXPR bool isEmpty() const;
- Q_DECL_CONSTEXPR bool isValid() const;
+ inline bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isEmpty() const;
+ Q_DECL_CONSTEXPR inline bool isValid() const;
- Q_DECL_CONSTEXPR qreal width() const;
- Q_DECL_CONSTEXPR qreal height() const;
- void setWidth(qreal w);
- void setHeight(qreal h);
+ Q_DECL_CONSTEXPR inline qreal width() const;
+ Q_DECL_CONSTEXPR inline qreal height() const;
+ inline void setWidth(qreal w);
+ inline void setHeight(qreal h);
void transpose();
- Q_DECL_CONSTEXPR QSizeF transposed() const;
+ Q_DECL_CONSTEXPR inline QSizeF transposed() const;
- void scale(qreal w, qreal h, Qt::AspectRatioMode mode);
- void scale(const QSizeF &s, Qt::AspectRatioMode mode);
+ inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode);
+ inline void scale(const QSizeF &s, Qt::AspectRatioMode mode);
QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const;
QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const;
- Q_DECL_CONSTEXPR QSizeF expandedTo(const QSizeF &) const;
- Q_DECL_CONSTEXPR QSizeF boundedTo(const QSizeF &) const;
+ Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const;
+ Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const;
- qreal &rwidth();
- qreal &rheight();
+ inline qreal &rwidth();
+ inline qreal &rheight();
- QSizeF &operator+=(const QSizeF &);
- QSizeF &operator-=(const QSizeF &);
- QSizeF &operator*=(qreal c);
- QSizeF &operator/=(qreal c);
+ inline QSizeF &operator+=(const QSizeF &);
+ inline QSizeF &operator-=(const QSizeF &);
+ inline QSizeF &operator*=(qreal c);
+ inline QSizeF &operator/=(qreal c);
friend Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &, const QSizeF &);
friend Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &, const QSizeF &);
diff --git a/src/corelib/tools/qstack.cpp b/src/corelib/tools/qstack.cpp
index 888fbfa0b4..359705887e 100644
--- a/src/corelib/tools/qstack.cpp
+++ b/src/corelib/tools/qstack.cpp
@@ -58,7 +58,7 @@
Example:
- \snippet doc/src/snippets/qstack/main.cpp 0
+ \snippet qstack/main.cpp 0
The example will output 3, 2, 1 in that order.
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index ed0c493c7a..04626742bd 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -421,7 +421,7 @@ const QString::Null QString::null = { };
Most of the QChar member functions also exist in QCharRef.
However, they are not explicitly documented here.
- \sa QString::operator[]() QString::at() QChar
+ \sa QString::operator[](), QString::at(), QChar
*/
/*!
@@ -467,7 +467,7 @@ const QString::Null QString::null = { };
*} to its constructor. For example, the following code creates a
QString of size 5 containing the data "Hello":
- \snippet doc/src/snippets/qstring/main.cpp 0
+ \snippet qstring/main.cpp 0
QString converts the \c{const char *} data into Unicode using the
fromAscii() function. fromAscii() treats ordinals above 128 as Latin-1
@@ -480,7 +480,7 @@ const QString::Null QString::null = { };
You can also provide string data as an array of \l{QChar}s:
- \snippet doc/src/snippets/qstring/main.cpp 1
+ \snippet qstring/main.cpp 1
QString makes a deep copy of the QChar data, so you can modify it
later without experiencing side effects. (If for performance
@@ -495,12 +495,12 @@ const QString::Null QString::null = { };
character that can be used on the left side of an assignment. For
example:
- \snippet doc/src/snippets/qstring/main.cpp 2
+ \snippet qstring/main.cpp 2
For read-only access, an alternative syntax is to use the at()
function:
- \snippet doc/src/snippets/qstring/main.cpp 3
+ \snippet qstring/main.cpp 3
The at() function can be faster than \l operator[](), because it
never causes a \l{deep copy} to occur. Alternatively, use the
@@ -519,7 +519,7 @@ const QString::Null QString::null = { };
usage. For example, if you want to compare a QString with a string
literal, you can write code like this and it will work as expected:
- \snippet doc/src/snippets/qstring/main.cpp 4
+ \snippet qstring/main.cpp 4
You can also pass string literals to functions that take QStrings
as arguments, invoking the QString(const char *)
@@ -534,7 +534,7 @@ const QString::Null QString::null = { };
character data: append(), prepend(), insert(), replace(), and
remove(). For example:
- \snippet doc/src/snippets/qstring/main.cpp 5
+ \snippet qstring/main.cpp 5
If you are building a QString gradually and know in advance
approximately how many characters the QString will contain, you
@@ -563,7 +563,7 @@ const QString::Null QString::null = { };
they return -1. For example, here's a typical loop that finds all
occurrences of a particular substring:
- \snippet doc/src/snippets/qstring/main.cpp 6
+ \snippet qstring/main.cpp 6
QString provides many functions for converting numbers into
strings and strings into numbers. See the arg() functions, the
@@ -642,14 +642,14 @@ const QString::Null QString::null = { };
application is to add the following entry to your
\l{qmake Project Files}{qmake project file}:
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 0
+ \snippet code/src_corelib_tools_qstring.cpp 0
You then need to explicitly call fromAscii(), fromLatin1(),
fromUtf8(), or fromLocal8Bit() to construct a QString from an
8-bit string, or use the lightweight QLatin1String class, for
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 1
+ \snippet code/src_corelib_tools_qstring.cpp 1
Similarly, you must call toAscii(), toLatin1(), toUtf8(), or
toLocal8Bit() explicitly to convert the QString to an 8-bit
@@ -666,7 +666,7 @@ const QString::Null QString::null = { };
\l{implicitly shared}, QStrings may be treated like \c{int}s or
other basic types. For example:
- \snippet doc/src/snippets/qstring/main.cpp 7
+ \snippet qstring/main.cpp 7
The \c result variable, is a normal variable allocated on the
stack. When \c return is called, and because we're returning by
@@ -685,7 +685,7 @@ const QString::Null QString::null = { };
string with size 0. A null string is always empty, but an empty
string isn't necessarily null:
- \snippet doc/src/snippets/qstring/main.cpp 8
+ \snippet qstring/main.cpp 8
All functions except isNull() treat null strings the same as empty
strings. For example, toAscii().constData() returns a pointer to a
@@ -732,7 +732,7 @@ const QString::Null QString::null = { };
complex string from multiple substrings. You will often write code
like this:
- \snippet doc/src/snippets/qstring/stringbuilder.cpp 0
+ \snippet qstring/stringbuilder.cpp 0
There is nothing wrong with either of these string constructions,
but there are a few hidden inefficiencies. Beginning with Qt 4.6,
@@ -770,13 +770,13 @@ const QString::Null QString::null = { };
\c{QStringBuilder} wherever you want to use it, and use the
\c{'%'} operator instead of \c{'+'} when concatenating strings:
- \snippet doc/src/snippets/qstring/stringbuilder.cpp 5
+ \snippet qstring/stringbuilder.cpp 5
A more global approach which is the most convenient but
not entirely source compatible, is to this define in your
.pro file:
- \snippet doc/src/snippets/qstring/stringbuilder.cpp 3
+ \snippet qstring/stringbuilder.cpp 3
and the \c{'+'} will automatically be performed as the
\c{QStringBuilder} \c{'%'} everywhere.
@@ -1175,12 +1175,12 @@ QString::QString(QChar ch)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 45
+ \snippet qstring/main.cpp 45
If you want to append a certain number of identical characters to
the string, use \l operator+=() as follows rather than resize():
- \snippet doc/src/snippets/qstring/main.cpp 46
+ \snippet qstring/main.cpp 46
If you want to expand the string so that it reaches a certain
width and fill the new positions with a particular character, use
@@ -1188,7 +1188,7 @@ QString::QString(QChar ch)
If \a size is negative, it is equivalent to passing zero.
- \snippet doc/src/snippets/qstring/main.cpp 47
+ \snippet qstring/main.cpp 47
\sa truncate(), reserve()
*/
@@ -1253,7 +1253,7 @@ void QString::resize(int size)
we're fairly sure that size is large enough to make a call to
reserve() worthwhile:
- \snippet doc/src/snippets/qstring/main.cpp 44
+ \snippet qstring/main.cpp 44
\sa squeeze(), capacity()
*/
@@ -1394,7 +1394,7 @@ QString &QString::operator=(QChar ch)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 26
+ \snippet qstring/main.cpp 26
If the given \a position is greater than size(), the array is
first extended using resize().
@@ -1478,11 +1478,11 @@ QString& QString::insert(int i, QChar ch)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 9
+ \snippet qstring/main.cpp 9
This is the same as using the insert() function:
- \snippet doc/src/snippets/qstring/main.cpp 10
+ \snippet qstring/main.cpp 10
The append() function is typically very fast (\l{constant time}),
because QString preallocates extra space at the end of the string
@@ -1574,7 +1574,7 @@ QString &QString::append(QChar ch)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 36
+ \snippet qstring/main.cpp 36
\sa append(), insert()
*/
@@ -1629,7 +1629,7 @@ QString &QString::append(QChar ch)
position + \a n is beyond the end of the string, the string is
truncated at the specified \a position.
- \snippet doc/src/snippets/qstring/main.cpp 37
+ \snippet qstring/main.cpp 37
\sa insert(), replace()
*/
@@ -1680,7 +1680,7 @@ QString &QString::remove(const QString &str, Qt::CaseSensitivity cs)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 38
+ \snippet qstring/main.cpp 38
This is the same as \c replace(ch, "", cs).
@@ -1713,7 +1713,7 @@ QString &QString::remove(QChar ch, Qt::CaseSensitivity cs)
Removes every occurrence of the regular expression \a rx in the
string, and returns a reference to the string. For example:
- \snippet doc/src/snippets/qstring/main.cpp 39
+ \snippet qstring/main.cpp 39
\sa indexOf(), lastIndexOf(), replace()
*/
@@ -1725,7 +1725,7 @@ QString &QString::remove(QChar ch, Qt::CaseSensitivity cs)
Removes every occurrence of the regular expression \a re in the
string, and returns a reference to the string. For example:
- \snippet doc/src/snippets/qstring/main.cpp 96
+ \snippet qstring/main.cpp 96
\sa indexOf(), lastIndexOf(), replace()
*/
@@ -1738,7 +1738,7 @@ QString &QString::remove(QChar ch, Qt::CaseSensitivity cs)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 40
+ \snippet qstring/main.cpp 40
\sa insert(), remove()
*/
@@ -1789,13 +1789,13 @@ QString &QString::replace(int pos, int len, QChar after)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 41
+ \snippet qstring/main.cpp 41
\note The replacement text is not rescanned after it is inserted.
Example:
- \snippet doc/src/snippets/qstring/main.cpp 86
+ \snippet qstring/main.cpp 86
*/
QString &QString::replace(const QString &before, const QString &after, Qt::CaseSensitivity cs)
{
@@ -2214,7 +2214,7 @@ bool QString::operator<(const QLatin1String &other) const
\overload operator<()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded
+ fromAscii() function. If any NUL characters ('\\0') are embedded
in the byte array, they will be included in the transformation.
You can disable this operator by defining \c
@@ -2236,8 +2236,7 @@ bool QString::operator<(const QLatin1String &other) const
go through QObject::tr(), for example.
*/
-/*! \fn bool operator<=(const QString &s1, const QString &s2)
- \relates QString
+/*! \fn bool QString::operator<=(const QString &s1, const QString &s2)
Returns true if string \a s1 is lexically less than or equal to
string \a s2; otherwise returns false.
@@ -2258,7 +2257,7 @@ bool QString::operator<(const QLatin1String &other) const
\overload operator<=()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded
+ fromAscii() function. If any NUL characters ('\\0') are embedded
in the byte array, they will be included in the transformation.
You can disable this operator by defining \c
@@ -2280,8 +2279,7 @@ bool QString::operator<(const QLatin1String &other) const
go through QObject::tr(), for example.
*/
-/*! \fn bool operator>(const QString &s1, const QString &s2)
- \relates QString
+/*! \fn bool QString::operator>(const QString &s1, const QString &s2)
Returns true if string \a s1 is lexically greater than string \a
s2; otherwise returns false.
@@ -2318,7 +2316,7 @@ bool QString::operator>(const QLatin1String &other) const
\overload operator>()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded
+ fromAscii() function. If any NUL characters ('\\0') are embedded
in the byte array, they will be included in the transformation.
You can disable this operator by defining \c
@@ -2362,7 +2360,7 @@ bool QString::operator>(const QLatin1String &other) const
\overload operator>=()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded in
+ fromAscii() function. If any NUL characters ('\\0') are embedded in
the byte array, they will be included in the transformation.
You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII
@@ -2406,7 +2404,7 @@ bool QString::operator>(const QLatin1String &other) const
\overload operator!=()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded
+ fromAscii() function. If any NUL characters ('\\0') are embedded
in the byte array, they will be included in the transformation.
You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII
@@ -2438,7 +2436,7 @@ bool QString::operator>(const QLatin1String &other) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 24
+ \snippet qstring/main.cpp 24
If \a from is -1, the search starts at the last character; if it is
-2, at the next to last character and so on.
@@ -2461,7 +2459,7 @@ int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 24
+ \snippet qstring/main.cpp 24
If \a from is -1, the search starts at the last character; if it is
-2, at the next to last character and so on.
@@ -2636,7 +2634,7 @@ static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *nee
Example:
- \snippet doc/src/snippets/qstring/main.cpp 29
+ \snippet qstring/main.cpp 29
\sa indexOf(), contains(), count()
*/
@@ -2675,7 +2673,7 @@ int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) c
Example:
- \snippet doc/src/snippets/qstring/main.cpp 29
+ \snippet qstring/main.cpp 29
\sa indexOf(), contains(), count()
*/
@@ -2765,13 +2763,13 @@ struct QStringCapture
string with \a after. Returns a reference to the string. For
example:
- \snippet doc/src/snippets/qstring/main.cpp 42
+ \snippet qstring/main.cpp 42
For regular expressions containing \l{capturing parentheses},
occurrences of \b{\\1}, \b{\\2}, ..., in \a after are replaced
with \a{rx}.cap(1), cap(2), ...
- \snippet doc/src/snippets/qstring/main.cpp 43
+ \snippet qstring/main.cpp 43
\sa indexOf(), lastIndexOf(), remove(), QRegExp::cap()
*/
@@ -2923,13 +2921,13 @@ QString& QString::replace(const QRegExp &rx, const QString &after)
string with \a after. Returns a reference to the string. For
example:
- \snippet doc/src/snippets/qstring/main.cpp 87
+ \snippet qstring/main.cpp 87
For regular expressions containing capturing groups,
- occurrences of \bold{\\1}, \bold{\\2}, ..., in \a after are replaced
+ occurrences of \b{\\1}, \b{\\2}, ..., in \a after are replaced
with the string captured by the corresponding capturing group.
- \snippet doc/src/snippets/qstring/main.cpp 88
+ \snippet qstring/main.cpp 88
\sa indexOf(), lastIndexOf(), remove(), QRegularExpression, QRegularExpressionMatch
*/
@@ -3097,7 +3095,7 @@ int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const
case sensitive; otherwise the search is case insensitive.
Example:
- \snippet doc/src/snippets/qstring/main.cpp 17
+ \snippet qstring/main.cpp 17
\sa indexOf(), count()
*/
@@ -3151,7 +3149,7 @@ int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 25
+ \snippet qstring/main.cpp 25
*/
int QString::indexOf(const QRegExp& rx, int from) const
{
@@ -3172,7 +3170,7 @@ int QString::indexOf(const QRegExp& rx, int from) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 25
+ \snippet qstring/main.cpp 25
*/
int QString::indexOf(QRegExp& rx, int from) const
{
@@ -3188,7 +3186,7 @@ int QString::indexOf(QRegExp& rx, int from) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 30
+ \snippet qstring/main.cpp 30
*/
int QString::lastIndexOf(const QRegExp& rx, int from) const
{
@@ -3209,7 +3207,7 @@ int QString::lastIndexOf(const QRegExp& rx, int from) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 30
+ \snippet qstring/main.cpp 30
*/
int QString::lastIndexOf(QRegExp& rx, int from) const
{
@@ -3225,7 +3223,7 @@ int QString::lastIndexOf(QRegExp& rx, int from) const
This function counts overlapping matches, so in the example
below, there are four instances of "ana" or "ama":
- \snippet doc/src/snippets/qstring/main.cpp 18
+ \snippet qstring/main.cpp 18
*/
int QString::count(const QRegExp& rx) const
@@ -3256,7 +3254,7 @@ int QString::count(const QRegExp& rx) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 93
+ \snippet qstring/main.cpp 93
*/
int QString::indexOf(const QRegularExpression& re, int from) const
{
@@ -3282,7 +3280,7 @@ int QString::indexOf(const QRegularExpression& re, int from) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 94
+ \snippet qstring/main.cpp 94
*/
int QString::lastIndexOf(const QRegularExpression &re, int from) const
{
@@ -3333,7 +3331,7 @@ bool QString::contains(const QRegularExpression &re) const
This function counts overlapping matches, so in the example
below, there are four instances of "ana" or "ama":
- \snippet doc/src/snippets/qstring/main.cpp 95
+ \snippet qstring/main.cpp 95
*/
int QString::count(const QRegularExpression &re) const
{
@@ -3408,13 +3406,13 @@ int QString::count(const QRegularExpression &re) const
to skip empty fields and how to deal with leading and trailing
separators; see \l{SectionFlags}.
- \snippet doc/src/snippets/qstring/main.cpp 52
+ \snippet qstring/main.cpp 52
If \a start or \a end is negative, we count fields from the right
of the string, the right-most field being -1, the one from
right-most field being -2, and so on.
- \snippet doc/src/snippets/qstring/main.cpp 53
+ \snippet qstring/main.cpp 53
\sa split()
*/
@@ -3422,8 +3420,8 @@ int QString::count(const QRegularExpression &re) const
/*!
\overload section()
- \snippet doc/src/snippets/qstring/main.cpp 51
- \snippet doc/src/snippets/qstring/main.cpp 54
+ \snippet qstring/main.cpp 51
+ \snippet qstring/main.cpp 54
\sa split()
*/
@@ -3532,12 +3530,12 @@ static QString extractSections(const QList<qt_section_chunk> &sections,
This string is treated as a sequence of fields separated by the
regular expression, \a reg.
- \snippet doc/src/snippets/qstring/main.cpp 55
+ \snippet qstring/main.cpp 55
\warning Using this QRegExp version is much more expensive than
the overloaded string and character versions.
- \sa split() simplified()
+ \sa split(), simplified()
*/
QString QString::section(const QRegExp &reg, int start, int end, SectionFlags flags) const
{
@@ -3572,12 +3570,12 @@ QString QString::section(const QRegExp &reg, int start, int end, SectionFlags fl
This string is treated as a sequence of fields separated by the
regular expression, \a re.
- \snippet doc/src/snippets/qstring/main.cpp 89
+ \snippet qstring/main.cpp 89
\warning Using this QRegularExpression version is much more expensive than
the overloaded string and character versions.
- \sa split() simplified()
+ \sa split(), simplified()
*/
QString QString::section(const QRegularExpression &re, int start, int end, SectionFlags flags) const
{
@@ -3618,7 +3616,7 @@ QString QString::section(const QRegularExpression &re, int start, int end, Secti
The entire string is returned if \a n is greater than size() or
less than zero.
- \snippet doc/src/snippets/qstring/main.cpp 31
+ \snippet qstring/main.cpp 31
\sa right(), mid(), startsWith()
*/
@@ -3636,7 +3634,7 @@ QString QString::left(int n) const
The entire string is returned if \a n is greater than size() or
less than zero.
- \snippet doc/src/snippets/qstring/main.cpp 48
+ \snippet qstring/main.cpp 48
\sa left(), mid(), endsWith()
*/
@@ -3659,7 +3657,7 @@ QString QString::right(int n) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 34
+ \snippet qstring/main.cpp 34
\sa left(), right()
*/
@@ -3690,7 +3688,7 @@ QString QString::mid(int position, int n) const
If \a cs is Qt::CaseSensitive (default), the search is
case sensitive; otherwise the search is case insensitive.
- \snippet doc/src/snippets/qstring/main.cpp 65
+ \snippet qstring/main.cpp 65
\sa endsWith()
*/
@@ -3746,7 +3744,7 @@ bool QString::startsWith(const QStringRef &s, Qt::CaseSensitivity cs) const
If \a cs is Qt::CaseSensitive (default), the search is case
sensitive; otherwise the search is case insensitive.
- \snippet doc/src/snippets/qstring/main.cpp 20
+ \snippet qstring/main.cpp 20
\sa startsWith()
*/
@@ -4248,7 +4246,7 @@ QString& QString::setUnicode(const QChar *unicode, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 57
+ \snippet qstring/main.cpp 57
\sa trimmed()
*/
@@ -4338,7 +4336,7 @@ QString QString::simplified() const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 82
+ \snippet qstring/main.cpp 82
Unlike simplified(), trimmed() leaves internal whitespace alone.
@@ -4386,7 +4384,7 @@ QString QString::trimmed() const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 85
+ \snippet qstring/main.cpp 85
The return value is of type QCharRef, a helper class for QString.
When you get an object of type QCharRef, you can use it as if it
@@ -4425,7 +4423,7 @@ modifiable reference. Equivalent to \c at(position).
Example:
- \snippet doc/src/snippets/qstring/main.cpp 83
+ \snippet qstring/main.cpp 83
If \a position is negative, it is equivalent to passing zero.
@@ -4445,7 +4443,7 @@ void QString::truncate(int pos)
If \a n is greater than size(), the result is an empty string.
Example:
- \snippet doc/src/snippets/qstring/main.cpp 15
+ \snippet qstring/main.cpp 15
If you want to remove characters from the \e beginning of the
string, use remove() instead.
@@ -4465,7 +4463,7 @@ void QString::chop(int n)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 21
+ \snippet qstring/main.cpp 21
\sa resize()
*/
@@ -4504,7 +4502,7 @@ QString& QString::fill(QChar ch, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 58
+ \snippet qstring/main.cpp 58
\sa isEmpty(), resize()
*/
@@ -4515,7 +4513,7 @@ QString& QString::fill(QChar ch, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 28
+ \snippet qstring/main.cpp 28
Qt makes a distinction between null strings and empty strings for
historical reasons. For most applications, what matters is
@@ -4532,7 +4530,7 @@ QString& QString::fill(QChar ch, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 27
+ \snippet qstring/main.cpp 27
\sa size()
*/
@@ -4544,7 +4542,7 @@ QString& QString::fill(QChar ch, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 84
+ \snippet qstring/main.cpp 84
This operation is typically very fast (\l{constant time}),
because QString preallocates extra space at the end of the string
@@ -4566,7 +4564,7 @@ QString& QString::fill(QChar ch, int size)
\overload operator+=()
Appends the byte array \a ba to this string. The byte array is converted
- to Unicode using the fromAscii() function. If any NUL characters ('\0')
+ to Unicode using the fromAscii() function. If any NUL characters ('\\0')
are embedded in the \a ba byte array, they will be included in the
transformation.
@@ -4773,7 +4771,7 @@ QString& QString::fill(QChar ch, int size)
a human would expect. Consider sorting user-visible strings with
localeAwareCompare().
- \snippet doc/src/snippets/qstring/main.cpp 16
+ \snippet qstring/main.cpp 16
\sa operator==(), operator<(), operator>()
*/
@@ -5057,13 +5055,13 @@ const ushort *QString::utf16() const
If \a truncate is false and the size() of the string is more than
\a width, then the returned string is a copy of the string.
- \snippet doc/src/snippets/qstring/main.cpp 32
+ \snippet qstring/main.cpp 32
If \a truncate is true and the size() of the string is more than
\a width, then any characters in a copy of the string after
position \a width are removed, and the copy is returned.
- \snippet doc/src/snippets/qstring/main.cpp 33
+ \snippet qstring/main.cpp 33
\sa rightJustified()
*/
@@ -5093,7 +5091,7 @@ QString QString::leftJustified(int width, QChar fill, bool truncate) const
Returns a string of size() \a width that contains the \a fill
character followed by the string. For example:
- \snippet doc/src/snippets/qstring/main.cpp 49
+ \snippet qstring/main.cpp 49
If \a truncate is false and the size() of the string is more than
\a width, then the returned string is a copy of the string.
@@ -5102,7 +5100,7 @@ QString QString::leftJustified(int width, QChar fill, bool truncate) const
\a width, then the resulting string is truncated at position \a
width.
- \snippet doc/src/snippets/qstring/main.cpp 50
+ \snippet qstring/main.cpp 50
\sa leftJustified()
*/
@@ -5131,7 +5129,7 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const
/*!
Returns a lowercase copy of the string.
- \snippet doc/src/snippets/qstring/main.cpp 75
+ \snippet qstring/main.cpp 75
The case conversion will always happen in the 'C' locale. For locale dependent
case folding use QLocale::toLower()
@@ -5233,7 +5231,20 @@ QString QString::toCaseFolded() const
prop = qGetProp(*p);
}
if (prop->caseFoldSpecial) {
+ const ushort *specialCase = specialCaseMap + prop->caseFoldDiff;
+ ushort length = *specialCase++;
+#if 0
+ int pos = pp - s.d->data;
+ s.resize(s.d->size + length - 1);
+ pp = s.d->data + pos;
+ while (length--)
+ *pp++ = *specialCase++;
+#else
//### we currently don't support full case foldings
+ Q_ASSERT(length == 1);
+ Q_UNUSED(length)
+ *pp++ = *specialCase;
+#endif
} else {
*pp++ = *p + prop->caseFoldDiff;
}
@@ -5254,7 +5265,7 @@ QString QString::toCaseFolded() const
/*!
Returns an uppercase copy of the string.
- \snippet doc/src/snippets/qstring/main.cpp 81
+ \snippet qstring/main.cpp 81
The case conversion will always happen in the 'C' locale. For locale dependent
case folding use QLocale::toUpper()
@@ -5337,14 +5348,14 @@ QString QString::toUpper() const
\c{long long}). If you need those, use the standard snprintf()
function instead:
- \snippet doc/src/snippets/qstring/main.cpp 63
+ \snippet qstring/main.cpp 63
\warning We do not recommend using QString::sprintf() in new Qt
code. Instead, consider using QTextStream or arg(), both of
which support Unicode strings seamlessly and are type-safe.
Here's an example that uses QTextStream:
- \snippet doc/src/snippets/qstring/main.cpp 64
+ \snippet qstring/main.cpp 64
For \l {QObject::tr()}{translations}, especially if the strings
contains more than one escape sequence, you should consider using
@@ -5552,7 +5563,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
case lm_t: i = va_arg(ap, int); break;
default: i = 0; break;
}
- subst = locale.d()->longLongToString(i, precision, 10, width, flags);
+ subst = locale.d->longLongToString(i, precision, 10, width, flags);
++c;
break;
}
@@ -5584,7 +5595,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
base = 16; break;
default: break;
}
- subst = locale.d()->unsLongLongToString(u, precision, base, width, flags);
+ subst = locale.d->unsLongLongToString(u, precision, base, width, flags);
++c;
break;
}
@@ -5613,7 +5624,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
case 'g': form = QLocalePrivate::DFSignificantDigits; break;
default: break;
}
- subst = locale.d()->doubleToString(d, precision, form, width, flags);
+ subst = locale.d->doubleToString(d, precision, form, width, flags);
++c;
break;
}
@@ -5647,7 +5658,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
quint64 i = reinterpret_cast<unsigned long>(arg);
#endif
flags |= QLocalePrivate::Alternate;
- subst = locale.d()->unsLongLongToString(i, precision, 16, width, flags);
+ subst = locale.d->unsLongLongToString(i, precision, 16, width, flags);
++c;
break;
}
@@ -5717,7 +5728,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 74
+ \snippet qstring/main.cpp 74
\sa number(), toULongLong(), toInt(), QLocale::toLongLong()
*/
@@ -5732,7 +5743,7 @@ qint64 QString::toLongLong(bool *ok, int base) const
#endif
QLocale c_locale(QLocale::C);
- return c_locale.d()->stringToLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
+ return c_locale.d->stringToLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
}
/*!
@@ -5752,7 +5763,7 @@ qint64 QString::toLongLong(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 79
+ \snippet qstring/main.cpp 79
\sa number(), toLongLong(), QLocale::toULongLong()
*/
@@ -5767,7 +5778,7 @@ quint64 QString::toULongLong(bool *ok, int base) const
#endif
QLocale c_locale(QLocale::C);
- return c_locale.d()->stringToUnsLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
+ return c_locale.d->stringToUnsLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
}
/*!
@@ -5789,7 +5800,7 @@ quint64 QString::toULongLong(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 73
+ \snippet qstring/main.cpp 73
\sa number(), toULong(), toInt(), QLocale::toLong()
*/
@@ -5824,7 +5835,7 @@ long QString::toLong(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 78
+ \snippet qstring/main.cpp 78
\sa number(), QLocale::toULong()
*/
@@ -5858,7 +5869,7 @@ ulong QString::toULong(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 72
+ \snippet qstring/main.cpp 72
\sa number(), toUInt(), toDouble(), QLocale::toInt()
*/
@@ -5891,7 +5902,7 @@ int QString::toInt(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 77
+ \snippet qstring/main.cpp 77
\sa number(), toInt(), QLocale::toUInt()
*/
@@ -5924,7 +5935,7 @@ uint QString::toUInt(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 76
+ \snippet qstring/main.cpp 76
\sa number(), toUShort(), toInt(), QLocale::toShort()
*/
@@ -5957,7 +5968,7 @@ short QString::toShort(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 80
+ \snippet qstring/main.cpp 80
\sa number(), toShort(), QLocale::toUShort()
*/
@@ -5982,31 +5993,31 @@ ushort QString::toUShort(bool *ok, int base) const
If a conversion error occurs, \c{*}\a{ok} is set to false;
otherwise \c{*}\a{ok} is set to true.
- \snippet doc/src/snippets/qstring/main.cpp 66
+ \snippet qstring/main.cpp 66
Various string formats for floating point numbers can be converted
to double values:
- \snippet doc/src/snippets/qstring/main.cpp 67
+ \snippet qstring/main.cpp 67
The string conversion will always happen in the 'C' locale. For locale
dependent conversion use QLocale::toDouble()
- \snippet doc/src/snippets/qstring/main.cpp 68
+ \snippet qstring/main.cpp 68
For historic reasons, this function does not handle
thousands group separators. If you need to convert such numbers,
use QLocale::toDouble().
- \snippet doc/src/snippets/qstring/main.cpp 69
+ \snippet qstring/main.cpp 69
- \sa number() QLocale::setDefault() QLocale::toDouble() trimmed()
+ \sa number(), QLocale::setDefault(), QLocale::toDouble(), trimmed()
*/
double QString::toDouble(bool *ok) const
{
QLocale c_locale(QLocale::C);
- return c_locale.d()->stringToDouble(*this, ok, QLocalePrivate::FailOnGroupSeparators);
+ return c_locale.d->stringToDouble(*this, ok, QLocalePrivate::FailOnGroupSeparators);
}
/*!
@@ -6020,7 +6031,7 @@ double QString::toDouble(bool *ok) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 71
+ \snippet qstring/main.cpp 71
\sa number(), toDouble(), toInt(), QLocale::toFloat()
*/
@@ -6049,7 +6060,7 @@ float QString::toFloat(bool *ok) const
The base is 10 by default and must be between 2 and 36. For bases
other than 10, \a n is treated as an unsigned integer.
- \snippet doc/src/snippets/qstring/main.cpp 56
+ \snippet qstring/main.cpp 56
The formatting always uses QLocale::C, i.e., English/UnitedStates.
To get a localized string representation of a number, use
@@ -6083,7 +6094,7 @@ QString &QString::setNum(qlonglong n, int base)
}
#endif
QLocale locale(QLocale::C);
- *this = locale.d()->longLongToString(n, -1, base);
+ *this = locale.d->longLongToString(n, -1, base);
return *this;
}
@@ -6099,7 +6110,7 @@ QString &QString::setNum(qulonglong n, int base)
}
#endif
QLocale locale(QLocale::C);
- *this = locale.d()->unsLongLongToString(n, -1, base);
+ *this = locale.d->unsLongLongToString(n, -1, base);
return *this;
}
@@ -6156,7 +6167,7 @@ QString &QString::setNum(double n, char f, int prec)
}
QLocale locale(QLocale::C);
- *this = locale.d()->doubleToString(n, prec, form, -1, flags);
+ *this = locale.d->doubleToString(n, prec, form, -1, flags);
return *this;
}
@@ -6188,7 +6199,7 @@ QString &QString::setNum(double n, char f, int prec)
To get a localized string representation of a number, use
QLocale::toString() with the appropriate locale.
- \snippet doc/src/snippets/qstring/main.cpp 35
+ \snippet qstring/main.cpp 35
\sa setNum()
*/
@@ -6286,7 +6297,7 @@ QString QString::number(double n, char f, int prec)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 62
+ \snippet qstring/main.cpp 62
\sa QStringList::join(), section()
*/
@@ -6337,18 +6348,18 @@ QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivit
Here's an example where we extract the words in a sentence
using one or more whitespace characters as the separator:
- \snippet doc/src/snippets/qstring/main.cpp 59
+ \snippet qstring/main.cpp 59
Here's a similar example, but this time we use any sequence of
non-word characters as the separator:
- \snippet doc/src/snippets/qstring/main.cpp 60
+ \snippet qstring/main.cpp 60
Here's a third example where we use a zero-length assertion,
\b{\\b} (word boundary), to split the string into an
alternating sequence of non-word and word tokens:
- \snippet doc/src/snippets/qstring/main.cpp 61
+ \snippet qstring/main.cpp 61
\sa QStringList::join(), section()
*/
@@ -6386,18 +6397,18 @@ QStringList QString::split(const QRegExp &rx, SplitBehavior behavior) const
Here's an example where we extract the words in a sentence
using one or more whitespace characters as the separator:
- \snippet doc/src/snippets/qstring/main.cpp 90
+ \snippet qstring/main.cpp 90
Here's a similar example, but this time we use any sequence of
non-word characters as the separator:
- \snippet doc/src/snippets/qstring/main.cpp 91
+ \snippet qstring/main.cpp 91
Here's a third example where we use a zero-length assertion,
- \bold{\\b} (word boundary), to split the string into an
+ \b{\\b} (word boundary), to split the string into an
alternating sequence of non-word and word tokens:
- \snippet doc/src/snippets/qstring/main.cpp 92
+ \snippet qstring/main.cpp 92
\sa QStringList::join(), section()
*/
@@ -6738,7 +6749,7 @@ static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int f
This example shows how we might create a \c status string for
reporting progress while processing a list of files:
- \snippet doc/src/snippets/qstring/main.cpp 11
+ \snippet qstring/main.cpp 11
First, \c arg(i) replaces \c %1. Then \c arg(total) replaces \c
%2. Finally, \c arg(fileName) replaces \c %3.
@@ -6774,7 +6785,7 @@ QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const
strings \a a1 and \a a2 are replaced in one pass. This can make a
difference if \a a1 contains e.g. \c{%1}:
- \snippet doc/src/snippets/qstring/main.cpp 13
+ \snippet qstring/main.cpp 13
*/
/*!
@@ -6861,8 +6872,8 @@ QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const
locale was specified, the "C" locale is used. The 'L' flag is
ignored if \a base is not 10.
- \snippet doc/src/snippets/qstring/main.cpp 12
- \snippet doc/src/snippets/qstring/main.cpp 14
+ \snippet qstring/main.cpp 12
+ \snippet qstring/main.cpp 14
If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is
used. For negative numbers, zero padding might appear before the
@@ -6898,8 +6909,8 @@ QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const
using QLocale::setDefault(). The 'L' flag is ignored if \a base is
not 10.
- \snippet doc/src/snippets/qstring/main.cpp 12
- \snippet doc/src/snippets/qstring/main.cpp 14
+ \snippet qstring/main.cpp 12
+ \snippet qstring/main.cpp 14
If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is
used. For negative numbers, zero padding might appear before the
@@ -6954,14 +6965,14 @@ QString QString::arg(qlonglong a, int fieldWidth, int base, QChar fillChar) cons
QString arg;
if (d.occurrences > d.locale_occurrences)
- arg = QLocale::c().d()->longLongToString(a, -1, base, fieldWidth, flags);
+ arg = QLocale::c().d->longLongToString(a, -1, base, fieldWidth, flags);
QString locale_arg;
if (d.locale_occurrences > 0) {
QLocale locale;
if (!locale.numberOptions() & QLocale::OmitGroupSeparator)
flags |= QLocalePrivate::ThousandsGroup;
- locale_arg = locale.d()->longLongToString(a, -1, base, fieldWidth, flags);
+ locale_arg = locale.d->longLongToString(a, -1, base, fieldWidth, flags);
}
return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);
@@ -6998,14 +7009,14 @@ QString QString::arg(qulonglong a, int fieldWidth, int base, QChar fillChar) con
QString arg;
if (d.occurrences > d.locale_occurrences)
- arg = QLocale::c().d()->unsLongLongToString(a, -1, base, fieldWidth, flags);
+ arg = QLocale::c().d->unsLongLongToString(a, -1, base, fieldWidth, flags);
QString locale_arg;
if (d.locale_occurrences > 0) {
QLocale locale;
if (!locale.numberOptions() & QLocale::OmitGroupSeparator)
flags |= QLocalePrivate::ThousandsGroup;
- locale_arg = locale.d()->unsLongLongToString(a, -1, base, fieldWidth, flags);
+ locale_arg = locale.d->unsLongLongToString(a, -1, base, fieldWidth, flags);
}
return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);
@@ -7082,7 +7093,7 @@ QString QString::arg(char a, int fieldWidth, QChar fillChar) const
value produces right-aligned text; a negative value produces
left-aligned text.
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 2
+ \snippet code/src_corelib_tools_qstring.cpp 2
The '%' can be followed by an 'L', in which case the sequence is
replaced with a localized representation of \a a. The conversion
@@ -7132,7 +7143,7 @@ QString QString::arg(double a, int fieldWidth, char fmt, int prec, QChar fillCha
QString arg;
if (d.occurrences > d.locale_occurrences)
- arg = QLocale::c().d()->doubleToString(a, prec, form, fieldWidth, flags);
+ arg = QLocale::c().d->doubleToString(a, prec, form, fieldWidth, flags);
QString locale_arg;
if (d.locale_occurrences > 0) {
@@ -7140,7 +7151,7 @@ QString QString::arg(double a, int fieldWidth, char fmt, int prec, QChar fillCha
if (!locale.numberOptions() & QLocale::OmitGroupSeparator)
flags |= QLocalePrivate::ThousandsGroup;
- locale_arg = locale.d()->doubleToString(a, prec, form, fieldWidth, flags);
+ locale_arg = locale.d->doubleToString(a, prec, form, fieldWidth, flags);
}
return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);
@@ -7278,7 +7289,7 @@ bool QString::isRightToLeft() const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 19
+ \snippet qstring/main.cpp 19
Note that the pointer remains valid only as long as the string is
not modified by other means. For read-only access, constData() is
@@ -7366,8 +7377,8 @@ bool QString::isRightToLeft() const
Here's an example of how we can use a QRegExp on raw data in
memory without requiring to copy the data into a QString:
- \snippet doc/src/snippets/qstring/main.cpp 22
- \snippet doc/src/snippets/qstring/main.cpp 23
+ \snippet qstring/main.cpp 22
+ \snippet qstring/main.cpp 23
\warning A string created with fromRawData() is \e not
'\\0'-terminated, unless the raw data contains a '\\0' character
@@ -7438,11 +7449,11 @@ QString &QString::setRawData(const QChar *unicode, int size)
the \c{const char *} data. For example, assuming \c str is a
QString,
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 3
+ \snippet code/src_corelib_tools_qstring.cpp 3
is much faster than
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 4
+ \snippet code/src_corelib_tools_qstring.cpp 4
because it doesn't construct four temporary QString objects and
make a deep copy of the character data.
@@ -7454,7 +7465,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
just a very thin wrapper around a \c{const char *}. Using
QLatin1String, the example code above becomes
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 5
+ \snippet code/src_corelib_tools_qstring.cpp 5
This is a bit longer to type, but it provides exactly the same
benefits as the first version of the code, and is faster than
@@ -7464,7 +7475,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
QLatin1String can be used everywhere a QString is expected. For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 6
+ \snippet code/src_corelib_tools_qstring.cpp 6
\sa QString, QLatin1Char, QStringLiteral
*/
@@ -8332,7 +8343,7 @@ QString &QString::append(const QStringRef &str)
If \a n is greater than size() or less than zero, a reference to the entire
string is returned.
- \snippet doc/src/snippets/qstring/main.cpp leftRef
+ \snippet qstring/main.cpp leftRef
\sa left(), rightRef(), midRef(), startsWith()
*/
@@ -8352,7 +8363,7 @@ QStringRef QString::leftRef(int n) const
If \a n is greater than size() or less than zero, a reference to the entire
string is returned.
- \snippet doc/src/snippets/qstring/main.cpp rightRef
+ \snippet qstring/main.cpp rightRef
\sa right(), leftRef(), midRef(), endsWith()
*/
@@ -8379,7 +8390,7 @@ QStringRef QString::rightRef(int n) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp midRef
+ \snippet qstring/main.cpp midRef
\sa mid(), leftRef(), rightRef()
*/
@@ -9123,7 +9134,7 @@ QVector<uint> QStringRef::toUcs4() const
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 7
+ \snippet code/src_corelib_tools_qstring.cpp 7
*/
QString QString::toHtmlEscaped() const
{
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 9fcd203a3f..bbfb31aef3 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -448,10 +448,14 @@ public:
{
return fromLocal8Bit_helper(str, (str && size == -1) ? int(strlen(str)) : size);
}
- static inline QString fromAscii(const QByteArray &str) { return fromAscii(str.data(), str.size()); }
- static inline QString fromLatin1(const QByteArray &str) { return fromLatin1(str.data(), str.size()); }
- static inline QString fromUtf8(const QByteArray &str) { return fromUtf8(str.data(), str.size()); }
- static inline QString fromLocal8Bit(const QByteArray &str) { return fromLocal8Bit(str.data(), str.size()); }
+ static inline QString fromAscii(const QByteArray &str)
+ { return fromAscii(str.data(), qstrnlen(str.constData(), str.size())); }
+ static inline QString fromLatin1(const QByteArray &str)
+ { return fromLatin1(str.data(), qstrnlen(str.constData(), str.size())); }
+ static inline QString fromUtf8(const QByteArray &str)
+ { return fromUtf8(str.data(), qstrnlen(str.constData(), str.size())); }
+ static inline QString fromLocal8Bit(const QByteArray &str)
+ { return fromLocal8Bit(str.data(), qstrnlen(str.constData(), 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);
@@ -572,13 +576,13 @@ public:
inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &s) const;
inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &s) const;
inline QT_ASCII_CAST_WARN bool operator<(const QByteArray &s) const
- { return *this < QString::fromAscii(s.constData(), s.size()); }
+ { return *this < QString::fromAscii(s); }
inline QT_ASCII_CAST_WARN bool operator>(const QByteArray &s) const
- { return *this > QString::fromAscii(s.constData(), s.size()); }
+ { return *this > QString::fromAscii(s); }
inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &s) const
- { return *this <= QString::fromAscii(s.constData(), s.size()); }
+ { return *this <= QString::fromAscii(s); }
inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &s) const
- { return *this >= QString::fromAscii(s.constData(), s.size()); }
+ { return *this >= QString::fromAscii(s); }
#endif
typedef QChar *iterator;
@@ -689,17 +693,30 @@ public:
{ return s >= *this; }
inline QT_ASCII_CAST_WARN bool operator==(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) == *this; }
+ { return QString::fromAscii(s) == *this; }
inline QT_ASCII_CAST_WARN bool operator!=(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) != *this; }
+ { return QString::fromAscii(s) != *this; }
inline QT_ASCII_CAST_WARN bool operator<(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) > *this; }
+ { return QString::fromAscii(s) > *this; }
inline QT_ASCII_CAST_WARN bool operator>(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) < *this; }
+ { return QString::fromAscii(s) < *this; }
inline QT_ASCII_CAST_WARN bool operator<=(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) >= *this; }
+ { return QString::fromAscii(s) >= *this; }
inline QT_ASCII_CAST_WARN bool operator>=(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) <= *this; }
+ { return QString::fromAscii(s) <= *this; }
+
+ inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &s) const
+ { return QString::fromAscii(s) == *this; }
+ inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &s) const
+ { return QString::fromAscii(s) != *this; }
+ inline QT_ASCII_CAST_WARN bool operator<(const QByteArray &s) const
+ { return QString::fromAscii(s) > *this; }
+ inline QT_ASCII_CAST_WARN bool operator>(const QByteArray &s) const
+ { return QString::fromAscii(s) < *this; }
+ inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &s) const
+ { return QString::fromAscii(s) >= *this; }
+ inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &s) const
+ { return QString::fromAscii(s) <= *this; }
private:
int m_size;
const char *m_data;
@@ -1016,14 +1033,14 @@ inline bool operator>=(const QLatin1String &s1, const QLatin1String &s2)
inline bool QString::operator==(const QByteArray &s) const
-{ return qStringComparisonHelper(*this, s.constData()); }
+{ return qStringComparisonHelper(*this, s); }
inline bool QString::operator!=(const QByteArray &s) const
-{ return !qStringComparisonHelper(*this, s.constData()); }
+{ return !qStringComparisonHelper(*this, s); }
inline bool QByteArray::operator==(const QString &s) const
-{ return qStringComparisonHelper(s, constData()); }
+{ return qStringComparisonHelper(s, *this); }
inline bool QByteArray::operator!=(const QString &s) const
-{ return !qStringComparisonHelper(s, constData()); }
+{ return !qStringComparisonHelper(s, *this); }
inline bool QByteArray::operator<(const QString &s) const
{ return QString::fromAscii(constData(), size()) < s; }
inline bool QByteArray::operator>(const QString &s) const
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index 6999972172..a044cca3c9 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -95,7 +95,7 @@ QT_BEGIN_NAMESPACE
\c QChar, \c QCharRef, \c QLatin1Char, and \c char.
*/
-/*! \fn QByteArray QStringBuilder::toLatin1() const
+/* \fn QByteArray QStringBuilder::toLatin1() const
Returns a Latin-1 representation of the string as a QByteArray. The
returned byte array is undefined if the string contains non-Latin1
characters.
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp
index bfe2c5ec2d..c25d326b9d 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/tools/qstringlist.cpp
@@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE
{QList::operator+=()}{operator+=()} and \l
{QStringList::operator<<()}{operator<<()} functions. For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 0
+ \snippet qstringlist/main.cpp 0
\section1 Iterating over the strings
@@ -111,15 +111,15 @@ QT_BEGIN_NAMESPACE
Indexing:
- \snippet doc/src/snippets/qstringlist/main.cpp 1
+ \snippet qstringlist/main.cpp 1
Java-style iterator:
- \snippet doc/src/snippets/qstringlist/main.cpp 2
+ \snippet qstringlist/main.cpp 2
STL-style iterator:
- \snippet doc/src/snippets/qstringlist/main.cpp 3
+ \snippet qstringlist/main.cpp 3
The QStringListIterator class is simply a type definition for
QListIterator<QString>. QStringList also provide the
@@ -133,12 +133,12 @@ QT_BEGIN_NAMESPACE
string list into a single string (with an optional separator)
using the join() function. For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 4
+ \snippet qstringlist/main.cpp 4
To break up a string into a string list, use the QString::split()
function:
- \snippet doc/src/snippets/qstringlist/main.cpp 6
+ \snippet qstringlist/main.cpp 6
The argument to split can be a single character, a string, or a
QRegExp.
@@ -152,7 +152,7 @@ QT_BEGIN_NAMESPACE
contain a particular substring (or match a particular regular
expression):
- \snippet doc/src/snippets/qstringlist/main.cpp 7
+ \snippet qstringlist/main.cpp 7
The contains() function tells you whether the list contains a
given string, while the indexOf() function returns the index of
@@ -163,7 +163,7 @@ QT_BEGIN_NAMESPACE
Finally, the replaceInStrings() function calls QString::replace()
on each string in the string list in turn. For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 8
+ \snippet qstringlist/main.cpp 8
\sa QString
*/
@@ -180,7 +180,7 @@ QT_BEGIN_NAMESPACE
Constructs a string list that contains the given string, \a
str. Longer lists are easily created like this:
- \snippet doc/src/snippets/qstringlist/main.cpp 9
+ \snippet qstringlist/main.cpp 9
\sa append()
*/
@@ -255,13 +255,13 @@ void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs)
comparison is case sensitive; otherwise the comparison is case
insensitive.
- \snippet doc/src/snippets/qstringlist/main.cpp 5
- \snippet doc/src/snippets/qstringlist/main.cpp 10
+ \snippet qstringlist/main.cpp 5
+ \snippet qstringlist/main.cpp 10
This is equivalent to
- \snippet doc/src/snippets/qstringlist/main.cpp 11
- \snippet doc/src/snippets/qstringlist/main.cpp 12
+ \snippet qstringlist/main.cpp 11
+ \snippet qstringlist/main.cpp 12
\sa contains()
*/
@@ -348,8 +348,8 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegula
For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 5
- \snippet doc/src/snippets/qstringlist/main.cpp 13
+ \snippet qstringlist/main.cpp 5
+ \snippet qstringlist/main.cpp 13
\sa QString::replace()
*/
@@ -372,8 +372,8 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QString &b
For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 5
- \snippet doc/src/snippets/qstringlist/main.cpp 14
+ \snippet qstringlist/main.cpp 5
+ \snippet qstringlist/main.cpp 14
For regular expressions that contain \l{capturing parentheses},
occurrences of \b{\\1}, \b{\\2}, ..., in \a after are
@@ -381,8 +381,8 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QString &b
For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 5
- \snippet doc/src/snippets/qstringlist/main.cpp 15
+ \snippet qstringlist/main.cpp 5
+ \snippet qstringlist/main.cpp 15
*/
void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &rx, const QString &after)
{
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index f0d8c248b4..0c1ed4de84 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -182,7 +182,7 @@ void QTimeLinePrivate::setCurrentTime(int msecs)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qtimeline.cpp 0
+ \snippet code/src_corelib_tools_qtimeline.cpp 0
You can also use QTimeLine with the
\l{Graphics View}{Graphics View framework} for
diff --git a/src/corelib/tools/qunicodetables.cpp b/src/corelib/tools/qunicodetables.cpp
index 9504e7168e..ea61d2090d 100644
--- a/src/corelib/tools/qunicodetables.cpp
+++ b/src/corelib/tools/qunicodetables.cpp
@@ -41,8 +41,12 @@
/* This file is autogenerated from the Unicode 5.0 database. Do not edit */
+#include "qunicodetables_p.h"
+
QT_BEGIN_NAMESPACE
+namespace QUnicodeTables {
+
static const unsigned short uc_property_trie[] = {
// 0 - 0x11000
@@ -3422,9 +3426,9 @@ static const unsigned short uc_property_trie[] = {
: (uc_property_trie[uc_property_trie[((ucs4 - 0x11000)>>8) + 0x880] + (ucs4 & 0xff)]))
#define GET_PROP_INDEX_UCS2(ucs2) \
-(uc_property_trie[uc_property_trie[ucs2>>5] + (ucs2 & 0x1f)])
+ (uc_property_trie[uc_property_trie[ucs2>>5] + (ucs2 & 0x1f)])
-static const QUnicodeTables::Properties uc_properties[] = {
+static const Properties uc_properties[] = {
{ 9, 19, 18, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0 },
{ 9, 15, 8, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3 },
{ 9, 30, 7, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1 },
@@ -4319,38 +4323,37 @@ static const QUnicodeTables::Properties uc_properties[] = {
{ 3, 10, 2, 0, 0, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7 },
{ 13, 11, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 18, 12, 0, 0, 0, -1, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 },
- { 12, 11, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 12, 11, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
-static inline const QUnicodeTables::Properties *qGetProp(uint ucs4)
+static inline const Properties *qGetProp(uint ucs4)
{
- int index = GET_PROP_INDEX(ucs4);
+ const int index = GET_PROP_INDEX(ucs4);
return uc_properties + index;
}
-static inline const QUnicodeTables::Properties *qGetProp(ushort ucs2)
+static inline const Properties *qGetProp(ushort ucs2)
{
- int index = GET_PROP_INDEX_UCS2(ucs2);
+ const int index = GET_PROP_INDEX_UCS2(ucs2);
return uc_properties + index;
}
-Q_CORE_EXPORT const QUnicodeTables::Properties * QT_FASTCALL QUnicodeTables::properties(uint ucs4)
+Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4)
{
- int index = GET_PROP_INDEX(ucs4);
- return uc_properties + index;
+ return qGetProp(ucs4);
}
-Q_CORE_EXPORT const QUnicodeTables::Properties * QT_FASTCALL QUnicodeTables::properties(ushort ucs2)
+Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2)
{
- int index = GET_PROP_INDEX_UCS2(ucs2);
- return uc_properties + index;
+ return qGetProp(ucs2);
}
-Q_CORE_EXPORT QUnicodeTables::LineBreakClass QT_FASTCALL QUnicodeTables::lineBreakClass(uint ucs4)
+Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4)
{
- return (QUnicodeTables::LineBreakClass)qGetProp(ucs4)->line_break_class;
+ return (LineBreakClass)qGetProp(ucs4)->line_break_class;
}
+
static const ushort specialCaseMap[] = {
0x0, // placeholder
0x2, 0x53, 0x73,
@@ -4449,7 +4452,7 @@ static const ushort specialCaseMap[] = {
0x3, 0x3a9, 0x342, 0x345,
0x3, 0x3a9, 0x342, 0x399
};
-#define SPECIAL_CASE_MAX_LEN 3
+
static const unsigned short uc_decomposition_trie[] = {
// 0 - 0x3400
@@ -5893,7 +5896,7 @@ static const unsigned short uc_decomposition_trie[] = {
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+ 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
};
#define GET_DECOMPOSITION_INDEX(ucs4) \
@@ -5904,7 +5907,6 @@ static const unsigned short uc_decomposition_trie[] = {
: 0xffff))
static const unsigned short uc_decomposition_map[] = {
-
0x103, 0x20, 0x210, 0x20, 0x308, 0x109, 0x61, 0x210,
0x20, 0x304, 0x109, 0x32, 0x109, 0x33, 0x210, 0x20,
0x301, 0x110, 0x3bc, 0x210, 0x20, 0x327, 0x109, 0x31,
@@ -7608,7 +7610,7 @@ static const unsigned short uc_decomposition_map[] = {
0xdd05, 0x201, 0xd868, 0xde0e, 0x201, 0xd868, 0xde91, 0x101,
0x9ebb, 0x101, 0x4d56, 0x101, 0x9ef9, 0x101, 0x9efe, 0x101,
0x9f05, 0x101, 0x9f0f, 0x101, 0x9f16, 0x101, 0x9f3b, 0x201,
- 0xd869, 0xde00,
+ 0xd869, 0xde00
};
static const unsigned short uc_ligature_trie[] = {
@@ -7766,13 +7768,13 @@ static const unsigned short uc_ligature_trie[] = {
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0x700, 0x761, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+ 0xffff, 0x700, 0x761, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
};
-#define GET_LIGATURE_INDEX(u2) (u2 < 0x3100 ? uc_ligature_trie[uc_ligature_trie[u2>>5] + (u2 & 0x1f)] : 0xffff);
+#define GET_LIGATURE_INDEX(u2) \
+ (u2 < 0x3100 ? uc_ligature_trie[uc_ligature_trie[u2>>5] + (u2 & 0x1f)] : 0xffff);
static const unsigned short uc_ligature_map[] = {
-
0x54, 0x41, 0xc0, 0x45, 0xc8, 0x49, 0xcc, 0x4e,
0x1f8, 0x4f, 0xd2, 0x55, 0xd9, 0x57, 0x1e80, 0x59,
0x1ef2, 0x61, 0xe0, 0x65, 0xe8, 0x69, 0xec, 0x6e,
@@ -8011,9 +8013,10 @@ static const unsigned short uc_ligature_map[] = {
0x30f7, 0x30f0, 0x30f8, 0x30f1, 0x30f9, 0x30f2, 0x30fa, 0x30fd,
0x30fe, 0xa, 0x306f, 0x3071, 0x3072, 0x3074, 0x3075, 0x3077,
0x3078, 0x307a, 0x307b, 0x307d, 0x30cf, 0x30d1, 0x30d2, 0x30d4,
- 0x30d5, 0x30d7, 0x30d8, 0x30da, 0x30db, 0x30dd,
+ 0x30d5, 0x30d7, 0x30d8, 0x30da, 0x30db, 0x30dd
};
+
struct NormalizationCorrection {
uint ucs4;
uint old_mapping;
@@ -8032,11 +8035,10 @@ static const NormalizationCorrection uc_normalization_corrections[] = {
enum { NumNormalizationCorrections = 6 };
enum { NormalizationCorrectionsVersionMax = 7 };
+
enum { UnicodeBlockCount = 512 }; // number of unicode blocks
enum { UnicodeBlockSize = 128 }; // size of each block
-namespace QUnicodeTables {
-
static const unsigned char uc_scripts[] = {
Common, /* U+0000-007f */
Common, /* U+0080-00ff */
@@ -9471,9 +9473,7 @@ static const unsigned char uc_scripts[] = {
Common, Common, Common, Common, Common, Common, Common, Common
};
-} // namespace QUnicodeTables
-
-Q_CORE_EXPORT int QT_FASTCALL QUnicodeTables::script(uint ucs4)
+Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
{
if (ucs4 > 0xffff)
return Common;
@@ -9485,4 +9485,8 @@ Q_CORE_EXPORT int QT_FASTCALL QUnicodeTables::script(uint ucs4)
return script;
}
+} // namespace QUnicodeTables
+
+using namespace QUnicodeTables;
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h
index 0b8115035c..50afebdd9c 100644
--- a/src/corelib/tools/qunicodetables_p.h
+++ b/src/corelib/tools/qunicodetables_p.h
@@ -76,7 +76,7 @@ namespace QUnicodeTables {
ushort lowerCaseSpecial : 1;
ushort upperCaseSpecial : 1;
ushort titleCaseSpecial : 1;
- ushort caseFoldSpecial : 1; /* currently unused */
+ ushort caseFoldSpecial : 1;
signed short mirrorDiff : 16;
signed short lowerCaseDiff : 16;
signed short upperCaseDiff : 16;
@@ -217,7 +217,7 @@ namespace QUnicodeTables {
};
- Q_CORE_EXPORT QUnicodeTables::LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4);
+ Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4);
inline int lineBreakClass(QChar ch)
{ return lineBreakClass(ch.unicode()); }
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 639d2463fd..58b26be4a9 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -180,8 +180,7 @@ private:
int s; // size
T *ptr; // data
union {
- // ### Qt 5: Use 'Prealloc * sizeof(T)' as array size
- char array[sizeof(qint64) * (((Prealloc * sizeof(T)) / sizeof(qint64)) + 1)];
+ char array[Prealloc * sizeof(T)];
qint64 q_for_alignment_1;
double q_for_alignment_2;
};
diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc
index e92f91aa47..748126012b 100644
--- a/src/corelib/tools/qvarlengtharray.qdoc
+++ b/src/corelib/tools/qvarlengtharray.qdoc
@@ -35,12 +35,12 @@
The C++ language doesn't support variable-length arrays on the stack.
For example, the following code won't compile:
- \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 0
+ \snippet code/doc_src_qvarlengtharray.cpp 0
The alternative is to allocate the array on the heap (with
\c{new}):
- \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 1
+ \snippet code/doc_src_qvarlengtharray.cpp 1
However, if myfunc() is called very frequently from the
application's inner loop, heap allocation can be a major source
@@ -53,7 +53,7 @@
it is much faster than heap allocation.
Example:
- \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 2
+ \snippet code/doc_src_qvarlengtharray.cpp 2
In the example above, QVarLengthArray will preallocate 1024
elements on the stack and use them unless \c{n + 1} is greater
@@ -260,7 +260,7 @@
be used to access and modify the items in the array.
Example:
- \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 3
+ \snippet code/doc_src_qvarlengtharray.cpp 3
The pointer remains valid as long as the array isn't reallocated.
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index 0026338047..20501f98ff 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -119,20 +119,20 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Here's an example of a QVector that stores integers and a QVector
that stores QString values:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 0
+ \snippet code/src_corelib_tools_qvector.cpp 0
QVector stores a vector (or array) of items. Typically, vectors
are created with an initial size. For example, the following code
constructs a QVector with 200 elements:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 1
+ \snippet code/src_corelib_tools_qvector.cpp 1
The elements are automatically initialized with a
\l{default-constructed value}. If you want to initialize the
vector with a different value, pass that value as the second
argument to the constructor:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 2
+ \snippet code/src_corelib_tools_qvector.cpp 2
You can also call fill() at any time to fill the vector with a
value.
@@ -142,11 +142,11 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
non-const vectors, operator[]() returns a reference to the item
that can be used on the left side of an assignment:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 3
+ \snippet code/src_corelib_tools_qvector.cpp 3
For read-only access, an alternative syntax is to use at():
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 4
+ \snippet code/src_corelib_tools_qvector.cpp 4
at() can be faster than operator[](), because it never causes a
\l{deep copy} to occur.
@@ -164,7 +164,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
backward. Both return the index of the matching item if they found
one; otherwise, they return -1. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 5
+ \snippet code/src_corelib_tools_qvector.cpp 5
If you simply want to check whether a vector contains a
particular value, use contains(). If you want to find out how
@@ -411,7 +411,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
can be used to access and modify the items in the vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 6
+ \snippet code/src_corelib_tools_qvector.cpp 6
The pointer remains valid as long as the vector isn't
reallocated.
@@ -482,7 +482,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Inserts \a value at the end of the vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 7
+ \snippet code/src_corelib_tools_qvector.cpp 7
This is the same as calling resize(size() + 1) and assigning \a
value to the new last element in the vector.
@@ -499,7 +499,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Inserts \a value at the beginning of the vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 8
+ \snippet code/src_corelib_tools_qvector.cpp 8
This is the same as vector.insert(0, \a value).
@@ -519,7 +519,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
value is appended to the vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 9
+ \snippet code/src_corelib_tools_qvector.cpp 9
For large vectors, this operation can be slow (\l{linear time}),
because it requires moving all the items at indexes \a i and
@@ -538,7 +538,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 10
+ \snippet code/src_corelib_tools_qvector.cpp 10
*/
/*! \fn QVector::iterator QVector::insert(iterator before, const T &value)
@@ -592,7 +592,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
size beforehand.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 11
+ \snippet code/src_corelib_tools_qvector.cpp 11
\sa resize()
*/
@@ -604,7 +604,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Returns -1 if no item matched.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 12
+ \snippet code/src_corelib_tools_qvector.cpp 12
This function requires the value type to have an implementation of
\c operator==().
@@ -620,7 +620,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
last item. Returns -1 if no item matched.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 13
+ \snippet code/src_corelib_tools_qvector.cpp 13
This function requires the value type to have an implementation of
\c operator==().
@@ -966,7 +966,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 14
+ \snippet code/src_corelib_tools_qvector.cpp 14
\sa fromList(), QList::fromVector()
*/
@@ -977,7 +977,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 15
+ \snippet code/src_corelib_tools_qvector.cpp 15
\sa toList(), QList::toVector()
*/
@@ -989,7 +989,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 16
+ \snippet code/src_corelib_tools_qvector.cpp 16
\sa toStdVector(), QList::fromStdList()
*/
@@ -999,7 +999,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Returns a std::vector object with the data contained in this QVector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 17
+ \snippet code/src_corelib_tools_qvector.cpp 17
\sa fromStdVector(), QList::toStdList()
*/
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index df2c2f998f..769cdc9495 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -291,7 +291,7 @@ QXmlStreamEntityResolver *QXmlStreamReader::entityResolver() const
A typical loop with QXmlStreamReader looks like this:
- \snippet doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp 0
+ \snippet code/src_corelib_xml_qxmlstream.cpp 0
QXmlStreamReader is a well-formed XML 1.0 parser that does \e not
@@ -2900,11 +2900,11 @@ QStringRef QXmlStreamReader::documentEncoding() const
The following abridged code snippet shows the basic use of the class
to write formatted XML with indentation:
- \snippet doc/src/snippets/qxmlstreamwriter/main.cpp start stream
+ \snippet qxmlstreamwriter/main.cpp start stream
\dots
- \snippet doc/src/snippets/qxmlstreamwriter/main.cpp write element
+ \snippet qxmlstreamwriter/main.cpp write element
\dots
- \snippet doc/src/snippets/qxmlstreamwriter/main.cpp finish stream
+ \snippet qxmlstreamwriter/main.cpp finish stream
QXmlStreamWriter takes care of prefixing namespaces, all you have to
do is specify the \c namespaceUri when writing elements or
@@ -3561,7 +3561,7 @@ void QXmlStreamWriter::writeEmptyElement(const QString &namespaceUri, const QStr
This is a convenience function equivalent to:
- \snippet doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp 1
+ \snippet code/src_corelib_xml_qxmlstream.cpp 1
*/
void QXmlStreamWriter::writeTextElement(const QString &qualifiedName, const QString &text)
@@ -3578,7 +3578,7 @@ void QXmlStreamWriter::writeTextElement(const QString &qualifiedName, const QStr
This is a convenience function equivalent to:
- \snippet doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp 2
+ \snippet code/src_corelib_xml_qxmlstream.cpp 2
*/
void QXmlStreamWriter::writeTextElement(const QString &namespaceUri, const QString &name, const QString &text)
diff --git a/src/corelib/xml/qxmlutils.cpp b/src/corelib/xml/qxmlutils.cpp
index 7ec208816c..44a56de797 100644
--- a/src/corelib/xml/qxmlutils.cpp
+++ b/src/corelib/xml/qxmlutils.cpp
@@ -227,7 +227,7 @@ bool QXmlUtils::isBaseChar(const QChar c)
Determines whether \a encName is a valid instance of production [81]EncName in the XML 1.0
specification. If it is, true is returned, otherwise false.
- \sa \l {http://www.w3.org/TR/REC-xml/#NT-EncName}
+ \sa {http://www.w3.org/TR/REC-xml/#NT-EncName},
{Extensible Markup Language (XML) 1.0 (Fourth Edition), [81] EncName}
*/
bool QXmlUtils::isEncName(const QString &encName)
@@ -236,7 +236,7 @@ bool QXmlUtils::isEncName(const QString &encName)
* replace that regexp is probably a 70 lines so I prioritize this to when
* the dependency is considered alarming, or when the rest of the bugs
* are fixed. */
- const QRegExp encNameRegExp(QLatin1String("[A-Za-z][A-Za-z0-9._\\-]*"));
+ QRegExp encNameRegExp(QLatin1String("[A-Za-z][A-Za-z0-9._\\-]*"));
Q_ASSERT(encNameRegExp.isValid());
return encNameRegExp.exactMatch(encName);
@@ -248,7 +248,7 @@ bool QXmlUtils::isEncName(const QString &encName)
Determines whether \a c is a valid instance of production [84]Letter in the XML 1.0
specification. If it is, true is returned, otherwise false.
- \sa \l {http://www.w3.org/TR/REC-xml/#NT-Letter}
+ \sa {http://www.w3.org/TR/REC-xml/#NT-Letter},
{Extensible Markup Language (XML) 1.0 (Fourth Edition), [84] Letter}
*/
bool QXmlUtils::isLetter(const QChar c)
@@ -262,7 +262,7 @@ bool QXmlUtils::isLetter(const QChar c)
Determines whether \a c is a valid instance of production [2]Char in the XML 1.0
specification. If it is, true is returned, otherwise false.
- \sa \l {http://www.w3.org/TR/REC-xml/#NT-Char}
+ \sa {http://www.w3.org/TR/REC-xml/#NT-Char},
{Extensible Markup Language (XML) 1.0 (Fourth Edition), [2] Char}
*/
bool QXmlUtils::isChar(const QChar c)
@@ -281,7 +281,7 @@ bool QXmlUtils::isChar(const QChar c)
production [4]NameChar in the XML 1.0 specification. If it
is, true is returned, otherwise false.
- \sa \l {http://www.w3.org/TR/REC-xml/#NT-NameChar}
+ \sa {http://www.w3.org/TR/REC-xml/#NT-NameChar},
{Extensible Markup Language (XML) 1.0 (Fourth Edition), [4] NameChar}
*/
bool QXmlUtils::isNameChar(const QChar c)
@@ -304,7 +304,7 @@ bool QXmlUtils::isNameChar(const QChar c)
production [12] PubidLiteral in the XML 1.0 specification. If it
is, true is returned, otherwise false.
- \sa \l {http://www.w3.org/TR/REC-xml/#NT-PubidLiteral}
+ \sa {http://www.w3.org/TR/REC-xml/#NT-PubidLiteral},
{Extensible Markup Language (XML) 1.0 (Fourth Edition), [12] PubidLiteral}
*/
bool QXmlUtils::isPublicID(const QString &candidate)
@@ -363,7 +363,7 @@ bool QXmlUtils::isPublicID(const QString &candidate)
production [4]NCName in the XML 1.0 Namespaces specification. If it
is, true is returned, otherwise false.
- \sa \l {http://www.w3.org/TR/REC-xml-names/#NT-NCName}
+ \sa {http://www.w3.org/TR/REC-xml-names/#NT-NCName},
{W3CNamespaces in XML 1.0 (Second Edition), [4] NCName}
*/
bool QXmlUtils::isNCName(const QStringRef &ncName)