summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2010-03-24 23:06:43 (GMT)
committerLorn Potter <lorn.potter@nokia.com>2010-03-24 23:06:43 (GMT)
commitd20510dd91e01b15e2346c0cb12e352080b6a093 (patch)
tree83554f5c96f69df6fe6d9d5c2a9f529a3b1316d8
parentf727f993c3c4e3f548b06d57b3ee0da4f3914bae (diff)
parent8218a16815d883823d3411be9896332b997f3e91 (diff)
downloadQt-d20510dd91e01b15e2346c0cb12e352080b6a093.zip
Qt-d20510dd91e01b15e2346c0cb12e352080b6a093.tar.gz
Qt-d20510dd91e01b15e2346c0cb12e352080b6a093.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Conflicts: src/plugins/bearer/corewlan/qcorewlanengine.mm
-rwxr-xr-xconfigure56
-rw-r--r--dist/changes-4.7.010
-rw-r--r--doc/src/declarative/extending.qdoc16
-rw-r--r--doc/src/declarative/integrating.qdoc4
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc87
-rw-r--r--doc/src/declarative/qtprogrammers.qdoc2
-rw-r--r--doc/src/examples/bearercloud.qdoc197
-rw-r--r--doc/src/examples/bearermonitor.qdoc49
-rw-r--r--doc/src/getting-started/examples.qdoc2
-rw-r--r--doc/src/images/bearercloud-example.pngbin0 -> 37582 bytes
-rw-r--r--doc/src/images/bearermonitor-example.pngbin0 -> 34862 bytes
-rw-r--r--doc/src/network-programming/bearermanagement.qdoc286
-rw-r--r--doc/src/network-programming/qtnetwork.qdoc30
-rw-r--r--doc/src/sql-programming/sql-driver.qdoc67
-rw-r--r--examples/network/bearercloud/cloud.h2
-rw-r--r--examples/network/bearermonitor/sessionwidget.h2
-rw-r--r--mkspecs/features/symbian/application_icon.prf7
-rw-r--r--mkspecs/features/symbian/qt.prf2
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h4
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h4
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp7
-rw-r--r--src/corelib/global/qnamespace.qdoc2
-rw-r--r--src/corelib/io/qdir.cpp6
-rw-r--r--src/corelib/io/qdir.h4
-rw-r--r--src/corelib/io/qdiriterator.cpp6
-rw-r--r--src/corelib/io/qfsfileengine.cpp2
-rw-r--r--src/corelib/io/qfsfileengine_p.h4
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp28
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp2
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp10
-rw-r--r--src/corelib/kernel/qmetaobject.cpp63
-rw-r--r--src/corelib/kernel/qtranslator.cpp4
-rw-r--r--src/corelib/tools/qlocale.cpp214
-rw-r--r--src/corelib/tools/qlocale.h1
-rw-r--r--src/corelib/tools/qlocale_p.h18
-rw-r--r--src/corelib/tools/qlocale_symbian.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp11
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp18
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp248
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h2
-rw-r--r--src/declarative/util/util.pri3
-rw-r--r--src/gui/dialogs/qwizard_win_p.h1
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp6
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp12
-rw-r--r--src/gui/itemviews/qtreeview.cpp23
-rw-r--r--src/gui/kernel/qapplication_win.cpp6
-rw-r--r--src/gui/kernel/qapplication_x11.cpp5
-rw-r--r--src/gui/kernel/qdnd_win.cpp16
-rw-r--r--src/gui/kernel/qwidget_mac.mm5
-rw-r--r--src/gui/kernel/qwidget_p.h2
-rw-r--r--src/gui/kernel/qwidget_x11.cpp6
-rw-r--r--src/gui/painting/qdrawhelper.cpp20
-rw-r--r--src/gui/painting/qpainter.cpp2
-rw-r--r--src/gui/styles/qgtkstyle.cpp2
-rw-r--r--src/gui/styles/qs60style_s60.cpp2
-rw-r--r--src/gui/styles/qwindowsstyle.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp5
-rw-r--r--src/gui/text/qtextlayout.cpp14
-rw-r--r--src/gui/text/qtextlayout.h1
-rw-r--r--src/gui/util/qcompleter.cpp2
-rw-r--r--src/gui/widgets/qmainwindow.cpp2
-rw-r--r--src/gui/widgets/qsplitter.cpp32
-rw-r--r--src/gui/widgets/qsplitter.h1
-rw-r--r--src/gui/widgets/qtoolbarlayout.cpp4
-rw-r--r--src/imports/multimedia/qdeclarativeaudio.cpp2
-rw-r--r--src/imports/multimedia/qdeclarativevideo.cpp2
-rw-r--r--src/multimedia/video/qabstractvideobuffer.cpp2
-rw-r--r--src/multimedia/video/qabstractvideobuffer.h2
-rw-r--r--src/network/access/qnetworkaccessmanager.h2
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp8
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp2
-rw-r--r--src/network/bearer/qnetworkconfiguration.cpp2
-rw-r--r--src/network/bearer/qnetworksession.cpp2
-rw-r--r--src/network/bearer/qnetworksession.h2
-rw-r--r--src/opengl/qglbuffer.cpp30
-rw-r--r--src/opengl/qglbuffer.h5
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.h3
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm14
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp2
-rw-r--r--src/plugins/bearer/icd/qicdengine.cpp2
-rw-r--r--src/plugins/bearer/icd/qnetworksession_impl.cpp2
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.h16
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.cpp67
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.h7
-rw-r--r--src/plugins/bearer/symbian/symbianengine.cpp79
-rw-r--r--src/plugins/bearer/symbian/symbianengine.h6
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.cpp396
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.h7
-rw-r--r--src/plugins/mediaservices/qt7/qt7movieviewoutput.h1
-rw-r--r--src/plugins/mediaservices/qt7/qt7movieviewoutput.mm32
-rw-r--r--src/qt3support/network/q3socketdevice_win.cpp1
-rw-r--r--src/script/api/qscriptengine.cpp1
-rw-r--r--src/script/api/qscriptengine.h1
-rw-r--r--src/script/api/qscriptvalue.cpp12
-rw-r--r--src/script/api/qscriptvalueiterator.cpp1
-rw-r--r--src/script/bridge/qscriptqobject.cpp3
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/importlib/sublib/Foo.qml (renamed from tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir/Foo.qml)0
-rw-r--r--tests/auto/macnativeevents/qnativeinput.cpp378
-rw-r--r--tests/auto/macnativeevents/qnativeinput.h228
-rw-r--r--tests/auto/macnativeevents/qnativeinput_mac.cpp382
-rw-r--r--tests/auto/macnativeevents/qnativeplayer.cpp139
-rw-r--r--tests/auto/macnativeevents/qnativeplayer.h92
-rw-r--r--tests/auto/macnativeevents/tst_macnativeevents.cpp81
-rw-r--r--tests/auto/macnativeevents/tst_macnativeevents.pro16
-rw-r--r--tests/auto/other.pro1
-rw-r--r--tests/auto/qdiriterator/tst_qdiriterator.cpp48
-rw-r--r--tests/auto/qfile/tst_qfile.cpp47
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp12
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp27
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp6
-rw-r--r--tests/auto/qnetworksession/test/tst_qnetworksession.cpp255
-rw-r--r--tests/auto/qobject/tst_qobject.cpp78
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp87
-rw-r--r--tests/auto/qshortcut/tst_qshortcut.cpp2
-rw-r--r--tests/auto/qstring/tst_qstring.cpp5
-rw-r--r--tests/auto/qtranslator/qtranslator.pro2
-rw-r--r--tests/auto/qtranslator/qtranslator.qrc5
-rw-r--r--tests/auto/qtranslator/tst_qtranslator.cpp19
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.cpp5
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp16
-rw-r--r--tools/configure/configureapp.cpp27
-rw-r--r--tools/configure/environment.cpp4
-rw-r--r--tools/designer/src/components/formeditor/formwindowmanager.cpp4
-rw-r--r--tools/designer/src/components/propertyeditor/propertyeditor.cpp67
-rw-r--r--tools/designer/src/components/propertyeditor/propertyeditor.h5
-rw-r--r--tools/designer/src/designer/qdesigner_actions.cpp10
-rw-r--r--tools/designer/src/lib/shared/qtresourceview.cpp3
-rw-r--r--tools/linguist/linguist/mainwindow.cpp44
-rw-r--r--tools/qdoc3/helpprojectwriter.cpp61
-rw-r--r--tools/qdoc3/htmlgenerator.cpp2
-rw-r--r--tools/qdoc3/node.h8
-rw-r--r--tools/qdoc3/tree.cpp78
-rw-r--r--tools/runonphone/main.cpp49
-rw-r--r--tools/runonphone/symbianutils/launcher.cpp83
-rw-r--r--tools/runonphone/symbianutils/launcher.h15
-rw-r--r--tools/runonphone/symbianutils/symbiandevicemanager.cpp194
-rw-r--r--tools/runonphone/symbianutils/symbiandevicemanager.h47
-rw-r--r--tools/runonphone/symbianutils/trkdevice.cpp111
-rw-r--r--tools/runonphone/symbianutils/trkdevice.h11
-rw-r--r--tools/runonphone/trksignalhandler.cpp11
-rw-r--r--tools/shared/windows/registry.cpp2
146 files changed, 4133 insertions, 1017 deletions
diff --git a/configure b/configure
index 5786764..3c38763 100755
--- a/configure
+++ b/configure
@@ -725,6 +725,7 @@ CFG_DBUS=auto
CFG_GLIB=auto
CFG_GSTREAMER=auto
CFG_QGTKSTYLE=auto
+CFG_QS60STYLE=auto
CFG_LARGEFILE=yes
CFG_OPENSSL=auto
CFG_PTMALLOC=no
@@ -1803,6 +1804,13 @@ while [ "$#" -gt 0 ]; do
UNKNOWN_OPT=yes
fi
;;
+ style-s60)
+ if [ "$VAL" = "qt" ] || [ "$VAL" = "no" ]; then
+ CFG_QS60STYLE="$VAL"
+ else
+ UNKNOWN_OPT=yes
+ fi
+ ;;
qdbus|dbus)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "linked" ]; then
CFG_DBUS="$VAL"
@@ -3358,7 +3366,6 @@ Usage: $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir
[-no-openssl] [-openssl] [-openssl-linked]
[-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-javascript-jit] [-javascript-jit]
[-no-script] [-script] [-no-scripttools] [-scripttools] [-no-declarative] [-declarative]
- [-no-s60] [-s60] [-no-usedeffiles] [-usedeffiles]
[additional platform specific options (see below)]
@@ -3542,11 +3549,6 @@ EOF
fi
cat << EOF
- -no-s60 ............ Do not compile in S60 support.
- + -s60 ............... Compile with support for the S60 UI Framework.
- -no-usedeffiles .... Disable the usage of DEF files.
- * -usedeffiles ....... Enable the usage of DEF files.
-
-no-mmx ............ Do not compile with use of MMX instructions.
-no-3dnow .......... Do not compile with use of 3DNOW instructions.
-no-sse ............ Do not compile with use of SSE instructions.
@@ -3997,6 +3999,20 @@ if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_X11" = "yes" ]; then
EOF
fi
+if echo "$XPLATFORM" | grep symbian > /dev/null ; then
+ cat << EOF
+
+Qt for Symbian only:
+ -no-s60 ............ Do not compile in S60 support.
+ + -s60 ............... Compile with support for the S60 UI Framework.
+ -no-style-s60....... Disable s60 style
+ + -qt-style-s60....... Enable s60 style in the Qt Library
+
+ -no-usedeffiles .... Disable the usage of DEF files.
+ * -usedeffiles ....... Enable the usage of DEF files.
+EOF
+fi
+
[ "x$ERROR" = "xyes" ] && exit 1
exit 0
fi # Help
@@ -4010,6 +4026,8 @@ if [ "$PLATFORM_QWS" = "yes" ]; then
Platform="Qt for Embedded Linux"
elif [ "$PLATFORM_MAC" = "yes" ]; then
Platform="Qt for Mac OS X"
+elif echo "$XPLATFORM" | grep "symbian" > /dev/null ; then
+ Platform="Qt for Symbian"
elif [ '!' -z "`getQMakeConf \"$XQMAKESPEC\" | grep QMAKE_LIBS_X11 | awk '{print $3;}'`" ]; then
PLATFORM_X11=yes
Platform="Qt for Linux/X11"
@@ -4635,15 +4653,23 @@ if [ "$CFG_ZLIB" = "auto" ]; then
fi
if [ "$CFG_S60" = "auto" ]; then
- if echo "$XQMAKESPEC" | grep symbian > /dev/null; then
+ if echo "$XPLATFORM" | grep symbian > /dev/null; then
CFG_S60=yes
else
CFG_S60=no
fi
fi
+if [ "$CFG_QS60STYLE" = "auto" ]; then
+ if echo "$XPLATFORM" | grep symbian > /dev/null; then
+ CFG_QS60STYLE=qt
+ else
+ CFG_QS60STYLE=no
+ fi
+fi
+
if [ "$CFG_SYMBIAN_DEFFILES" = "auto" ]; then
- if echo "$XQMAKESPEC" | grep symbian > /dev/null && [ "$CFG_DEV" = "no" ]; then
+ if echo "$XPLATFORM" | grep symbian > /dev/null && [ "$CFG_DEV" = "no" ]; then
CFG_SYMBIAN_DEFFILES=yes
else
CFG_SYMBIAN_DEFFILES=no
@@ -5709,6 +5735,8 @@ fi
if [ "$CFG_ENDIAN" = "auto" ]; then
if [ "$PLATFORM_MAC" = "yes" ]; then
true #leave as auto
+ elif [ "$XPLATFORM" = "symbian-sbsv2" ]; then
+ CFG_ENDIAN="Q_LITTLE_ENDIAN"
else
"$unixtests/endian.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath"
F="$?"
@@ -5794,7 +5822,7 @@ if [ "$CFG_DOUBLEFORMAT" = "auto" ]; then
fi
HAVE_STL=no
-if echo "$XQMAKESPEC" | grep symbian > /dev/null || "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stl "STL" $L_FLAGS $I_FLAGS $l_FLAGS; then
+if echo "$XPLATFORM" | grep symbian > /dev/null || "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stl "STL" $L_FLAGS $I_FLAGS $l_FLAGS; then
HAVE_STL=yes
fi
@@ -5948,7 +5976,7 @@ if [ "$CFG_OPENSSL" != "no" ]; then
fi
# detect OpenVG support
-if [ "$CFG_OPENVG" != "no" ]; then
+if [ "$CFG_OPENVG" != "no" ] && [ "$XPLATFORM" != "symbian-sbsv2" ]; then
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
if [ "$CFG_OPENVG" = "auto" ]; then
CFG_OPENVG=yes
@@ -6032,7 +6060,7 @@ elif [ "$CFG_JAVASCRIPTCORE_JIT" = "no" ]; then
fi
if [ "$CFG_AUDIO_BACKEND" = "auto" ]; then
- if echo "$XQMAKESPEC" | grep symbian > /dev/null 2>&1; then
+ if echo "$XPLATFORM" | grep symbian > /dev/null 2>&1; then
"$symbiantests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/symbian/audio "audio" $L_FLAGS $I_FLAGS $l_FLAGS
else
CFG_AUDIO_BACKEND=yes
@@ -6210,6 +6238,12 @@ else
fi
fi
+if [ "$CFG_QS60STYLE" = "no" ]; then
+ QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_STYLE_S60"
+else
+ QCONFIG_FLAGS="$QCONFIG_FLAGS QT_STYLE_S60"
+fi
+
# Disable OpenGL on Symbian.
case "$XPLATFORM" in
symbian*)
diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0
index 76fa7f8..b9aa64d 100644
--- a/dist/changes-4.7.0
+++ b/dist/changes-4.7.0
@@ -41,6 +41,16 @@ Third party components
* Library *
****************************************************************************
+QtCore
+------
+
+QtGui
+-----
+
+ - QAbstractItemView
+ * Fixed a bug that would cause keyboard searches not to behave
+ properly when used within 400 milliseconds of midnight.
+
- QPrinter
* Obsoleted the slightly confusing setNumCopies() and numCopies()
functions, and replaced them with setCopyCount(), copyCount() and
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index 0ae4f7d..8c096da 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -177,7 +177,7 @@ The guest property declaration looks like this:
\snippet examples/declarative/extending/properties/birthdayparty.h 2
-\l {Extending QML in C++ - Object and List Property Types Example} shows the complete
+\l {Extending QML - Object and List Property Types Example} shows the complete
code used to create the \c BirthdayParty type.
\section1 Inheritance and Coercion
@@ -224,7 +224,7 @@ QML will automatically coerce C++ types when assigning to either an object
property, or to a list property. Only if coercion fails does an assignment
error occur.
-\l {Extending QML in C++ - Inheritance and Coercion Example} shows the complete
+\l {Extending QML - Inheritance and Coercion Example} shows the complete
code used to create the \c Boy and \c Girl types.
\section1 Default Property
@@ -256,7 +256,7 @@ refer to a property declared in the class itself, or a property inherited from a
base class.
\endquotation
-\l {Extending QML in C++ - Default Property Example} shows the complete code used to
+\l {Extending QML - Default Property Example} shows the complete code used to
specify a default property.
\section1 Grouped Properties
@@ -281,7 +281,7 @@ property block - in this case the size, color, brand and price properties.
Grouped property blocks may declared and accessed be recusively.
-\l {Extending QML in C++ - Grouped Properties Example} shows the complete code used to
+\l {Extending QML - Grouped Properties Example} shows the complete code used to
implement the \c shoe property grouping.
\section1 Attached Properties
@@ -373,7 +373,7 @@ creating it if it does not already exist. If \a create is false, the attachment
object will only be returned if it has previously been created.
\endquotation
-\l {Extending QML in C++ - Attached Properties Example} shows the complete code used to
+\l {Extending QML - Attached Properties Example} shows the complete code used to
implement the rsvp attached property.
\section1 Memory Management and QVariant types
@@ -435,7 +435,7 @@ listed in \l {Adding Types}, as well registered object types are permitted as
signal parameter types. Using other types is not an error, but the parameter
value will not be accessible from script.
-\l {Extending QML in C++ - Signal Support Example} shows the complete code used to
+\l {Extending QML - Signal Support Example} shows the complete code used to
implement the onPartyStarted signal property.
\section1 Property Value Sources
@@ -482,7 +482,7 @@ to assign it normally, as though it were a regular QML type. Only if this
assignment fails does the engine call the setTarget() method. This allows
the type to also be used in contexts other than just as a value source.
-\l {Extending QML in C++ - Property Value Source Example} shows the complete code used
+\l {Extending QML - Property Value Source Example} shows the complete code used
implement the HappyBirthday property value source.
\section1 Property Binding
@@ -554,7 +554,7 @@ The CONSTANT attribute should only be used for properties whose value is set,
and finalized, only in the class constructor. All other properties that want
to be used in bindings should have a NOTIFY signal instead.
-\l {Extending QML in C++ - Binding Example} shows the BirthdayParty example updated to
+\l {Extending QML - Binding Example} shows the BirthdayParty example updated to
include NOTIFY signals for use in binding.
\section1 Extension Objects
diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc
index c685d3d..165a735 100644
--- a/doc/src/declarative/integrating.qdoc
+++ b/doc/src/declarative/integrating.qdoc
@@ -103,13 +103,13 @@ and that this approach allows you to integrate new items written in QML
without using the above method.
You can make custom C++ types
-available in QML using the pair of macros listed in \l{Extending QML}.
+available in QML using the pair of macros listed in \l{Extending QML in C++}.
While this is normally only useful for
types that were designed for QML use, in conjunction with the
\l{GraphicsObjectContainer} element QGraphicsWidget subclasses can also be
used effectively (if they were designed, like QGraphicsWidget, to be controllable through Qt's property system).
This way you can write your UI using QML, without having to rewrite your existing items.
-For details on implementing this approach see \l{Extending QML} page for details on exposing your C++ types,
+For details on implementing this approach see \l{Extending QML in C++} page for details on exposing your C++ types,
and the \l{GraphicsObjectContainer} documentation for details about using it to wrap QGraphicsWidgets.
*/
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index b43d0ec..8013b92 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -40,76 +40,75 @@
****************************************************************************/
/*!
-\module QtDeclarative
-\title QtDeclarative Module
-\ingroup modules
+ \module QtDeclarative
+ \title QtDeclarative Module
+ \ingroup modules
-\brief The Qt Declarative module provides a declarative framework for building
-highly dynamic, custom user interfaces.
+ \brief The Qt Declarative module provides a declarative framework
+ for building highly dynamic, custom user interfaces.
-To include the definitions of the module's classes, use the
-following directive:
+ To include the definitions of the module's classes, use the
+ following directive:
-\code
-#include <QtDeclarative>
-\endcode
+ \code
+ #include <QtDeclarative>
+ \endcode
-To link against the module, add this line to your \l qmake \c
-.pro file:
+ To link against the module, add this line to your \l qmake \c
+ .pro file:
-\code
-QT += declarative
-\endcode
-
-For more information on the Qt Declarative module, see the
-\l{declarativeui.html}{Declarative UI} documentation.
+ \code
+ QT += declarative
+ \endcode
+ For more information on the Qt Declarative module, see the
+ \l{declarativeui.html}{Declarative UI} documentation.
*/
/*!
- \macro QML_DECLARE_TYPE(T)
- \relates QDeclarativeEngine
-
- yada yada yada
-
+ \macro QML_DECLARE_TYPE()
+ \relates QDeclarativeEngine
*/
/*!
- \fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
- \relates QDeclarativeEngine
+ \fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+ \relates QDeclarativeEngine
- This template function registers the C++ type \a T with the QML system, and make it available in
- QML under the name \a qmlName in the import library \a uri version \a versionMajor.versionMajor.
+ This template function registers the C++ type in the QML system with
+ the name \a qmlName. in the library imported from \a uri having the
+ version number composed from \a versionMajor and \a versionMinor.
- Returns the QML type id.
+ Returns the QML type id.
- Example: Register the C++ class \c MinehuntGame as QML type \c Game version 0.1 in the import
- library \c MinehuntCore:
+ Example: Register the C++ class \c MinehuntGame as the QML type
+ named \c Game for version 0.1 in the import library \c MinehuntCore:
- \code
- qmlRegisterType<MinehuntGame>("MinehuntCore", 0, 1, "Game");
- \endcode
+ \code
+ qmlRegisterType<MinehuntGame>("MinehuntCore", 0, 1, "Game");
+ \endcode
*/
/*!
- \fn int qmlRegisterType()
- \relates QDeclarativeEngine
- \overload
+ \fn int qmlRegisterType()
+ \relates QDeclarativeEngine
+ \overload
- This template function registers the C++ type \a T with the QML system. Instances of this type cannot
- be created from the QML system.
+ This template function registers the C++ type in the QML
+ system. Instances of this type cannot be created from the QML
+ system.
- Returns the QML type id.
+ Returns the QML type id.
*/
-/*! \fn int qmlRegisterInterface(const char *typeName)
- \relates QDeclarativeEngine
+/*!
+ \fn int qmlRegisterInterface(const char *typeName)
+ \relates QDeclarativeEngine
- This template function registers the C++ type \a T as interface with the QML system, under the name
- \a typeName.
+ This template function registers the C++ type in the QML system
+ under the name \a typeName.
- Returns the QML type id.
+ Returns the QML type id.
*/
diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc
index ca1d596..05ffeb0 100644
--- a/doc/src/declarative/qtprogrammers.qdoc
+++ b/doc/src/declarative/qtprogrammers.qdoc
@@ -65,7 +65,7 @@ QML provides direct access to the following concepts from Qt:
\o Qt models - used directly in data binding (QAbstractItemModel and next generation QListModelInterface)
\endlist
-Qt knowledge is \e required for \l {Extending QML}, and also for \l{Integrating QML with existing Qt UI code}.
+Qt knowledge is \e required for \l {Extending QML in C++}, and also for \l{Integrating QML with existing Qt UI code}.
\section1 QML Items compared with QWidgets
diff --git a/doc/src/examples/bearercloud.qdoc b/doc/src/examples/bearercloud.qdoc
new file mode 100644
index 0000000..c7acf04
--- /dev/null
+++ b/doc/src/examples/bearercloud.qdoc
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example network/bearercloud
+ \title Bearer Cloud Example
+
+ The Bearer Cloud example shows how to use the Bearer Management API to monitor the
+ connectivity state of the local device.
+
+ \image bearercloud-example.png Screenshot of the Bearer Cloud example
+
+ Bearer Management provides the QNetworkConfigurationManager class which can be used to monitor
+ changes in the available \l {QNetworkConfiguration}{network configurations} and the
+ QNetworkSession class which is used to \l {QNetworkSession::open()}{open} and
+ \l {QNetworkSession::close()}{close} a session bringing a network interface up or down if
+ necessary.
+
+ This example displays all known \l {QNetworkConfiguration}{network configurations} in a cloud
+ orbiting the local device. There are four orbits representing the four possible
+ \l {QNetworkConfiguration::StateFlags}{states} that the network configuration can be in.
+ The closer the orbit the more useful the network configuration is in its current state.
+ The inner orbit is populated with network configurations that are in the
+ \l {QNetworkConfiguration::Active}{Active} state. The second orbit is populated with network
+ configurations that are in the \l {QNetworkConfiguration::Discovered}{Discovered} state. The
+ third orbit is populated with network configurations that are in the
+ \l {QNetworkConfiguration::Defined}{Defined} state. Finally the outer orbit is populated by
+ configurations that are in the \l {QNetworkConfiguration::Undefined}{Undefined} state.
+
+ Hovering the mouse over a network configuration will display information about the network
+ configuration in a tool tip.
+
+ Double clicking on an Active or Discovered network configuration will
+ \l {QNetworkSession::close()}{close} or \l {QNetworkSession::open()}{open} a network session,
+ respectively.
+
+ Lastly you can reorganize the cloud without changing the state of the network configurations by
+ dragging them around.
+
+ This example consists of two main classes, the BearerCloud and Cloud classes. The Cloud class
+ represents a single network session and associated network configuration. The BearerCloud
+ class implements a Graphics View scene and manages the life-cycle of Cloud
+ objects in response to notification signals from QNetworkConfigurationManager.
+
+ \section1 Setting the scene
+
+ When constructing the scene we first calculate some random offsets using the global qsand()
+ and qrand() functions. We will use these offsets to scatter the initial position of new Cloud
+ objects.
+
+ Next we place a text item in the center of the scene to represent the local device and
+ surround it with four concentric circles to help visualize the orbits.
+
+ Finally we connect up the network configuration notification signals and queue the initial
+ population of the scene during the next iteration of the event loop.
+
+ \snippet examples/network/bearercloud/bearercloud.cpp 0
+
+ Populating the scene with the initial list of known network configuration is easy. Iterate
+ over the list returned by QNetworkConfigurationManager::allConfigurations(), calling our
+ configurationAdded() slot on each one.
+
+ We finishing off by calling cloudMoved() to ensure that animations are started.
+
+ \snippet examples/network/bearercloud/bearercloud.cpp 1
+
+ The configurationAdded() slot gets called when a new network configuration is added to the
+ system.
+
+ It stores the \l {QNetworkConfiguration::identifier()}{identifier} of the network
+ configuration in the \e {configStates} map, which is used to keep a count of the number of
+ network configurations in each state. This in turn is used to calculate the initial position
+ of new Cloud objects.
+
+ Next we create a new Cloud object for this network configuration. Set its initial position
+ and store it in the \e {configurations} hash.
+
+ The last step is to add it to the scene by calling QGraphicsScene::addItem().
+
+ \snippet examples/network/bearercloud/bearercloud.cpp 2
+
+ The configurationRemoved() slot gets called when a network configuration is removed from the
+ system.
+
+ First we remove all references to the network configuration from the \e {configStates} and
+ \e {configurations} member variables.
+
+ Next we initiate animation by setting a final scale value on the Cloud object associated with
+ the removed network configuration.
+
+ Finally we flag the Cloud object to delete itself after it has finished animating.
+
+ \snippet examples/network/bearercloud/bearercloud.cpp 3
+
+ The Cloud object will take care of most of the work required when a network configuration
+ changes. All we do in the configurationChanged() slot is update the \e {configStates} member
+ variable.
+
+ \snippet examples/network/bearercloud/bearercloud.cpp 4
+
+
+ \section1 Responding to changes
+
+ Each network session and associated network configuration known to the system is represented in
+ the scene as a Cloud object.
+
+ In the Cloud constructor we first initialize member variables. Then we create a new
+ QNetworkSession object bound to the network configuration. Next we connect the QNetworkSession
+ signals which we use to monitor it for state changes.
+
+ Next we set some QGraphicsItem properties. The QGraphicsItem::ItemIsMovable flag enables mouse
+ interaction with the Cloud object.
+
+ The Cloud object consists of an icon and a text caption, these are constructed here. We will
+ assign values to them later, as these will change as the sessions state changes.
+
+ Next we set the initial animation state and call our newConfigurationActivated() slot to finish
+ setting up the Cloud object based on the state of network session.
+
+ \snippet examples/network/bearercloud/cloud.cpp 0
+
+ The newConfigurationActivated() slot is called when a session has successfully roamed from one
+ access point to another.
+
+ The first thing we do is set the icon, inserting it into a shared SVG renderer cache if it is
+ not already available. Next we set the text caption to the name of the network configuration.
+
+ We then set the position of the icon and text caption so that they are centered horizontally.
+
+ Finally we call our stateChanged() slot.
+
+ \snippet examples/network/bearercloud/cloud.cpp 1
+
+ The stateChanged() slot is called when the session state changes.
+
+ In this slot we set lower the opacity of Cloud objects with network sessions that cannot be
+ \l {QNetworkSession::open()}{opened}, and set a detailed tool tip describing the sessions
+ state.
+
+ \snippet examples/network/bearercloud/cloud.cpp 2
+
+ In our reimplementation of the QGraphicsItem::mouseDoubleClickEvent() function we call
+ QNetworkSession::open() or QNetworkSession::close() to open or close the session in response
+ to a double left click.
+
+ \snippet examples/network/bearercloud/cloud.cpp 3
+
+ As we support the user dragging Cloud objects around we need to restart animations when the
+ position of the Cloud object changes. This is accomplished by reimplementing the
+ QGraphicsItem::itemChanged() function and calling the cloudMoved() function of the BearerCloud
+ object.
+
+ \snippet examples/network/bearercloud/cloud.cpp 4
+
+ The remainder of the code for the Cloud object implements the animations. The
+ calculateForces() function calculates the new position of the Cloud object based on the
+ position of all the other Cloud objects in the scene. The new position is set when the
+ advance() function is called to update the Cloud object for the current animation frame.
+*/
diff --git a/doc/src/examples/bearermonitor.qdoc b/doc/src/examples/bearermonitor.qdoc
new file mode 100644
index 0000000..592d1e5
--- /dev/null
+++ b/doc/src/examples/bearermonitor.qdoc
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example network/bearermonitor
+ \title Bearer Monitor Example
+
+ The Bearer Monitor example shows how to use the Bearer Management API.
+
+ \image bearermonitor-example.png Screenshot of the Bearer Monitor example
+*/
diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc
index bc6404c..885e96c 100644
--- a/doc/src/getting-started/examples.qdoc
+++ b/doc/src/getting-started/examples.qdoc
@@ -880,6 +880,8 @@
\o \l{network/threadedfortuneserver}{Threaded Fortune Server}\raisedaster
\o \l{network/torrent}{Torrent}
\o \l{network/googlesuggest}{Google Suggest}
+ \o \l{network/bearercloud}{Bearer Cloud}\raisedaster
+ \o \l{network/bearermonitor}{Bearer Monitor}
\endlist
Examples marked with an asterisk (*) are fully documented.
diff --git a/doc/src/images/bearercloud-example.png b/doc/src/images/bearercloud-example.png
new file mode 100644
index 0000000..aaf69df
--- /dev/null
+++ b/doc/src/images/bearercloud-example.png
Binary files differ
diff --git a/doc/src/images/bearermonitor-example.png b/doc/src/images/bearermonitor-example.png
new file mode 100644
index 0000000..1b8a9c3
--- /dev/null
+++ b/doc/src/images/bearermonitor-example.png
Binary files differ
diff --git a/doc/src/network-programming/bearermanagement.qdoc b/doc/src/network-programming/bearermanagement.qdoc
new file mode 100644
index 0000000..10d697a
--- /dev/null
+++ b/doc/src/network-programming/bearermanagement.qdoc
@@ -0,0 +1,286 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page bearer-management.html
+
+\title Bearer Management
+\brief An API to control the system's connectivity state.
+
+\ingroup network
+
+Bearer Management controls the connectivity state of the system so that
+the user can start or stop interfaces or roam transparently between
+access points.
+
+\tableofcontents
+
+
+\section1 Overview
+
+The Bearer Management API controls the system's connectivity state. This
+incorporates simple information such as whether the device is online and
+how many interfaces there are as well as enables the application developer
+to start, stop network interfaces and influences other connection specific
+details. Depending on the platform's capabilities it may even provide
+session management so that a network interface remains up for as long as
+clients have a registered interest in them while at the same time
+optimizes the interface's uptime.
+
+This API does not provide support for management of network configurations
+themselves. It is up to the platform to provide infrastructure which
+enables to user to create, edit or delete network configurations.
+
+\section2 The API in Detail
+
+Computer systems manage their network interfaces via a set of configurations.
+Each configuration describes a set of parameters which instruct the system
+how a particular network interface is started. One of the most simplistic
+examples might be an Ethernet configuration that links a network card to a
+DHCP server. A more complex example might be a Wireless LAN configuration
+which may comprise of hardware details such as the WLAN card address,
+WLAN access point details (e.g ESSID, encryption details) and user specific
+information (for example username and password). Once the network interface
+was configured and started according to the configuration blue print,
+multiple applications are free to use this link layer connection/session
+for their own socket operations. Note that the QNetworkConfiguration object
+only provides limited information about the configuration details themselves.
+It's main purpose is to act as a configuration identifier through which link
+layer connections can be created, destroyed and monitored.
+
+QNetworkSession provides two types of use cases. It enables the monitoring of
+physical network interfaces and management of network sessions. Network sessions
+are a common feature on mobile devices where multiple applications
+can request network sessions as they see fit. The system consolidates and tracks
+active network sessions for the same network interface by maintaining the link
+layer connections until the last session has been closed. The subsequent table
+lists the major QNetworkSession functions and how they fit into the session and
+hardware management categories:
+
+\table 60%
+\header \o Interface management \o Session management
+\row \o QNetworkSession::stop() \o QNetworkSession::open()
+\row \o QNetworkSession::interface() \o QNetworkSession::close()
+\row \o QNetworkSession::state() \o QNetworkSession::isOpen()
+\row \o QNetworkSession::bytesWritten() \o QNetworkSession::migrate()
+\row \o QNetworkSession::bytesReceived() \o QNetworkSession::ignore()
+\row \o QNetworkSession::activeTime() \o QNetworkSession::accept()
+\row \o QNetworkSession::stateChanged() \o QNetworkSession::reject()
+\row \o \o QNetworkSession::opened()
+\row \o \o QNetworkSession::closed()
+\endtable
+
+The state of the session represents the state of the underlying access point
+whereas the session's openness implies the networking/connectivity state available
+to the current process.
+
+Possible use cases for interface management are network management related
+applications which intend to monitor the connectivity state but do not engage
+in network communication themselves. Any application wanting to open a socket
+to a remote address will typically use session management related functionality.
+
+\section3 Service networks
+
+Some mobile platforms use the concept of grouped access points (also
+called SNAP or Service Network Access Point). In principle multiple
+configurations are grouped together and possibly even prioritized when
+compared to each other. This is useful for use cases where all
+configurations serve a similar purpose or context. A common context could
+be that they provide access to the public Internet or possibly only to the
+office Intranet. By providing a pool of configurations the system can make
+a decision based on given priorities which usually map to factors such as
+speed, availability and cost. Furthermore the system can automatically
+roam from one access point to the next one while ensuring minimal impact on
+the user experience.
+
+The \l{QNetworkConfiguration::Type} flag specifies to what category a
+configuration belongs. The \l{QNetworkConfiguration::InternetAccessPoint}
+type is the most common example. It represents a configuration that can be
+used to create a session. The above mentioned grouping behavior is provided
+by \l {QNetworkConfiguration::ServiceNetwork} configurations. Service
+networks are place holders until such time when the user attempts to
+\l {QNetworkSession::open()}{open()} a new session. At that point in time
+the system determines which of the configurations \l{QNetworkConfiguration::children()}
+is best to use. The selection algorithm is provided by the platform and is usually managed
+by network settings applications. A service network can only have one level of indirection
+which implies children can only be of type \l {QNetworkConfiguration::InternetAccessPoint}.
+
+Most systems allow the user to define the systems default configuration.
+Usually the default behavior is either a service network, a particular
+Internet access point or the user instructs the platform to ask the user
+once an application requests the network. User interaction is generally
+implemented by some sort of system dialog which shows up at the appropriate
+point in time. The application does not have to handle the user input. This
+API provides the \l QNetworkConfigurationManager::defaultConfiguration()
+call which serves a similar purpose. The subsequent code snippet provides
+a quick way how an application can quickly create a new network session
+without (or only minimal) user interaction:
+
+\code
+ // Set Internet Access Point
+ QNetworkConfigurationManager manager;
+ const bool canStartIAP = (manager.capabilities()
+ & QNetworkConfigurationManager::CanStartAndStopInterfaces);
+ // Is there default access point, use it
+ QNetworkConfiguration cfg = manager.defaultConfiguration();
+ if (!cfg.isValid() || (!canStartIAP && cfg.state() != QNetworkConfiguration::Active)) {
+ QMessageBox::information(this, tr("Network"), tr(
+ "No Access Point found."));
+ return;
+ }
+
+ session = new QNetworkSession(cfg, this);
+ session->open();
+ session->waitForOpened(-1);
+\endcode
+
+To accommodate the "Ask user" use case the default configuration can be of
+type QNetworkConfiguration::UserChoice. A user choice configuration is
+resolved as part of the \l {QNetworkSession::open()} call. Note that a
+\l{QNetworkConfiguration::UserChoice}{UserChoice} configuration is only
+ever returned via \l {QNetworkConfigurationManager::defaultConfiguration()}
+and not \l QNetworkConfigurationManager::allConfigurations().
+
+On systems which do not maintain a list of
+\l {QNetworkConfigurationManager::defaultConfiguration()}{defaultConfiguration()}
+an invalid configuration is returned. A possible workaround could be to
+implement a custom dialog which is populated based on what
+\l QNetworkConfigurationManager::allConfigurations() returns.
+
+\section3 Managing network sessions
+
+A QNetworkSession object separates a \l {QNetworkSession::state()}{state()}
+and an \l{QNetworkSession::isOpen()}{isOpen()} condition.
+
+The state() attribute enables developers to detect whether the system
+currently maintains a global network session for the given
+QNetworkConfiguration. If \l {QNetworkSession::isOpen()}{isOpen()}
+returns true the QNetworkSession instance at hand was at least one of the
+entities requesting the global network session. This distinction is
+required to support the notion of session registrations. For as long as
+there are one or more open QNetworkSession instances the underlying
+network interface is not shut down. Therefore the session
+\l{QNetworkSession::state()}{state()} can be used to monitor the state of
+network interfaces.
+
+An open session is created by calling \l {QNetworkSession::open()} and
+closed via \l{QNetworkSession::close()}, respectively. If the session
+is \l{QNetworkSession::Disconnected}{disconnected} at the time of the
+\l{QNetworkSession::open()}{open()} call the underlying interface is started;
+otherwise only the reference counter against the global session is
+incremeted. The opposite behavior can be observed when using
+\l{QNetworkSession::close()}{close()}.
+
+In some use cases it may be necessary to turn the interface off despite of
+open sessions. This can be achieved by calling
+\l{QNetworkSession::stop()}{stop()}. An example use case could be a
+network manager type of application allowing the user to control the
+overall state of the devices connectivity.
+
+Global (inter-process) session support is platform dependent and can be
+detected via \l {QNetworkConfigurationManager::SystemSessionSupport}.
+If the system does not support global session calling
+\l{QNetworkSession::close()}{close()} never stops the interface.
+
+\section3 Roaming
+
+Roaming is the process of reconnecting a device from one network to another
+while minimizing the impact on the application. The system notifies the application
+about link layer changes so that the required preparation can be taken.
+The most common reaction would be to reinitialize sockets and to renegotiate
+stateful connections with other parties. In the most extreme cases applications
+may even prevent the roaming altogether.
+
+Roaming is initiated when the system determines that a more appropriate access point
+becomes available to the user. In general such a decision is based on cost, network speed
+or network type (access to certain private networks may only be provided via certain access points).
+Almost all devices providing roaming support have some form of global configuration application
+enabling the user to define such groups of access points (service networks) and priorities.
+
+This API supports two types of roaming. Application level roaming (ALR)
+provides the most control over the process. Applications will be notified about upcoming
+link layer changes and get the opportunity to test the new access point. Eventually they can
+reject or accept the link layer change. The second form of roaming is referred to as Forced Roaming.
+The system simply changes the link layer without consulting the application. It is up to
+the application to detect that some of its internal socket may have become invalid. As a consequence
+it has to reinitialize those sockets and reestablish the previous user session without
+any interruption. Forced roaming has the advantage that applications don't have to
+manage the entire roaming process by themselves.
+
+QNetworkSession is the central class for managing roaming related issues.
+
+\section3 Platform capabilities
+
+Some API features are not available on all platforms. The
+\l QNetworkConfigurationManager::Capability should be used to detect
+platform features at runtime. The following table lists the various
+platform APIs being used by this API. This may assist in the process of
+determining the feature support:
+
+\table
+ \header
+ \o Platform
+ \o Backend capabilities
+ \row
+ \o Linux\unicode{0xAE}
+ \o Linux uses the \l {http://projects.gnome.org/NetworkManager}{NetworkManager API} which supports interface notifications and starting and stopping of network interfaces.
+ \row
+ \o Windows\unicode{0xAE} XP
+ \o This platform supports interface notifications without active polling.
+ \row
+ \o Windows XP SP2+Hotfixes, Windows XP SP3, Windows Vista, Windows 7
+ \o In addition to standard Windows XP wifi access point monitoring has been improved which includes the ability to start and stop wifi interfaces. This requires Windows to manage the wifi interfaces.
+ \row
+ \o Symbian\unicode{0xAE} Platform & S60 3.1
+ \o Symbian support is based on Symbian platforms RConnection. In addition to interface notifications, starting and stopping of network it provides system wide session support and direct connection routing.
+ \row
+ \o Symbian Platform & S60 3.2+
+ \o This platform enjoys the most comprehensive feature set. In addition to the features support by the S60 3.1 Network roaming is supported.
+ \row
+ \o Mac OS\unicode{0xAE}
+ \o This platform has full support by way of CoreWLAN offered in Mac OS 10.6. Previous
+ versions of Mac OS - 10.5 and 10.4 have limited support.
+ \row
+ \o All other platforms (*nix, Windows Mobile)
+ \o This backend is the fallback for all platforms supports network interface notifications via active polling only.
+\endtable
+
+*/
diff --git a/doc/src/network-programming/qtnetwork.qdoc b/doc/src/network-programming/qtnetwork.qdoc
index d7e7481..36f48cf 100644
--- a/doc/src/network-programming/qtnetwork.qdoc
+++ b/doc/src/network-programming/qtnetwork.qdoc
@@ -53,11 +53,14 @@
\brief An Introduction to Network Programming with Qt
The QtNetwork module offers classes that allow you to write TCP/IP clients
- and servers. it offers classes such as QFtp that implement specific
+ and servers. It offers classes such as QFtp that implement specific
application-level protocols, lower-level classes such as QTcpSocket,
QTcpServer and QUdpSocket that represent low level network concepts,
and high level classes such as QNetworkRequest, QNetworkReply and
QNetworkAccessManager to perform network operations using common protocols.
+ It also offers classes such as QNetworkConfiguration,
+ QNetworkConfigurationManager and QNetworkSession that implement bearer
+ management.
\tableofcontents
@@ -327,4 +330,29 @@
by passing a factory to QNetworkProxyFactory::setApplicationProxyFactory()
and a custom proxying policy can be created by subclassing
QNetworkProxyFactory; see the class documentation for details.
+
+ \section1 Bearer Management Support
+
+ Bearer Management controls the connectivity state of the device such that
+ the application can start or stop network interfaces and roam
+ transparently between access points.
+
+ The QNetworkConfigurationManager class manages the list of network
+ configurations known to the device. A network configuration describes the
+ set of parameters used to start a network interface and is represented by
+ the QNetworkConfiguration class.
+
+ A network interface is started by openning a QNetworkSession based on a
+ given network configuration. In most situations creating a network session
+ based on the platform specified default network configuration is
+ appropriate. The default network configuration is returned by the
+ QNetworkConfigurationManager::defaultConfiguration() function.
+
+ On some platforms it is a platform requirement that the application open a
+ network session before any network operations can be performed. This can be
+ tested by the presents of the
+ QNetworkConfigurationManager::NetworkSessionRequired flag in the value
+ returned by the QNetworkConfigurationManager::capabilities() function.
+
+ \sa {Bearer Management}
*/
diff --git a/doc/src/sql-programming/sql-driver.qdoc b/doc/src/sql-programming/sql-driver.qdoc
index e26472e..6bccd83 100644
--- a/doc/src/sql-programming/sql-driver.qdoc
+++ b/doc/src/sql-programming/sql-driver.qdoc
@@ -192,6 +192,73 @@
built in release mode only. If you are expecting a debug version
to be built as well, don't use the \c{"-o Makefile"} option.
+ \section3 How to build the MySQL driver for MinGW users
+
+ The following steps have been used successfully for WinXP SP3. In
+ this example, Qt 4.6.2 is shown.
+
+ \list
+
+ \o Download the following components:
+ \list
+ \o \c{MinGW-5.1.6.exe}
+ \o \c{mingw-utils-0.3.tar.gz}
+ \o Qt sources, e.g. \c{qt-everywhere-opensource-src-4.6.2.zip}
+ \o \c{mysql-5.1.35-win32.msi}
+ \endlist
+
+ \o Install \c{MinGW-5.1.6.exe} in, e.g. \c{C:\MinGW}.
+
+ \o Extract \c{mingw-utils-0.3.tar.gz} into, e.g. \c{C:\MinGW}.
+
+ \o Add the path for \c{MinGW-5.1.6.exe} to your \c{PATH} variable,
+ e.g. \c{C:\MinGW\bin;}
+
+ \o Extract the Qt sources, (\c{qt-everywhere-opensource-src-4.6.2.zip}),
+ into, e.g. \c{C:\Qt}.
+
+ \o Add the path for the eventual Qt binary to your \c{PATH} variable,
+ e.g. \c{C:\Qt\4.6.2\bin;}.
+
+ \o Install MySQL (\c{mysql-5.1.35-win32.msi}), customizing the
+ components. Select only the headers and libraries. Install in,
+ e.g. \c{C:\MySQL\MySQL51}.
+
+ \o Open the DOS prompt, go to \c{C:\MySQL\MySQL51\lib\opt}, and run
+ the following commands:
+ \list
+ \o \c{reimp -d libmysql.lib}
+ \o \c{dlltool -k -d libmysql.def -l libmysql.a}
+ \endlist
+
+ \o Open the DOS prompt, go to \c{C:\Qt\4.6.2} and run the following commands:
+ \list
+ \o \c{configure.exe -debug-and-release -platform win32-g++ -qt-sql-mysql
+ -l mysql -I C:\MySQL\MySQL51\include -L C:\MySQL\MySQL51\lib\opt}
+ \o \c{mingw32-make sub-src}
+ \endlist
+ This step takes a long time.
+
+ \o Open the DOS prompt, go to
+ \c{C:\Qt\4.6.2\src\plugins\sqldrivers\mysql} and run the
+ following command:
+ \list
+ \o \c{qmake "INCLUDEPATH+=C:\MySQL\MySQL51\include" "LIBS+=-L. mysql" mysql.pro}
+ \endlist
+
+ \o Now the following libraries are ready in \c{C:\Qt\4.6.2\plugins\sqldrivers}.
+ \list
+ \o \c{libqsqlmysql4.a}
+ \o \c{libqsqlmysqld4.a}
+ \o \c{qsqlmysql4.dll}
+ \o \c{qsqlmysqld4.dll}
+ \endlist
+ To use the SDK and QtCreator directly, copy these libraries to
+ your \c{C:\Qt\...\qt\plugins\sqldrivers\}, and copy
+ \c{C:\MySQL\MySQL51\lib\opt\libmysql.dll} to your \c{C:\Qt\...\qt\bin\}.
+
+ \endlist
+
\target QOCI
\section2 QOCI for the Oracle Call Interface (OCI)
diff --git a/examples/network/bearercloud/cloud.h b/examples/network/bearercloud/cloud.h
index 38f8aff..5d4e52a 100644
--- a/examples/network/bearercloud/cloud.h
+++ b/examples/network/bearercloud/cloud.h
@@ -56,7 +56,7 @@ class Cloud : public QObject, public QGraphicsItem
Q_INTERFACES(QGraphicsItem)
public:
- Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0);
+ explicit Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0);
~Cloud();
enum { Type = UserType + 1 };
diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h
index cc9c067..ae5cc96 100644
--- a/examples/network/bearermonitor/sessionwidget.h
+++ b/examples/network/bearermonitor/sessionwidget.h
@@ -53,7 +53,7 @@ class SessionWidget : public QWidget, public Ui_SessionWidget
Q_OBJECT
public:
- SessionWidget(const QNetworkConfiguration &config, QWidget *parent = 0);
+ explicit SessionWidget(const QNetworkConfiguration &config, QWidget *parent = 0);
~SessionWidget();
void timerEvent(QTimerEvent *);
diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf
index 1109060..9979f40 100644
--- a/mkspecs/features/symbian/application_icon.prf
+++ b/mkspecs/features/symbian/application_icon.prf
@@ -31,9 +31,9 @@ contains( CONFIG, no_icon ) {
# Note: symbian-sbsv2 builds can't utilize extra compiler for mifconv, so ICON handling is done in code
!symbian-sbsv2 {
+ !contains(ICON, "^(/|\\\\|.:).*"):ICON = $$_PRO_FILE_PWD_/$$ICON #absolute path
#Makefile: requires paths with backslash
ICON_backslashed = $$ICON
- contains(QMAKE_HOST.os, "Windows"):ICON_backslashed = $$replace( ICON_backslashed, /, \\)
symbian-abld {
mifIconZDir = ${ZDIR}$$APP_RESOURCE_DIR
@@ -47,9 +47,14 @@ contains( CONFIG, no_icon ) {
# Extra compiler rules for mifconv
mifconv.target = $$mifIconZDir/$${baseTarget}.mif
+ contains(QMAKE_HOST.os, "Windows") {
+ ICON_backslashed = $$replace(ICON_backslashed, /, \\)
+ mifconv.target = $$replace(mifconv.target, /, \\)
+ }
# Based on: http://www.forum.nokia.com/document/Cpp_Developers_Library
# svg-t icons should always use /c32 depth
mifconv.commands = mifconv $$mifconv.target /c32 $$ICON_backslashed
+
mifconv.depends = $$ICON
PRE_TARGETDEPS += $$mifconv.target
QMAKE_EXTRA_TARGETS += mifconv
diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf
index 2dc614f..0d2e6eb 100644
--- a/mkspecs/features/symbian/qt.prf
+++ b/mkspecs/features/symbian/qt.prf
@@ -43,5 +43,5 @@ isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x020000 0x800000
# Workaround for the fact that Gnupoc and Symbian chose different approaches to
# the letter casing of headers.
contains(CONFIG, is_using_gnupoc) {
- INCLUDEPATH += $$[QT_INSTALL_PREFIX]/mkspecs/common/symbian/header-wrappers
+ INCLUDEPATH += $$QMAKESPEC/../../common/symbian/header-wrappers
}
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
index 5fb7fe3..5b655e8 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
@@ -75,7 +75,7 @@
#include <libkern/OSAtomic.h>
#elif OS(ANDROID)
#include <cutils/atomic.h>
-#elif COMPILER(GCC) && !PLATFORM(SYMBIAN)
+#elif COMPILER(GCC) && !defined(__SYMBIAN32__)
#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
#include <ext/atomicity.h>
#else
@@ -239,7 +239,7 @@ inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Bar
inline int atomicIncrement(int volatile* addend) { return android_atomic_inc(addend); }
inline int atomicDecrement(int volatile* addend) { return android_atomic_dec(addend); }
-#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !PLATFORM(SYMBIAN) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc
+#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !defined(__SYMBIAN32__) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc
#define WTF_USE_LOCKFREE_THREADSAFESHARED 1
inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; }
diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h
index 52a24f6..3e25c95 100644
--- a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h
+++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h
@@ -73,7 +73,7 @@
#include <windows.h>
#elif PLATFORM(DARWIN)
#include <libkern/OSAtomic.h>
-#elif COMPILER(GCC) && !PLATFORM(SYMBIAN)
+#elif COMPILER(GCC) && !defined(__SYMBIAN32__)
#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
#include <ext/atomicity.h>
#else
@@ -232,7 +232,7 @@ inline int atomicDecrement(int volatile* addend) { return InterlockedDecrement(r
inline int atomicIncrement(int volatile* addend) { return OSAtomicIncrement32Barrier(const_cast<int*>(addend)); }
inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Barrier(const_cast<int*>(addend)); }
-#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !PLATFORM(SYMBIAN) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc
+#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !defined(__SYMBIAN32__) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc
#define WTF_USE_LOCKFREE_THREADSAFESHARED 1
inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; }
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 7617c1f..5ca30e6 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -464,12 +464,7 @@ void QSequentialAnimationGroupPrivate::setCurrentAnimation(int index, bool inter
void QSequentialAnimationGroupPrivate::activateCurrentAnimation(bool intermediate)
{
- Q_Q(QSequentialAnimationGroup);
-
- if (!currentAnimation)
- return;
-
- if (state == QSequentialAnimationGroup::Stopped)
+ if (!currentAnimation || state == QSequentialAnimationGroup::Stopped)
return;
currentAnimation->stop();
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 775c0f3..b1108cb 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1255,7 +1255,7 @@
window boundary (widget without parent or dialog) is found.
This attribute currently has effect only on Symbian platforms
- \value WA_X11DoNoAcceptFocus Asks the window manager to not give focus
+ \value WA_X11DoNotAcceptFocus Asks the window manager to not give focus
to this top level window. This attribute has no effect on non-X11
platforms.
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 505889e..1b60936 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1079,6 +1079,8 @@ QDir::Filters QDir::filter() const
\value NoSymLinks Do not list symbolic links (ignored by operating
systems that don't support symbolic links).
\value NoDotAndDotDot Do not list the special entries "." and "..".
+ \value NoDot Do not list the special entry ".".
+ \value NoDotDot Do not list the special entry "..".
\value AllEntries List directories, files, drives and symlinks (this does not list
broken symlinks unless you specify System).
\value Readable List files for which the application has read
@@ -2367,7 +2369,9 @@ QDebug operator<<(QDebug debug, QDir::Filters filters)
if (filters & QDir::Files) flags << QLatin1String("Files");
if (filters & QDir::Drives) flags << QLatin1String("Drives");
if (filters & QDir::NoSymLinks) flags << QLatin1String("NoSymLinks");
- if (filters & QDir::NoDotAndDotDot) flags << QLatin1String("NoDotAndDotDot");
+ if (filters & QDir::NoDotAndDotDot) flags << QLatin1String("NoDotAndDotDot"); // ### Qt5: remove (because NoDotAndDotDot=NoDot|NoDotDot)
+ if (filters & QDir::NoDot) flags << QLatin1String("NoDot");
+ if (filters & QDir::NoDotDot) flags << QLatin1String("NoDotDot");
if ((filters & QDir::AllEntries) == QDir::AllEntries) flags << QLatin1String("AllEntries");
if (filters & QDir::Readable) flags << QLatin1String("Readable");
if (filters & QDir::Writable) flags << QLatin1String("Writable");
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index 186dd2f..28da271 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -88,7 +88,9 @@ public:
AllDirs = 0x400,
CaseSensitive = 0x800,
- NoDotAndDotDot = 0x1000,
+ NoDotAndDotDot = 0x1000, // ### Qt5 NoDotAndDotDot = NoDot|NoDotDot
+ NoDot = 0x2000,
+ NoDotDot = 0x4000,
NoFilter = -1
#ifdef QT3_SUPPORT
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 860fb63..fd4b9c1 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -287,7 +287,11 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf
const bool dotOrDotDot = fileName[0] == QLatin1Char('.')
&& ((fileNameSize == 1)
||(fileNameSize == 2 && fileName[1] == QLatin1Char('.')));
- if ((filters & QDir::NoDotAndDotDot) && dotOrDotDot)
+ if ((filters & QDir::NoDot) && dotOrDotDot && fileNameSize == 1)
+ return false;
+ if ((filters & QDir::NoDotDot) && dotOrDotDot && fileNameSize == 2)
+ return false;
+ if ((filters & QDir::NoDotAndDotDot) && dotOrDotDot) // ### Qt5 remove (NoDotAndDotDot == NoDot|NoDotDot)
return false;
// name filter
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 5e14804..a1ffb81 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -126,8 +126,10 @@ void QFSFileEnginePrivate::init()
fileAttrib = INVALID_FILE_ATTRIBUTES;
fileHandle = INVALID_HANDLE_VALUE;
mapHandle = INVALID_HANDLE_VALUE;
+#ifndef Q_OS_WINCE
cachedFd = -1;
#endif
+#endif
}
/*!
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index d07c3a0..55c779e 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -112,7 +112,11 @@ public:
HANDLE fileHandle;
HANDLE mapHandle;
QHash<uchar *, DWORD /* offset % AllocationGranularity */> maps;
+
+#ifndef Q_OS_WINCE
mutable int cachedFd;
+#endif
+
mutable DWORD fileAttrib;
#else
QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps;
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 8d34486..eeca07e 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -450,13 +450,27 @@ bool QFSFileEnginePrivate::nativeClose()
// Windows native mode.
bool ok = true;
+
+#ifndef Q_OS_WINCE
+ if (cachedFd != -1) {
+ if (::_close(cachedFd) && !::CloseHandle(fileHandle)) {
+ q->setError(QFile::UnspecifiedError, qt_error_string());
+ ok = false;
+ }
+
+ // System handle is closed with associated file descriptor.
+ fileHandle = INVALID_HANDLE_VALUE;
+ cachedFd = -1;
+
+ return ok;
+ }
+#endif
+
if ((fileHandle == INVALID_HANDLE_VALUE || !::CloseHandle(fileHandle))) {
q->setError(QFile::UnspecifiedError, qt_error_string());
ok = false;
}
fileHandle = INVALID_HANDLE_VALUE;
- cachedFd = -1; // gets closed by CloseHandle above
-
return ok;
}
@@ -1261,12 +1275,7 @@ static QString readSymLink(const QString &link)
REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)qMalloc(bufsize);
DWORD retsize = 0;
if (::DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, 0, 0, rdb, bufsize, &retsize, 0)) {
- if (rdb->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
- int length = rdb->MountPointReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
- int offset = rdb->MountPointReparseBuffer.SubstituteNameOffset / sizeof(wchar_t);
- const wchar_t* PathBuffer = &rdb->MountPointReparseBuffer.PathBuffer[offset];
- result = QString::fromWCharArray(PathBuffer, length);
- } else {
+ if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
int length = rdb->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
int offset = rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t);
const wchar_t* PathBuffer = &rdb->SymbolicLinkReparseBuffer.PathBuffer[offset];
@@ -1529,8 +1538,7 @@ bool QFSFileEnginePrivate::isSymlink() const
if (hFind != INVALID_HANDLE_VALUE) {
::FindClose(hFind);
if ((findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
- && (findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT
- || findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
+ && findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
is_link = true;
}
}
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index 394323f..eb42c20 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -100,7 +100,7 @@ qint64 QWindowsPipeWriter::write(const char *ptr, qint64 maxlen)
void QWindowsPipeWriter::run()
{
- OVERLAPPED overl = {0, 0, 0, 0, NULL};
+ OVERLAPPED overl = {0, 0, {{ 0 }}, 0};
overl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
forever {
lock.lock();
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 566626d..c1925e7 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -1022,12 +1022,12 @@ QString decodeMSG(const MSG& msg)
if (!winPos)
break;
QString hwndAfter = valueCheck(quint64(winPos->hwndInsertAfter),
- FLAG_STRING((quintptr)HWND_BOTTOM, "HWND_BOTTOM"),
- FLAG_STRING((quintptr)HWND_NOTOPMOST, "HWND_NOTOPMOST"),
- FLAG_STRING((quintptr)HWND_TOP, "HWND_TOP"),
- FLAG_STRING((quintptr)HWND_TOPMOST, "HWND_TOPMOST"),
+ FLAG_STRING((qptrdiff)HWND_BOTTOM, "HWND_BOTTOM"),
+ FLAG_STRING((qptrdiff)HWND_NOTOPMOST, "HWND_NOTOPMOST"),
+ FLAG_STRING((qptrdiff)HWND_TOP, "HWND_TOP"),
+ FLAG_STRING((qptrdiff)HWND_TOPMOST, "HWND_TOPMOST"),
FLAG_STRING());
- if (hwndAfter.size() == 0)
+ if (hwndAfter.isEmpty())
hwndAfter = QString::number((quintptr)winPos->hwndInsertAfter, 16);
QString flags = flagCheck(winPos->flags,
FLGSTR(SWP_DRAWFRAME),
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 312c4b2..4ad78fd 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -483,38 +483,37 @@ int QMetaObject::classInfoCount() const
}
/** \internal
-* helper class for indexOf{Method,Slot,Signal}, returns the relative index of the method within
+* helper function for indexOf{Method,Slot,Signal}, returns the relative index of the method within
* the baseObject
* \a MethodType might be MethodSignal or MethodSlot, or 0 to match everything.
+* \a normalizeStringData set to true if we should do a second pass for old moc generated files normalizing all the symbols.
*/
template<int MethodType>
static inline int indexOfMethodRelative(const QMetaObject **baseObject,
const char *method,
bool normalizeStringData)
{
- const QMetaObject *m;
- for (m = *baseObject; m; m = *baseObject = m->d.superdata) {
- const QMetaObject *const m = *baseObject;
+ for (const QMetaObject *m = *baseObject; m; m = m->d.superdata) {
int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4)
? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1);
- if (i < 0)
- continue;
-
const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4)
? (priv(m->d.data)->signalCount) : 0;
if (!normalizeStringData) {
for (; i >= end; --i) {
- if ((MethodType == 0 || (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType)
- && strcmp(method, m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0)
+ const char *stringdata = m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5*i];
+ if (method[0] == stringdata[0] && strcmp(method + 1, stringdata + 1) == 0) {
+ *baseObject = m;
return i;
+ }
}
} else if (priv(m->d.data)->revision < 5) {
- const char *stringdata = (m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5 * i]);
- const QByteArray normalizedSignature = QMetaObject::normalizedSignature(stringdata);
for (; i >= end; --i) {
- if ((MethodType == 0|| (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType)
- && normalizedSignature == method)
+ const char *stringdata = (m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5 * i]);
+ const QByteArray normalizedSignature = QMetaObject::normalizedSignature(stringdata);
+ if (normalizedSignature == method) {
+ *baseObject = m;
return i;
+ }
}
}
}
@@ -537,8 +536,8 @@ int QMetaObject::indexOfConstructor(const char *constructor) const
if (priv(d.data)->revision < 2)
return -1;
for (int i = priv(d.data)->constructorCount-1; i >= 0; --i) {
- if (strcmp(constructor, d.stringdata
- + d.data[priv(d.data)->constructorData + 5*i]) == 0) {
+ const char *data = d.stringdata + d.data[priv(d.data)->constructorData + 5*i];
+ if (data[0] == constructor[0] && strcmp(constructor + 1, data + 1) == 0) {
return i;
}
}
@@ -682,18 +681,19 @@ static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, co
*/
int QMetaObject::indexOfEnumerator(const char *name) const
{
- int i = -1;
const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->enumeratorCount-1; i >= 0; --i)
- if (strcmp(name, m->d.stringdata
- + m->d.data[priv(m->d.data)->enumeratorData + 4*i]) == 0) {
+ while (m) {
+ const QMetaObjectPrivate *d = priv(m->d.data);
+ for (int i = d->enumeratorCount - 1; i >= 0; --i) {
+ const char *prop = m->d.stringdata + m->d.data[d->enumeratorData + 4*i];
+ if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
i += m->enumeratorOffset();
- break;
+ return i;
}
+ }
m = m->d.superdata;
}
- return i;
+ return -1;
}
/*!
@@ -704,26 +704,27 @@ int QMetaObject::indexOfEnumerator(const char *name) const
*/
int QMetaObject::indexOfProperty(const char *name) const
{
- int i = -1;
const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->propertyCount-1; i >= 0; --i)
- if (strcmp(name, m->d.stringdata
- + m->d.data[priv(m->d.data)->propertyData + 3*i]) == 0) {
+ while (m) {
+ const QMetaObjectPrivate *d = priv(m->d.data);
+ for (int i = d->propertyCount-1; i >= 0; --i) {
+ const char *prop = m->d.stringdata + m->d.data[d->propertyData + 3*i];
+ if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
i += m->propertyOffset();
- break;
+ return i;
}
+ }
m = m->d.superdata;
}
- if (i == -1 && priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)){
+ if (priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)) {
QAbstractDynamicMetaObject *me =
const_cast<QAbstractDynamicMetaObject *>(static_cast<const QAbstractDynamicMetaObject *>(this));
- i = me->createProperty(name, 0);
+ return me->createProperty(name, 0);
}
- return i;
+ return -1;
}
/*!
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 7d1e1d3..ca54c6c 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -412,12 +412,12 @@ bool QTranslator::load(const QString & filename, const QString & directory,
realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix);
fi.setFile(realname);
- if (fi.isReadable())
+ if (fi.isReadable() && fi.isFile())
break;
realname = prefix + fname;
fi.setFile(realname);
- if (fi.isReadable())
+ if (fi.isReadable() && fi.isFile())
break;
int rightmost = 0;
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index caa47d0..c3f6783 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -1274,25 +1274,11 @@ QLocale QSystemLocale::fallbackLocale() const
*/
QVariant QSystemLocale::query(QueryType type, QVariant /* in */) const
{
- switch (type) {
- case MeasurementSystem:
+ if (type == MeasurementSystem) {
return QVariant(unixGetSystemMeasurementSystem());
- case LanguageId:
- case CountryId: {
- QString locale = QLatin1String(envVarLocale());
- QLocale::Language lang;
- QLocale::Country cntry;
- getLangAndCountry(locale, lang, cntry);
- if (type == LanguageId)
- return lang;
- if (cntry == QLocale::AnyCountry)
- return fallbackLocale().country();
- return cntry;
- }
- default:
- break;
+ } else {
+ return QVariant();
}
- return QVariant();
}
#elif !defined(Q_OS_SYMBIAN)
@@ -1324,10 +1310,12 @@ QVariant QSystemLocale::query(QueryType /* type */, QVariant /* in */) const
#endif
+#ifndef QT_NO_SYSTEMLOCALE
static QSystemLocale *_systemLocale = 0;
Q_GLOBAL_STATIC_WITH_ARGS(QSystemLocale, QSystemLocale_globalSystemLocale, (true))
static QLocalePrivate *system_lp = 0;
Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate)
+#endif
/******************************************************************************
** Default system locale behavior
@@ -1400,8 +1388,7 @@ QSystemLocale::QSystemLocale()
/*! \internal */
QSystemLocale::QSystemLocale(bool)
-{
-}
+{ }
/*!
Deletes the object.
@@ -1423,42 +1410,16 @@ static const QSystemLocale *systemLocale()
return QSystemLocale_globalSystemLocale();
}
-static const QLocalePrivate *maybeSystemPrivate();
-bool QLocalePrivate::isUninitializedSystemLocale() const
-{
- return this == maybeSystemPrivate() && m_language_id == 0;
-}
-
-QVariant QLocalePrivate::querySystemLocale(int type, const QVariant &in) const
-{
- QVariant res = systemLocale()->query(QSystemLocale::QueryType(type), in);
- if (res.isNull() && isUninitializedSystemLocale()) {
- // if we were not able to get data from the system, initialize the
- // system locale private data (which is essentially equals to this)
- // with a fallback locale.
- QLocalePrivate *system_private = globalLocalePrivate();
- *system_private = *systemLocale()->fallbackLocale().d();
- // internal cache is not initialized with values from the system, mark
- // it as not fully initialized system locale.
- system_private->m_language_id = 0;
- }
- return res;
-}
-
-// retrieves data from the system locale and caches them locally.
void QLocalePrivate::updateSystemPrivate()
{
const QSystemLocale *sys_locale = systemLocale();
if (!system_lp)
- return;
-
- // copy over the information from the fallback locale and modify
+ system_lp = globalLocalePrivate();
*system_lp = *sys_locale->fallbackLocale().d();
QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant());
if (!res.isNull())
system_lp->m_language_id = res.toInt();
-
res = sys_locale->query(QSystemLocale::CountryId, QVariant());
if (!res.isNull())
system_lp->m_country_id = res.toInt();
@@ -1485,29 +1446,19 @@ void QLocalePrivate::updateSystemPrivate()
}
#endif
-// returns the private data for the system locale. Cached data will not be
-// initialized until the updateSystemPrivate is called.
static const QLocalePrivate *systemPrivate()
{
#ifndef QT_NO_SYSTEMLOCALE
- if (!system_lp) {
- system_lp = globalLocalePrivate();
- // mark the locale as uninitialized system locale
- system_lp->m_language_id = 0;
- }
+ // copy over the information from the fallback locale and modify
+ if (!system_lp || system_lp->m_language_id == 0)
+ QLocalePrivate::updateSystemPrivate();
+
return system_lp;
#else
return locale_data;
#endif
}
-#ifndef QT_NO_SYSTEMLOCALE
-static const QLocalePrivate *maybeSystemPrivate()
-{
- return system_lp;
-}
-#endif
-
static const QLocalePrivate *defaultPrivate()
{
if (!default_lp)
@@ -2386,12 +2337,7 @@ void QLocale::setDefault(const QLocale &locale)
*/
QLocale::Language QLocale::language() const
{
- const QLocalePrivate *dd = d();
-#ifndef QT_NO_SYSTEMLOCALE
- if (dd->isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
- return Language(dd->languageId());
+ return Language(d()->languageId());
}
/*!
@@ -2401,12 +2347,7 @@ QLocale::Language QLocale::language() const
*/
QLocale::Country QLocale::country() const
{
- const QLocalePrivate *dd = d();
-#ifndef QT_NO_SYSTEMLOCALE
- if (dd->isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
- return Country(dd->countryId());
+ return Country(d()->countryId());
}
/*!
@@ -2744,8 +2685,8 @@ QString QLocale::toString(const QDate &date, FormatType format) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(format == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateToStringLong : QSystemLocale::DateToStringShort,
date);
if (!res.isNull())
@@ -2839,8 +2780,8 @@ QString QLocale::toString(const QDateTime &dateTime, FormatType format) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(format == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateTimeToStringLong
: QSystemLocale::DateTimeToStringShort,
dateTime);
@@ -2865,8 +2806,8 @@ QString QLocale::toString(const QTime &time, FormatType format) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(format == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::TimeToStringLong : QSystemLocale::TimeToStringShort,
time);
if (!res.isNull())
@@ -2892,8 +2833,8 @@ QString QLocale::toString(const QTime &time, FormatType format) const
QString QLocale::dateFormat(FormatType format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(format == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateFormatLong : QSystemLocale::DateFormatShort,
QVariant());
if (!res.isNull())
@@ -2929,8 +2870,8 @@ QString QLocale::dateFormat(FormatType format) const
QString QLocale::timeFormat(FormatType format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(format == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::TimeFormatLong : QSystemLocale::TimeFormatShort,
QVariant());
if (!res.isNull())
@@ -2966,8 +2907,8 @@ QString QLocale::timeFormat(FormatType format) const
QString QLocale::dateTimeFormat(FormatType format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(format == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateTimeFormatLong
: QSystemLocale::DateTimeFormatShort,
QVariant());
@@ -3134,12 +3075,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format) cons
*/
QChar QLocale::decimalPoint() const
{
- const QLocalePrivate *dd = d();
-#ifndef QT_NO_SYSTEMLOCALE
- if (dd->isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
- return dd->decimal();
+ return d()->decimal();
}
/*!
@@ -3149,12 +3085,7 @@ QChar QLocale::decimalPoint() const
*/
QChar QLocale::groupSeparator() const
{
- const QLocalePrivate *dd = d();
-#ifndef QT_NO_SYSTEMLOCALE
- if (dd->isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
- return dd->group();
+ return d()->group();
}
/*!
@@ -3164,12 +3095,7 @@ QChar QLocale::groupSeparator() const
*/
QChar QLocale::percent() const
{
- const QLocalePrivate *dd = d();
-#ifndef QT_NO_SYSTEMLOCALE
- if (dd->isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
- return dd->percent();
+ return d()->percent();
}
/*!
@@ -3179,12 +3105,7 @@ QChar QLocale::percent() const
*/
QChar QLocale::zeroDigit() const
{
- const QLocalePrivate *dd = d();
-#ifndef QT_NO_SYSTEMLOCALE
- if (dd->isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
- return dd->zero();
+ return d()->zero();
}
/*!
@@ -3194,12 +3115,7 @@ QChar QLocale::zeroDigit() const
*/
QChar QLocale::negativeSign() const
{
- const QLocalePrivate *dd = d();
-#ifndef QT_NO_SYSTEMLOCALE
- if (dd->isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
- return dd->minus();
+ return d()->minus();
}
/*!
@@ -3209,12 +3125,7 @@ QChar QLocale::negativeSign() const
*/
QChar QLocale::positiveSign() const
{
- const QLocalePrivate *dd = d();
-#ifndef QT_NO_SYSTEMLOCALE
- if (dd->isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
- return dd->plus();
+ return d()->plus();
}
/*!
@@ -3224,12 +3135,7 @@ QChar QLocale::positiveSign() const
*/
QChar QLocale::exponential() const
{
- const QLocalePrivate *dd = d();
-#ifndef QT_NO_SYSTEMLOCALE
- if (dd->isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
- return dd->exponential();
+ return d()->exponential();
}
static bool qIsUpper(char c)
@@ -3348,8 +3254,8 @@ QString QLocale::monthName(int month, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(type == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort,
month);
if (!res.isNull())
@@ -3394,8 +3300,8 @@ QString QLocale::standaloneMonthName(int month, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(type == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort,
month);
if (!res.isNull())
@@ -3441,8 +3347,8 @@ QString QLocale::dayName(int day, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(type == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort,
day);
if (!res.isNull())
@@ -3490,8 +3396,8 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(type == LongFormat
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort,
day);
if (!res.isNull())
@@ -3535,8 +3441,8 @@ QLocale::MeasurementSystem QLocale::measurementSystem() const
bool found = false;
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(QSystemLocale::MeasurementSystem, QVariant());
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(QSystemLocale::MeasurementSystem, QVariant());
if (!res.isNull()) {
meas = MeasurementSystem(res.toInt());
found = true;
@@ -3563,8 +3469,8 @@ QLocale::MeasurementSystem QLocale::measurementSystem() const
QString QLocale::amText() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(QSystemLocale::AMText, QVariant());
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(QSystemLocale::AMText, QVariant());
if (!res.isNull())
return res.toString();
}
@@ -3583,8 +3489,8 @@ QString QLocale::amText() const
QString QLocale::pmText() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == maybeSystemPrivate()) {
- QVariant res = d()->querySystemLocale(QSystemLocale::PMText, QVariant());
+ if (d() == systemPrivate()) {
+ QVariant res = systemLocale()->query(QSystemLocale::PMText, QVariant());
if (!res.isNull())
return res.toString();
}
@@ -3999,10 +3905,6 @@ QString QLocalePrivate::doubleToString(double d,
int width,
unsigned flags) const
{
-#ifndef QT_NO_SYSTEMLOCALE
- if (isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
if (precision == -1)
precision = 6;
if (width == -1)
@@ -4153,10 +4055,6 @@ QString QLocalePrivate::longLongToString(qlonglong l, int precision,
int base, int width,
unsigned flags) const
{
-#ifndef QT_NO_SYSTEMLOCALE
- if (isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
bool precision_not_specified = false;
if (precision == -1) {
precision_not_specified = true;
@@ -4242,10 +4140,6 @@ QString QLocalePrivate::unsLongLongToString(qulonglong l, int precision,
int base, int width,
unsigned flags) const
{
-#ifndef QT_NO_SYSTEMLOCALE
- if (isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
bool precision_not_specified = false;
if (precision == -1) {
precision_not_specified = true;
@@ -4448,10 +4342,6 @@ bool QLocalePrivate::numberToCLocale(const QString &num,
bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByteArray *buff,
int decDigits) const
{
-#ifndef QT_NO_SYSTEMLOCALE
- if (isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
buff->clear();
buff->reserve(str.length());
@@ -4545,10 +4435,6 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte
double QLocalePrivate::stringToDouble(const QString &number, bool *ok,
GroupSeparatorMode group_sep_mode) const
{
-#ifndef QT_NO_SYSTEMLOCALE
- if (isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
CharBuff buff;
if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number,
group_sep_mode, &buff)) {
@@ -4562,10 +4448,6 @@ double QLocalePrivate::stringToDouble(const QString &number, bool *ok,
qlonglong QLocalePrivate::stringToLongLong(const QString &number, int base,
bool *ok, GroupSeparatorMode group_sep_mode) const
{
-#ifndef QT_NO_SYSTEMLOCALE
- if (isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
CharBuff buff;
if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number,
group_sep_mode, &buff)) {
@@ -4580,10 +4462,6 @@ qlonglong QLocalePrivate::stringToLongLong(const QString &number, int base,
qulonglong QLocalePrivate::stringToUnsLongLong(const QString &number, int base,
bool *ok, GroupSeparatorMode group_sep_mode) const
{
-#ifndef QT_NO_SYSTEMLOCALE
- if (isUninitializedSystemLocale())
- QLocalePrivate::updateSystemPrivate();
-#endif
CharBuff buff;
if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number,
group_sep_mode, &buff)) {
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index 3b4e9dc..ac05c86 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -691,7 +691,6 @@ public:
;
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 {
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index 003ae8c..ecf79e9 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -63,14 +63,14 @@ QT_BEGIN_NAMESPACE
struct Q_CORE_EXPORT QLocalePrivate
{
public:
- QChar decimal() const { Q_ASSERT(m_decimal); return QChar(m_decimal); }
- QChar group() const { Q_ASSERT(m_group); return QChar(m_group); }
- QChar list() const { Q_ASSERT(m_list); return QChar(m_list); }
- QChar percent() const { Q_ASSERT(m_percent); return QChar(m_percent); }
- QChar zero() const { Q_ASSERT(m_zero); return QChar(m_zero); }
- QChar plus() const { Q_ASSERT(m_plus); return QChar(m_plus); }
- QChar minus() const { Q_ASSERT(m_minus); return QChar(m_minus); }
- QChar exponential() const { Q_ASSERT(m_exponential); return QChar(m_exponential); }
+ 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); }
quint32 languageId() const { return m_language_id; }
quint32 countryId() const { return m_country_id; }
@@ -132,8 +132,6 @@ public:
CharBuff *result) const;
inline char digitToCLocale(const QChar &c) const;
- inline bool isUninitializedSystemLocale() const;
- QVariant querySystemLocale(int type, const QVariant &in) const;
static void updateSystemPrivate();
enum NumberMode { IntegerMode, DoubleStandardMode, DoubleScientificMode };
diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp
index 58e3ba8..01f56cc 100644
--- a/src/corelib/tools/qlocale_symbian.cpp
+++ b/src/corelib/tools/qlocale_symbian.cpp
@@ -133,7 +133,7 @@ static const symbianToISO symbian_to_iso_list[] = {
{ ELangMalay, "ms_MY" },
{ ELangBrazilianPortuguese, "pt_BR" },
{ ELangRomanian, "ro_RO" },
- { ELangSerbian, "sr_YU" },
+ { ELangSerbian, "sr_RS" },
{ ELangLatinAmericanSpanish, "es" },
{ ELangUkrainian, "uk_UA" },
{ ELangUrdu, "ur_PK" }, // India/Pakistan
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 464e77b..2f12b80 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -5104,8 +5104,19 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
const char *c = cformat;
for (;;) {
// Copy non-escape chars to result
+#ifndef QT_NO_TEXTCODEC
+ int i = 0;
+ while (*(c + i) != '\0' && *(c + i) != '%')
+ ++i;
+ if (codecForCStrings)
+ result.append(codecForCStrings->toUnicode(c, i));
+ else
+ result.append(fromLatin1(c, i));
+ c += i;
+#else
while (*c != '\0' && *c != '%')
result.append(QLatin1Char(*c++));
+#endif
if (*c == '\0')
break;
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
index 1ebbaee..d19e5a5 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
@@ -74,7 +74,7 @@ public:
Here is a Flipable that flips whenever it is clicked:
- \snippet examples/declarative/flipable/flipable.qml 0
+ \snippet examples/declarative/flipable/flipable-example.qml 0
\image flipable.gif
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 4ba80ad..0bc4b8b 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -1264,22 +1264,22 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec
*/
/*!
- \fn void QDeclarativeItem::childrenRectChanged()
+ \fn void QDeclarativeItem::childrenRectChanged(const QRectF &)
\internal
*/
/*!
- \fn void QDeclarativeItem::baselineOffsetChanged()
+ \fn void QDeclarativeItem::baselineOffsetChanged(qreal)
\internal
*/
/*!
- \fn void QDeclarativeItem::widthChanged()
+ \fn void QDeclarativeItem::widthChanged(qreal)
\internal
*/
/*!
- \fn void QDeclarativeItem::heightChanged()
+ \fn void QDeclarativeItem::heightChanged(qreal)
\internal
*/
@@ -1289,17 +1289,17 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec
*/
/*!
- \fn void QDeclarativeItem::parentChanged()
+ \fn void QDeclarativeItem::parentChanged(QDeclarativeItem *)
\internal
*/
/*!
- \fn void QDeclarativeItem::smoothChanged()
+ \fn void QDeclarativeItem::smoothChanged(bool)
\internal
*/
/*!
- \fn void QDeclarativeItem::clipChanged()
+ \fn void QDeclarativeItem::clipChanged(bool)
\internal
*/
@@ -1313,12 +1313,12 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec
*/
/*!
- \fn void QDeclarativeItem::focusChanged()
+ \fn void QDeclarativeItem::focusChanged(bool)
\internal
*/
/*!
- \fn void QDeclarativeItem::wantsFocusChanged()
+ \fn void QDeclarativeItem::wantsFocusChanged(bool)
\internal
*/
diff --git a/src/declarative/qml/qdeclarativecompiledbindings_p.h b/src/declarative/qml/qdeclarativecompiledbindings_p.h
index 84a5df9..8776c08 100644
--- a/src/declarative/qml/qdeclarativecompiledbindings_p.h
+++ b/src/declarative/qml/qdeclarativecompiledbindings_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QDeclarativeBindingCompilerPrivate;
+struct QDeclarativeBindingCompilerPrivate;
class QDeclarativeBindingCompiler
{
public:
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 64d46d5..a47e868 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -2094,7 +2094,7 @@ bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeParser::Propert
buildDynamicMeta(baseObj, ForceCreation);
v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
} else {
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" cannot operate on \"%2\"").arg(QLatin1String(v->object->typeName.constData())).arg(QLatin1String(prop->name.constData())));
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" cannot operate on \"%2\"").arg(QString::fromUtf8(v->object->typeName)).arg(QString::fromUtf8(prop->name.constData())));
}
return true;
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 800434a..1a40857 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -116,16 +116,16 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
/*!
- \qmlclass QtObject QObject
+ \qmlclass QtObject QObject
\since 4.7
- \brief The QtObject element is the most basic element in QML
+ \brief The QtObject element is the most basic element in QML
- The QtObject element is a non-visual element which contains only
- the objectName property. It is useful for when you need an extremely
- lightweight element to place your own custom properties in.
+ The QtObject element is a non-visual element which contains only the
+ objectName property. It is useful for when you need an extremely
+ lightweight element to place your own custom properties in.
- It can also be useful for C++ integration, as it is just a plain QObject. See
- the QObject documentation for further details.
+ It can also be useful for C++ integration, as it is just a plain
+ QObject. See the QObject documentation for further details.
*/
/*!
\qmlproperty string QtObject::objectName
@@ -374,37 +374,38 @@ QDeclarativeWorkerScriptEngine *QDeclarativeEnginePrivate::getWorkerScriptEngine
}
/*!
- \class QDeclarativeEngine
+ \class QDeclarativeEngine
\since 4.7
- \brief The QDeclarativeEngine class provides an environment for instantiating QML components.
- \mainclass
-
- Each QML component is instantiated in a QDeclarativeContext. QDeclarativeContext's are
- essential for passing data to QML components. In QML, contexts are arranged
- hierarchically and this hierarchy is managed by the QDeclarativeEngine.
-
- Prior to creating any QML components, an application must have created a
- QDeclarativeEngine to gain access to a QML context. The following example shows how
- to create a simple Text item.
-
- \code
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import Qt 4.6\nText { text: \"Hello world!\" }", QUrl());
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create());
-
- //add item to view, etc
- ...
- \endcode
-
- In this case, the Text item will be created in the engine's
- \l {QDeclarativeEngine::rootContext()}{root context}.
-
- \sa QDeclarativeComponent QDeclarativeContext
+ \brief The QDeclarativeEngine class provides an environment for instantiating QML components.
+ \mainclass
+
+ Each QML component is instantiated in a QDeclarativeContext.
+ QDeclarativeContext's are essential for passing data to QML
+ components. In QML, contexts are arranged hierarchically and this
+ hierarchy is managed by the QDeclarativeEngine.
+
+ Prior to creating any QML components, an application must have
+ created a QDeclarativeEngine to gain access to a QML context. The
+ following example shows how to create a simple Text item.
+
+ \code
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6\nText { text: \"Hello world!\" }", QUrl());
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create());
+
+ //add item to view, etc
+ ...
+ \endcode
+
+ In this case, the Text item will be created in the engine's
+ \l {QDeclarativeEngine::rootContext()}{root context}.
+
+ \sa QDeclarativeComponent QDeclarativeContext
*/
/*!
- Create a new QDeclarativeEngine with the given \a parent.
+ Create a new QDeclarativeEngine with the given \a parent.
*/
QDeclarativeEngine::QDeclarativeEngine(QObject *parent)
: QObject(*new QDeclarativeEnginePrivate(this), parent)
@@ -414,10 +415,11 @@ QDeclarativeEngine::QDeclarativeEngine(QObject *parent)
}
/*!
- Destroys the QDeclarativeEngine.
+ Destroys the QDeclarativeEngine.
- Any QDeclarativeContext's created on this engine will be invalidated, but not
- destroyed (unless they are parented to the QDeclarativeEngine object).
+ Any QDeclarativeContext's created on this engine will be
+ invalidated, but not destroyed (unless they are parented to the
+ QDeclarativeEngine object).
*/
QDeclarativeEngine::~QDeclarativeEngine()
{
@@ -433,8 +435,9 @@ QDeclarativeEngine::~QDeclarativeEngine()
/*!
Clears the engine's internal component cache.
- Normally the QDeclarativeEngine caches components loaded from qml files. This method
- clears this cache and forces the component to be reloaded.
+ Normally the QDeclarativeEngine caches components loaded from qml
+ files. This method clears this cache and forces the component to be
+ reloaded.
*/
void QDeclarativeEngine::clearComponentCache()
{
@@ -443,14 +446,15 @@ void QDeclarativeEngine::clearComponentCache()
}
/*!
- Returns the engine's root context.
+ Returns the engine's root context.
- The root context is automatically created by the QDeclarativeEngine. Data that
- should be available to all QML component instances instantiated by the
- engine should be put in the root context.
+ The root context is automatically created by the QDeclarativeEngine.
+ Data that should be available to all QML component instances
+ instantiated by the engine should be put in the root context.
- Additional data that should only be available to a subset of component
- instances should be added to sub-contexts parented to the root context.
+ Additional data that should only be available to a subset of
+ component instances should be added to sub-contexts parented to the
+ root context.
*/
QDeclarativeContext *QDeclarativeEngine::rootContext()
{
@@ -459,14 +463,14 @@ QDeclarativeContext *QDeclarativeEngine::rootContext()
}
/*!
- Sets the \a factory to use for creating QNetworkAccessManager(s).
+ Sets the \a factory to use for creating QNetworkAccessManager(s).
- QNetworkAccessManager is used for all network access by QML.
- By implementing a factory it is possible to create custom
- QNetworkAccessManager with specialized caching, proxy and
- cookie support.
+ QNetworkAccessManager is used for all network access by QML. By
+ implementing a factory it is possible to create custom
+ QNetworkAccessManager with specialized caching, proxy and cookie
+ support.
- The factory must be set before exceuting the engine.
+ The factory must be set before exceuting the engine.
*/
void QDeclarativeEngine::setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *factory)
{
@@ -476,9 +480,9 @@ void QDeclarativeEngine::setNetworkAccessManagerFactory(QDeclarativeNetworkAcces
}
/*!
- Returns the current QDeclarativeNetworkAccessManagerFactory.
+ Returns the current QDeclarativeNetworkAccessManagerFactory.
- \sa setNetworkAccessManagerFactory()
+ \sa setNetworkAccessManagerFactory()
*/
QDeclarativeNetworkAccessManagerFactory *QDeclarativeEngine::networkAccessManagerFactory() const
{
@@ -508,15 +512,16 @@ QNetworkAccessManager *QDeclarativeEnginePrivate::getNetworkAccessManager() cons
}
/*!
- Returns a common QNetworkAccessManager which can be used by any QML element
- instantiated by this engine.
+ Returns a common QNetworkAccessManager which can be used by any QML
+ element instantiated by this engine.
- If a QDeclarativeNetworkAccessManagerFactory has been set and a QNetworkAccessManager
- has not yet been created, the QDeclarativeNetworkAccessManagerFactory will be used
- to create the QNetworkAccessManager; otherwise the returned QNetworkAccessManager
- will have no proxy or cache set.
+ If a QDeclarativeNetworkAccessManagerFactory has been set and a
+ QNetworkAccessManager has not yet been created, the
+ QDeclarativeNetworkAccessManagerFactory will be used to create the
+ QNetworkAccessManager; otherwise the returned QNetworkAccessManager
+ will have no proxy or cache set.
- \sa setNetworkAccessManagerFactory()
+ \sa setNetworkAccessManagerFactory()
*/
QNetworkAccessManager *QDeclarativeEngine::networkAccessManager() const
{
@@ -525,26 +530,27 @@ QNetworkAccessManager *QDeclarativeEngine::networkAccessManager() const
}
/*!
- Sets the \a provider to use for images requested via the \e image: url
- scheme, with host \a providerId.
- QDeclarativeImageProvider allows images to be provided to QML asynchronously.
- The image request will be run in a low priority thread. This allows
- potentially costly image loading to be done in the background, without
- affecting the performance of the UI.
+ Sets the \a provider to use for images requested via the \e
+ image: url scheme, with host \a providerId.
+
+ QDeclarativeImageProvider allows images to be provided to QML
+ asynchronously. The image request will be run in a low priority
+ thread. This allows potentially costly image loading to be done in
+ the background, without affecting the performance of the UI.
- Note that images loaded from a QDeclarativeImageProvider are cached by
- QPixmapCache, similar to any image loaded by QML.
+ Note that images loaded from a QDeclarativeImageProvider are cached
+ by QPixmapCache, similar to any image loaded by QML.
- The QDeclarativeEngine assumes ownership of the provider.
+ The QDeclarativeEngine assumes ownership of the provider.
- This example creates a provider with id \e colors:
+ This example creates a provider with id \e colors:
- \snippet examples/declarative/imageprovider/imageprovider.cpp 0
+ \snippet examples/declarative/imageprovider/imageprovider.cpp 0
- \snippet examples/declarative/imageprovider/imageprovider.qml 0
+ \snippet examples/declarative/imageprovider/imageprovider-example.qml 0
- \sa removeImageProvider()
+ \sa removeImageProvider()
*/
void QDeclarativeEngine::addImageProvider(const QString &providerId, QDeclarativeImageProvider *provider)
{
@@ -554,7 +560,7 @@ void QDeclarativeEngine::addImageProvider(const QString &providerId, QDeclarativ
}
/*!
- Returns the QDeclarativeImageProvider set for \a providerId.
+ Returns the QDeclarativeImageProvider set for \a providerId.
*/
QDeclarativeImageProvider *QDeclarativeEngine::imageProvider(const QString &providerId) const
{
@@ -564,11 +570,11 @@ QDeclarativeImageProvider *QDeclarativeEngine::imageProvider(const QString &prov
}
/*!
- Removes the QDeclarativeImageProvider for \a providerId.
+ Removes the QDeclarativeImageProvider for \a providerId.
- Returns the provider if it was found; otherwise returns 0.
+ Returns the provider if it was found; otherwise returns 0.
- \sa addImageProvider()
+ \sa addImageProvider()
*/
void QDeclarativeEngine::removeImageProvider(const QString &providerId)
{
@@ -588,13 +594,14 @@ QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url)
}
/*!
- Return the base URL for this engine. The base URL is only used to resolve
- components when a relative URL is passed to the QDeclarativeComponent constructor.
+ Return the base URL for this engine. The base URL is only used to
+ resolve components when a relative URL is passed to the
+ QDeclarativeComponent constructor.
- If a base URL has not been explicitly set, this method returns the
- application's current working directory.
+ If a base URL has not been explicitly set, this method returns the
+ application's current working directory.
- \sa setBaseUrl()
+ \sa setBaseUrl()
*/
QUrl QDeclarativeEngine::baseUrl() const
{
@@ -607,9 +614,9 @@ QUrl QDeclarativeEngine::baseUrl() const
}
/*!
- Set the base URL for this engine to \a url.
+ Set the base URL for this engine to \a url.
- \sa baseUrl()
+ \sa baseUrl()
*/
void QDeclarativeEngine::setBaseUrl(const QUrl &url)
{
@@ -618,9 +625,11 @@ void QDeclarativeEngine::setBaseUrl(const QUrl &url)
}
/*!
- Returns the QDeclarativeContext for the \a object, or 0 if no context has been set.
+ Returns the QDeclarativeContext for the \a object, or 0 if no
+ context has been set.
- When the QDeclarativeEngine instantiates a QObject, the context is set automatically.
+ When the QDeclarativeEngine instantiates a QObject, the context is
+ set automatically.
*/
QDeclarativeContext *QDeclarativeEngine::contextForObject(const QObject *object)
{
@@ -645,7 +654,8 @@ QDeclarativeContext *QDeclarativeEngine::contextForObject(const QObject *object)
If the \a object already has a context, a warning is
output, but the context is not changed.
- When the QDeclarativeEngine instantiates a QObject, the context is set automatically.
+ When the QDeclarativeEngine instantiates a QObject, the context is
+ set automatically.
*/
void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContext *context)
{
@@ -663,37 +673,43 @@ void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContex
}
/*!
-\enum QDeclarativeEngine::ObjectOwnership
-
-Ownership controls whether or not QML automatically destroys the QObject when the object
-is garbage collected by the JavaScript engine. The two ownership options are:
-
-\list
-\o CppOwnership - The object is owned by C++ code, and will never be deleted by QML. The
-JavaScript destroy() method cannot be used on objects with CppOwnership. This option
-is similar to QScriptEngine::QtOwnership.
-
-\o JavaScriptOwnership - The object is owned by JavaScript. When the object is returned to QML
-as the return value of a method call or property access, QML will delete the object if there
-are no remaining JavaScript references to it and it has no QObject::parent(). This option
-is similar to QScriptEngine::ScriptOwnership.
-\endlist
-
-Generally an application doesn't need to set an object's ownership explicitly. QML uses
-a heuristic to set the default object ownership. By default, an object that is created by
-QML has JavaScriptOwnership. The exception to this are the root objects created by calling
-QDeclarativeCompnent::create() or QDeclarativeComponent::beginCreate() which have
-CppOwnership by default. The ownership of these root-level objects is considered to have
-been transfered to the C++ caller.
-
-Objects not-created by QML have CppOwnership by default. The exception to this is objects
-returned from a C++ method call. The ownership of these objects is passed to JavaScript.
-
-Calling setObjectOwnership() overrides the default ownership heuristic used by QML.
+ \enum QDeclarativeEngine::ObjectOwnership
+
+ Ownership controls whether or not QML automatically destroys the
+ QObject when the object is garbage collected by the JavaScript
+ engine. The two ownership options are:
+
+ \value CppOwnership The object is owned by C++ code, and will
+ never be deleted by QML. The JavaScript destroy() method cannot be
+ used on objects with CppOwnership. This option is similar to
+ QScriptEngine::QtOwnership.
+
+ \value JavaScriptOwnership The object is owned by JavaScript.
+ When the object is returned to QML as the return value of a method
+ call or property access, QML will delete the object if there are no
+ remaining JavaScript references to it and it has no
+ QObject::parent(). This option is similar to
+ QScriptEngine::ScriptOwnership.
+
+ Generally an application doesn't need to set an object's ownership
+ explicitly. QML uses a heuristic to set the default object
+ ownership. By default, an object that is created by QML has
+ JavaScriptOwnership. The exception to this are the root objects
+ created by calling QDeclarativeCompnent::create() or
+ QDeclarativeComponent::beginCreate() which have CppOwnership by
+ default. The ownership of these root-level objects is considered to
+ have been transfered to the C++ caller.
+
+ Objects not-created by QML have CppOwnership by default. The
+ exception to this is objects returned from a C++ method call. The
+ ownership of these objects is passed to JavaScript.
+
+ Calling setObjectOwnership() overrides the default ownership
+ heuristic used by QML.
*/
/*!
-Sets the \a ownership of \a object.
+ Sets the \a ownership of \a object.
*/
void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership)
{
@@ -706,7 +722,7 @@ void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership own
}
/*!
-Returns the ownership of \a object.
+ Returns the ownership of \a object.
*/
QDeclarativeEngine::ObjectOwnership QDeclarativeEngine::objectOwnership(QObject *object)
{
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index 1a36f10..d41323d 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -136,7 +136,7 @@ public:
int index() const;
private:
friend class QDeclarativeTypePrivate;
- friend class QDeclarativeMetaTypeData;
+ friend struct QDeclarativeMetaTypeData;
friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &);
friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &);
QDeclarativeType(int, const QDeclarativePrivate::RegisterInterface &);
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index ddf00ea..f455870 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -62,8 +62,7 @@ HEADERS += \
$$PWD/qdeclarativebehavior_p.h \
$$PWD/qdeclarativefontloader_p.h \
$$PWD/qdeclarativestyledtext_p.h \
- $$PWD/qdeclarativelistmodelworkeragent_p.h \
- $$PWD/qdeclarativelistmodelworkeragent_p_p.h
+ $$PWD/qdeclarativelistmodelworkeragent_p.h
contains(QT_CONFIG, xmlpatterns) {
QT+=xmlpatterns
diff --git a/src/gui/dialogs/qwizard_win_p.h b/src/gui/dialogs/qwizard_win_p.h
index fe01587..5f3b6c2 100644
--- a/src/gui/dialogs/qwizard_win_p.h
+++ b/src/gui/dialogs/qwizard_win_p.h
@@ -82,7 +82,6 @@ class QWizard;
class QVistaHelper : public QObject
{
- Q_OBJECT
public:
QVistaHelper(QWizard *wizard);
~QVistaHelper();
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 3c255ef..948ff28 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -3482,7 +3482,7 @@ void QGraphicsItem::setX(qreal x)
if (qIsNaN(x))
return;
- d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y()));
+ setPos(QPointF(x, d_ptr->pos.y()));
}
/*!
@@ -3509,7 +3509,7 @@ void QGraphicsItem::setY(qreal y)
if (qIsNaN(y))
return;
- d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y));
+ setPos(QPointF(d_ptr->pos.x(), y));
}
/*!
@@ -3577,7 +3577,7 @@ void QGraphicsItem::setPos(const QPointF &pos)
return;
// Update and repositition.
- if (!(d_ptr->flags & ItemSendsGeometryChanges)) {
+ if (!(d_ptr->flags & ItemSendsGeometryChanges) && !(d_ptr->flags & ItemSendsScenePositionChanges)) {
d_ptr->setPosHelper(pos);
return;
}
@@ -10936,7 +10936,7 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
// Item coordinates with info.
QTransform newEffectTransform = info->transformPtr->inverted();
newEffectTransform *= effectTransform;
- scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, info->exposedRegion,
+ scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform,
info->drawItem);
}
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index bcdc7d3..29a4be8 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4721,7 +4721,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
if (item->d_ptr->graphicsEffect && item->d_ptr->graphicsEffect->isEnabled()) {
ENSURE_TRANSFORM_PTR;
QGraphicsItemPaintInfo info(viewTransform, transformPtr, effectTransform, exposedRegion, widget, &styleOptionTmp,
- painter, opacity, wasDirtyParentSceneTransform, drawItem);
+ painter, opacity, wasDirtyParentSceneTransform, itemHasContents && !itemIsFullyTransparent);
QGraphicsEffectSource *source = item->d_ptr->graphicsEffect->d_func()->source;
QGraphicsItemEffectSourcePrivate *sourced = static_cast<QGraphicsItemEffectSourcePrivate *>
(source->d_func());
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 669dd61..a257e0d 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -396,6 +396,12 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
}
/*!
+ \fn QGraphicsWidget::geometryChanged()
+
+ This signal gets emitted whenever the geometry is changed in setGeometry().
+*/
+
+/*!
\fn QRectF QGraphicsWidget::rect() const
Returns the item's local rect as a QRectF. This function is equivalent
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index d7ddf4e..97fd6e1 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -104,9 +104,10 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()
horizontalScrollMode(QAbstractItemView::ScrollPerItem),
currentIndexSet(false),
wrapItemText(false),
- delayedPendingLayout(true)
+ delayedPendingLayout(true),
moveCursorUpdatedView(false)
{
+ keyboardInputTime.invalidate();
}
QAbstractItemViewPrivate::~QAbstractItemViewPrivate()
@@ -2842,17 +2843,16 @@ void QAbstractItemView::keyboardSearch(const QString &search)
QModelIndex start = currentIndex().isValid() ? currentIndex()
: d->model->index(0, 0, d->root);
- QElapsedTimer now;
- now.start();
bool skipRow = false;
- if (search.isEmpty()
- || (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) {
+ bool keyboardTimeWasValid = d->keyboardInputTime.isValid();
+ qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart();
+ if (search.isEmpty() || !keyboardTimeWasValid
+ || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) {
d->keyboardInput = search;
skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)
} else {
d->keyboardInput += search;
}
- d->keyboardInputTime = now;
// special case for searches with same key like 'aaaaa'
bool sameKey = false;
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index b2457f3..d934683 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -674,15 +674,19 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto
// refresh the height cache here; we don't really lose anything by getting the size hint,
// since QAbstractItemView::dataChanged() will get the visualRect for the items anyway
- int topViewIndex = d->viewIndex(topLeft);
- if (topViewIndex == 0)
- d->defaultItemHeight = indexRowSizeHint(topLeft);
bool sizeChanged = false;
+ int topViewIndex = d->viewIndex(topLeft);
+ if (topViewIndex == 0) {
+ int newDefaultItemHeight = indexRowSizeHint(topLeft);
+ sizeChanged = d->defaultItemHeight != newDefaultItemHeight;
+ d->defaultItemHeight = newDefaultItemHeight;
+ }
+
if (topViewIndex != -1) {
if (topLeft.row() == bottomRight.row()) {
int oldHeight = d->itemHeight(topViewIndex);
d->invalidateHeightCache(topViewIndex);
- sizeChanged = (oldHeight != d->itemHeight(topViewIndex));
+ sizeChanged |= (oldHeight != d->itemHeight(topViewIndex));
if (topLeft.column() == 0)
d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft);
} else {
@@ -958,17 +962,16 @@ void QTreeView::keyboardSearch(const QString &search)
else
start = d->model->index(0, 0, d->root);
- QElapsedTimer now;
- now.start();
bool skipRow = false;
- if (search.isEmpty()
- || (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) {
+ bool keyboardTimeWasValid = d->keyboardInputTime.isValid();
+ qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart();
+ if (search.isEmpty() || !keyboardTimeWasValid
+ || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) {
d->keyboardInput = search;
- skipRow = true;
+ skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)
} else {
d->keyboardInput += search;
}
- d->keyboardInputTime = now;
// special case for searches with same key like 'aaaaa'
bool sameKey = false;
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index ae9b34c..1d8eb4c 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1578,6 +1578,10 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_XBUTTONDOWN:
+ case WM_LBUTTONDBLCLK:
+ case WM_RBUTTONDBLCLK:
+ case WM_MBUTTONDBLCLK:
+ case WM_XBUTTONDBLCLK:
if (qt_win_ignoreNextMouseReleaseEvent)
qt_win_ignoreNextMouseReleaseEvent = false;
break;
@@ -2278,7 +2282,7 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa
case WM_GETOBJECT:
{
// Ignoring all requests while starting up
- if (QApplication::startingUp() || QApplication::closingDown() || (DWORD)lParam != OBJID_CLIENT) {
+ if (QApplication::startingUp() || QApplication::closingDown() || (LONG)lParam != OBJID_CLIENT) {
result = false;
break;
}
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 67e0865..78fc704 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -669,11 +669,6 @@ static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
return 0;
break;
- case BadMatch:
- if (err->request_code == 42 /* X_SetInputFocus */)
- return 0;
- break;
-
default:
#if !defined(QT_NO_XINPUT)
if (err->request_code == X11->xinput_major
diff --git a/src/gui/kernel/qdnd_win.cpp b/src/gui/kernel/qdnd_win.cpp
index 0742a93..a164c2a 100644
--- a/src/gui/kernel/qdnd_win.cpp
+++ b/src/gui/kernel/qdnd_win.cpp
@@ -524,18 +524,14 @@ QOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
if (fEscapePressed) {
return ResultFromScode(DRAGDROP_S_CANCEL);
- } else if (!(grfKeyState & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON))) {
+ } else if ((GetAsyncKeyState(VK_LBUTTON) == 0)
+ && (GetAsyncKeyState(VK_MBUTTON) == 0)
+ && (GetAsyncKeyState(VK_RBUTTON) == 0)) {
+ // grfKeyState is broken on CE & some Windows XP versions,
+ // therefore we need to check the state manually
return ResultFromScode(DRAGDROP_S_DROP);
} else {
-#if defined(Q_OS_WINCE)
- // grfKeyState is broken on CE, therefore need to check
- // the state manually
- if ((GetAsyncKeyState(VK_LBUTTON) == 0) &&
- (GetAsyncKeyState(VK_MBUTTON) == 0) &&
- (GetAsyncKeyState(VK_RBUTTON) == 0)) {
- return ResultFromScode(DRAGDROP_S_DROP);
- }
-#else
+#if !defined(Q_OS_WINCE)
if (currentButtons == Qt::NoButton) {
currentButtons = keystate_to_mousebutton(grfKeyState);
} else {
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index b3a6aec..ef7373c 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -4067,7 +4067,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
QRect xrect = data.crect;
QRect parentWRect;
- if (q->isWindow() && topData()->embedded) {
+ bool isEmbeddedWindow = (q->isWindow() && topData()->embedded);
+ if (isEmbeddedWindow) {
#ifndef QT_MAC_USE_COCOA
HIViewRef parentView = HIViewGetSuperview(qt_mac_nativeview_for(q));
#else
@@ -4092,7 +4093,7 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
if (parentWRect.isValid()) {
// parent is clipped, and we have to clip to the same limit as parent
- if (!parentWRect.contains(xrect)) {
+ if (!parentWRect.contains(xrect) && !isEmbeddedWindow) {
xrect &= parentWRect;
wrect = xrect;
//translate from parent's to my Qt coord sys
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index c32e1a1..ef7ac1f 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -680,7 +680,7 @@ public:
QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
// Bit fields.
- uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
+ uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
QPalette::ColorRole fg_role : 8;
QPalette::ColorRole bg_role : 8;
uint dirtyOpaqueChildren : 1;
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index c1363d2..37ac6bf 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -1642,7 +1642,8 @@ void QWidget::activateWindow()
X11->userTime = X11->time;
qt_net_update_user_time(tlw, X11->userTime);
- if (X11->isSupportedByWM(ATOM(_NET_ACTIVE_WINDOW))) {
+ if (X11->isSupportedByWM(ATOM(_NET_ACTIVE_WINDOW))
+ && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)) {
XEvent e;
e.xclient.type = ClientMessage;
e.xclient.message_type = ATOM(_NET_ACTIVE_WINDOW);
@@ -1660,7 +1661,8 @@ void QWidget::activateWindow()
XSendEvent(X11->display, RootWindow(X11->display, tlw->x11Info().screen()),
false, SubstructureNotifyMask | SubstructureRedirectMask, &e);
} else {
- XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time);
+ if (!qt_widget_private(tlw)->topData()->waitingForMapNotify)
+ XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time);
}
}
}
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 71e2e3b..1f75ec7 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -3884,8 +3884,8 @@ inline void interpolate_pixel_unaligned_2(DST *dest, const SRC *src,
template <class DST, class SRC>
inline void interpolate_pixel_2(DST *dest, const SRC *src, quint16 alpha)
{
- Q_ASSERT((long(dest) & 0x3) == 0);
- Q_ASSERT((long(src) & 0x3) == 0);
+ Q_ASSERT((quintptr(dest) & 0x3) == 0);
+ Q_ASSERT((quintptr(src) & 0x3) == 0);
const quint16 a = eff_alpha_2(alpha, dest);
const quint16 ia = eff_ialpha_2(alpha, dest);
@@ -3958,8 +3958,8 @@ template <class DST, class SRC>
inline void interpolate_pixel_2(DST *dest, quint8 a,
const SRC *src, quint8 b)
{
- Q_ASSERT((long(dest) & 0x3) == 0);
- Q_ASSERT((long(src) & 0x3) == 0);
+ Q_ASSERT((quintptr(dest) & 0x3) == 0);
+ Q_ASSERT((quintptr(src) & 0x3) == 0);
Q_ASSERT(!SRC::hasAlpha());
@@ -4007,8 +4007,8 @@ inline void interpolate_pixel_2(qrgb444 *dest, quint8 a,
template <class DST, class SRC>
inline void interpolate_pixel_4(DST *dest, const SRC *src, quint32 alpha)
{
- Q_ASSERT((long(dest) & 0x3) == 0);
- Q_ASSERT((long(src) & 0x3) == 0);
+ Q_ASSERT((quintptr(dest) & 0x3) == 0);
+ Q_ASSERT((quintptr(src) & 0x3) == 0);
const quint32 a = eff_alpha_4(alpha, dest);
const quint32 ia = eff_ialpha_4(alpha, dest);
@@ -4411,7 +4411,7 @@ void QT_FASTCALL blendUntransformed_dest16(DST *dest, const SRC *src,
{
Q_ASSERT(sizeof(DST) == 2);
Q_ASSERT(sizeof(SRC) == 2);
- Q_ASSERT((long(dest) & 0x3) == (long(src) & 0x3));
+ Q_ASSERT((quintptr(dest) & 0x3) == (quintptr(src) & 0x3));
Q_ASSERT(coverage > 0);
const int align = quintptr(dest) & 0x3;
@@ -4479,8 +4479,8 @@ void QT_FASTCALL blendUntransformed_dest16(DST *dest, const SRC *src,
}
while (length >= 2) {
- Q_ASSERT((long(dest) & 3) == 0);
- Q_ASSERT((long(src) & 3) == 0);
+ Q_ASSERT((quintptr(dest) & 3) == 0);
+ Q_ASSERT((quintptr(src) & 3) == 0);
const quint16 a = alpha_2(src);
if (a == 0xffff) {
@@ -4511,7 +4511,7 @@ template <class DST, class SRC>
void QT_FASTCALL blendUntransformed_dest24(DST *dest, const SRC *src,
quint8 coverage, int length)
{
- Q_ASSERT((long(dest) & 0x3) == (long(src) & 0x3));
+ Q_ASSERT((quintptr(dest) & 0x3) == (quintptr(src) & 0x3));
Q_ASSERT(sizeof(DST) == 3);
Q_ASSERT(coverage > 0);
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index db4ace4..1c528fe 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7999,7 +7999,7 @@ start_lengthVariant:
for (int i = 0; i < textLayout.lineCount(); i++) {
QTextLine line = textLayout.lineAt(i);
- qreal advance = textLayout.engine()->lines[i].textAdvance.toReal();
+ qreal advance = line.horizontalAdvance();
if (tf & Qt::AlignRight)
xoff = r.width() - advance;
else if (tf & Qt::AlignHCenter)
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index e2de43a..bd87ca4 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -769,6 +769,8 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkArrowType type = GTK_ARROW_UP;
QRect r = header->rect;
QImage arrow;
+ // This sorting indicator inversion is intentional, and follows the GNOME HIG.
+ // See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable
if (header->sortIndicator & QStyleOptionHeader::SortUp)
type = GTK_ARROW_UP;
else if (header->sortIndicator & QStyleOptionHeader::SortDown)
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index 6138e85..4a279a7 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -63,7 +63,7 @@
#include <AknUtils.h>
#include <aknnavi.h>
#include <gulicon.h>
-#include <AknBitmapAnimation.h>
+#include <aknbitmapanimation.h>
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index 6c48590..60c06ca 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -497,7 +497,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW
{
#ifndef Q_OS_WINCE
NONCLIENTMETRICS ncm;
- ncm.cbSize = sizeof(NONCLIENTMETRICS);
+ ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT);
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
ret = qMax(ncm.iScrollHeight, ncm.iScrollWidth);
else
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index f2d0654..7dc2c26 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1124,14 +1124,13 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
bool kerningEnabled = this->font(si).d->kerning;
HB_ShaperItem entire_shaper_item;
- entire_shaper_item.kerning_applied = false;
+ qMemSet(&entire_shaper_item, 0, sizeof(entire_shaper_item));
entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(layoutData->string.constData());
entire_shaper_item.stringLength = layoutData->string.length();
entire_shaper_item.item.script = (HB_Script)si.analysis.script;
entire_shaper_item.item.pos = si.position;
entire_shaper_item.item.length = length(item);
entire_shaper_item.item.bidiLevel = si.analysis.bidiLevel;
- entire_shaper_item.glyphIndicesPresent = false;
HB_UChar16 upperCased[256]; // XXX what about making this 4096, so we don't have to extend it ever.
if (si.analysis.flags == QScriptAnalysis::SmallCaps || si.analysis.flags == QScriptAnalysis::Uppercase
@@ -2467,7 +2466,7 @@ void QTextEngine::splitItem(int item, int pos) const
if (pos <= 0)
return;
- layoutData->items.insert(item + 1, QScriptItem(layoutData->items[item]));
+ layoutData->items.insert(item + 1, layoutData->items[item]);
QScriptItem &oldItem = layoutData->items[item];
QScriptItem &newItem = layoutData->items[item+1];
newItem.position += pos;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 766053c..2fc5d1a 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1570,6 +1570,20 @@ qreal QTextLine::naturalTextWidth() const
return eng->lines[i].textWidth.toReal();
}
+/*! \since 4.7
+ Returns the horizontal advance of the text. The advance of the text
+ is the distance from its position to the next position at which
+ text would naturally be drawn.
+
+ By adding the advance to the position of the text line and using this
+ as the position of a second text line, you will be able to position
+ the two lines side-by-side without gaps in-between.
+*/
+qreal QTextLine::horizontalAdvance() const
+{
+ return eng->lines[i].textAdvance.toReal();
+}
+
/*!
Lays out the line with the given \a width. The line is filled from
its starting position with as many characters as will fit into
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index edae7de..8c93ed6 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -202,6 +202,7 @@ public:
bool leadingIncluded() const;
qreal naturalTextWidth() const;
+ qreal horizontalAdvance() const;
QRectF naturalTextRect() const;
enum Edge {
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index 387bf87..c095b3b 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -1110,7 +1110,7 @@ void QCompleter::setPopup(QAbstractItemView *popup)
delete d->popup;
if (popup->model() != d->proxy)
popup->setModel(d->proxy);
-#ifdef Q_OS_MAC
+#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
popup->show();
#else
popup->hide();
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index d2eda80..44483ea 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -1374,7 +1374,9 @@ bool QMainWindow::event(QEvent *event)
#endif // QT_NO_STATUSTIP
case QEvent::StyleChange:
+#ifndef QT_NO_DOCKWIDGET
d->layout->layoutState.dockAreaLayout.styleChangedEvent();
+#endif
if (!d->explicitIconSize)
setIconSize(QSize());
break;
diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp
index 597b28b..88b7517 100644
--- a/src/gui/widgets/qsplitter.cpp
+++ b/src/gui/widgets/qsplitter.cpp
@@ -227,6 +227,33 @@ QSize QSplitterHandle::sizeHint() const
/*!
\reimp
*/
+void QSplitterHandle::resizeEvent(QResizeEvent *event)
+{
+ Q_D(const QSplitterHandle);
+
+ // When splitters are only 1 pixel large we increase the
+ // actual grab area to five pixels
+
+ // Note that QSplitter uses contentsRect for layouting
+ // and ensures that handles are drawn on top of widgets
+ // We simply use the contents margins for draggin and only
+ // paint the mask area
+ bool useTinyMode = (d->s->handleWidth() == 1);
+ setAttribute(Qt::WA_MouseNoMask, useTinyMode);
+ if (useTinyMode) {
+ if (orientation() == Qt::Horizontal)
+ setContentsMargins(2, 0, 2, 0);
+ else
+ setContentsMargins(0, 2, 0, 2);
+ setMask(QRegion(contentsRect()));
+ }
+
+ QWidget::resizeEvent(event);
+}
+
+/*!
+ \reimp
+*/
bool QSplitterHandle::event(QEvent *event)
{
Q_D(QSplitterHandle);
@@ -301,7 +328,7 @@ void QSplitterHandle::paintEvent(QPaintEvent *)
Q_D(QSplitterHandle);
QPainter p(this);
QStyleOption opt(0);
- opt.rect = rect();
+ opt.rect = contentsRect();
opt.palette = palette();
if (orientation() == Qt::Horizontal)
opt.state = QStyle::State_Horizontal;
@@ -1662,6 +1689,9 @@ void QSplitter::setSizes(const QList<int> &list)
By default, this property contains a value that depends on the user's platform
and style preferences.
+
+ If you set handleWidth to 1, the actual grab area will grow to overlap a
+ few pixels of it's respective widgets.
*/
int QSplitter::handleWidth() const
diff --git a/src/gui/widgets/qsplitter.h b/src/gui/widgets/qsplitter.h
index a793f24..c3b304d 100644
--- a/src/gui/widgets/qsplitter.h
+++ b/src/gui/widgets/qsplitter.h
@@ -172,6 +172,7 @@ protected:
void mouseMoveEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
+ void resizeEvent(QResizeEvent *);
bool event(QEvent *);
void moveSplitter(int p);
diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp
index 4eb252a..f87510f 100644
--- a/src/gui/widgets/qtoolbarlayout.cpp
+++ b/src/gui/widgets/qtoolbarlayout.cpp
@@ -654,7 +654,11 @@ void QToolBarLayout::setExpanded(bool exp)
if (!tb)
return;
if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) {
+#ifdef QT_NO_DOCKWIDGET
+ animating = false;
+#else
animating = !tb->isWindow() && win->isAnimated();
+#endif
QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
if (expanded) {
tb->raise();
diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp
index dfe125f..077ed9a 100644
--- a/src/imports/multimedia/qdeclarativeaudio.cpp
+++ b/src/imports/multimedia/qdeclarativeaudio.cpp
@@ -142,7 +142,7 @@ void QDeclarativeAudio::stop()
*/
/*!
- \qmlproperty url Audio:autoLoad
+ \qmlproperty url Audio::autoLoad
This property indicates if loading of media should begin immediately.
diff --git a/src/imports/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp
index 6aff9bd..c878fe1 100644
--- a/src/imports/multimedia/qdeclarativevideo.cpp
+++ b/src/imports/multimedia/qdeclarativevideo.cpp
@@ -116,7 +116,7 @@ QDeclarativeVideo::~QDeclarativeVideo()
*/
/*!
- \qmlproperty url Audio:autoLoad
+ \qmlproperty url Video::autoLoad
This property indicates if loading of media should begin immediately.
diff --git a/src/multimedia/video/qabstractvideobuffer.cpp b/src/multimedia/video/qabstractvideobuffer.cpp
index 465a1e7..e9d30d0 100644
--- a/src/multimedia/video/qabstractvideobuffer.cpp
+++ b/src/multimedia/video/qabstractvideobuffer.cpp
@@ -71,6 +71,8 @@ QT_BEGIN_NAMESPACE
\value NoHandle The buffer has no handle, its data can only be accessed by mapping the buffer.
\value GLTextureHandle The handle of the buffer is an OpenGL texture ID.
+ \value XvShmImageHandle The handle contains pointer to shared memory XVideo image.
+ \value CoreImageHandle The handle contains pointer to Mac OS X CIImage.
\value UserHandle Start value for user defined handle types.
\sa handleType()
diff --git a/src/multimedia/video/qabstractvideobuffer.h b/src/multimedia/video/qabstractvideobuffer.h
index 4ffa46f..a8389db 100644
--- a/src/multimedia/video/qabstractvideobuffer.h
+++ b/src/multimedia/video/qabstractvideobuffer.h
@@ -61,6 +61,8 @@ public:
{
NoHandle,
GLTextureHandle,
+ XvShmImageHandle,
+ CoreImageHandle,
UserHandle = 1000
};
diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h
index 1d794a2..c57c9c6 100644
--- a/src/network/access/qnetworkaccessmanager.h
+++ b/src/network/access/qnetworkaccessmanager.h
@@ -148,7 +148,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed())
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionNewConfigurationActivated())
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionPreferredConfigurationChanged(QNetworkConfiguration,bool))
- Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State));
+ Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))
};
QT_END_NAMESPACE
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 7fc0097..edd6889 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -318,11 +318,15 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const
// for HTTP, we want to send out the request as fast as possible to the network, without
// invoking methods in a QueuedConnection
+#ifndef QT_NO_HTTP
if (qobject_cast<QNetworkAccessHttpBackend *>(backend)) {
_q_startOperation();
} else {
QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
}
+#else
+ QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
+#endif // QT_NO_HTTP
}
q->QIODevice::open(QIODevice::ReadOnly);
@@ -872,11 +876,15 @@ bool QNetworkReplyImplPrivate::migrateBackend()
backend->setResumeOffset(bytesDownloaded);
}
+#ifndef QT_NO_HTTP
if (qobject_cast<QNetworkAccessHttpBackend *>(backend)) {
_q_startOperation();
} else {
QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
}
+#else
+ QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
+#endif // QT_NO_HTTP
return true;
}
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 0cd5efb..1ba5dab 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -64,7 +64,7 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
\since 4.7
\inmodule QtNetwork
- \ingroup bearer
+ \ingroup network
QNetworkConfigurationManager provides access to the network configurations known to the system and
enables applications to detect the system capabilities (with regards to network sessions) at runtime.
diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp
index 82669e0..4108fee 100644
--- a/src/network/bearer/qnetworkconfiguration.cpp
+++ b/src/network/bearer/qnetworkconfiguration.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
\since 4.7
\inmodule QtNetwork
- \ingroup bearer
+ \ingroup network
QNetworkConfiguration encapsulates a single access point or service network.
In most cases a single access point configuration can be mapped to one network
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
index cf9f4b2..ca21dcd 100644
--- a/src/network/bearer/qnetworksession.cpp
+++ b/src/network/bearer/qnetworksession.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
\since 4.7
\inmodule QtNetwork
- \ingroup bearer
+ \ingroup network
A QNetworkSession enables control over the system's network interfaces. The session's configuration
parameter are determined via the QNetworkConfiguration object to which it is bound. Depending on the
diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h
index e65c177..1f25088 100644
--- a/src/network/bearer/qnetworksession.h
+++ b/src/network/bearer/qnetworksession.h
@@ -81,7 +81,7 @@ public:
InvalidConfigurationError
};
- QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0);
+ explicit QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0);
virtual ~QNetworkSession();
bool isOpen() const;
diff --git a/src/opengl/qglbuffer.cpp b/src/opengl/qglbuffer.cpp
index 755f34c..223243c 100644
--- a/src/opengl/qglbuffer.cpp
+++ b/src/opengl/qglbuffer.cpp
@@ -388,31 +388,23 @@ void QGLBuffer::release() const
#undef ctx
/*!
- Binds a raw \a bufferId to the specified buffer \a type
- in the current QGLContext. Returns false if there is
- no context current or the GL buffer extension could
- not be resolved.
+ Releases the buffer associated with \a type in the current
+ QGLContext.
- This function is a direct call to \c{glBindBuffer()} for
- use when the caller does not have a QGLBuffer but does
- have a raw \a bufferId. It can also be used to release
- the current buffer when the caller does not know which
- QGLBuffer object is currently bound:
+ This function is a direct call to \c{glBindBuffer(type, 0)}
+ for use when the caller does not know which QGLBuffer has
+ been bound to the context but wants to make sure that it
+ is released.
\code
- QGLBuffer::bind(QGLBuffer::VertexBuffer, 0);
+ QGLBuffer::release(QGLBuffer::VertexBuffer);
\endcode
*/
-bool QGLBuffer::bind(QGLBuffer::Type type, uint bufferId)
+void QGLBuffer::release(QGLBuffer::Type type)
{
const QGLContext *ctx = QGLContext::currentContext();
- if (ctx) {
- if (qt_resolve_buffer_extensions(const_cast<QGLContext *>(ctx))) {
- glBindBuffer(GLenum(type), GLuint(bufferId));
- return true;
- }
- }
- return false;
+ if (ctx && qt_resolve_buffer_extensions(const_cast<QGLContext *>(ctx)))
+ glBindBuffer(GLenum(type), 0);
}
#define ctx d->guard.context()
@@ -423,7 +415,7 @@ bool QGLBuffer::bind(QGLBuffer::Type type, uint bufferId)
\sa isCreated()
*/
-uint QGLBuffer::bufferId() const
+GLuint QGLBuffer::bufferId() const
{
Q_D(const QGLBuffer);
return d->guard.id();
diff --git a/src/opengl/qglbuffer.h b/src/opengl/qglbuffer.h
index a060733..2fe1f1f 100644
--- a/src/opengl/qglbuffer.h
+++ b/src/opengl/qglbuffer.h
@@ -43,6 +43,7 @@
#define QGLBUFFER_H
#include <QtCore/qscopedpointer.h>
+#include <QtOpenGL/qgl.h>
QT_BEGIN_HEADER
@@ -97,9 +98,9 @@ public:
bool bind() const;
void release() const;
- static bool bind(QGLBuffer::Type type, uint bufferId);
+ static void release(QGLBuffer::Type type);
- uint bufferId() const;
+ GLuint bufferId() const;
int size() const;
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h
index 2fe8974..02766c5 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.h
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.h
@@ -95,11 +95,10 @@ private:
SCDynamicStoreRef storeSession;
CFRunLoopSourceRef runloopSource;
-
bool hasWifi;
protected:
- QMap<QString, QMap<QString,QString> > userProfiles;
+ QMap<QString, QMap<QString,QString> > userProfiles;
void startNetworkChangeLoop();
void getUserConfigurations();
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index af57159..9c2cb0c 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -50,11 +50,13 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qdebug.h>
+
#include <QDir>
#include <CoreWLAN/CoreWLAN.h>
#include <CoreWLAN/CWInterface.h>
#include <CoreWLAN/CWNetwork.h>
#include <CoreWLAN/CWNetwork.h>
+#include <CoreWLAN/CW8021XProfile.h>
#include <Foundation/NSEnumerator.h>
#include <Foundation/NSKeyValueObserving.h>
@@ -194,14 +196,14 @@ void QCoreWlanEngine::connectToId(const QString &id)
NSString *wantedSsid = 0;
bool okToProceed = true;
+
if(getNetworkNameFromSsid(id) != id) {
NSArray *array = [CW8021XProfile allUser8021XProfiles];
for (NSUInteger i=0; i<[array count]; ++i) {
const QString idCheck = QString::number(qHash(QLatin1String("corewlan:") + qt_mac_NSStringToQString([[array objectAtIndex:i] userDefinedName])));
const QString idCheck2 = QString::number(qHash(QLatin1String("corewlan:") + qt_mac_NSStringToQString([[array objectAtIndex:i] ssid])));
- if(id == idCheck
- || id == idCheck2) {
+ if (id == idCheck || id == idCheck2) {
QString thisName = getSsidFromNetworkName(id);
if(thisName.isEmpty()) {
wantedSsid = qt_mac_QStringToNSString(id);
@@ -263,6 +265,8 @@ void QCoreWlanEngine::connectToId(const QString &id)
emit connectionError(id, InterfaceLookupError);
locker.relock();
}
+
+ locker.unlock();
emit connectionError(id, OperationNotSupported);
}
@@ -416,7 +420,6 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName)
if (!err) {
for(uint row=0; row < [apArray count]; row++ ) {
-
apNetwork = [apArray objectAtIndex:row];
const QString networkSsid = qt_mac_NSStringToQString([apNetwork ssid]);
@@ -456,7 +459,6 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName)
QString networkSsid = getSsidFromNetworkName(networkName);
const QString ssidId = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
-
QString interfaceName;
QMapIterator<QString, QString> ij(i.value());
while (ij.hasNext()) {
@@ -693,7 +695,6 @@ QString QCoreWlanEngine::getSsidFromNetworkName(const QString &name)
QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
while (i.hasNext()) {
i.next();
-
QMap<QString,QString> map = i.value();
QMapIterator<QString, QString> ij(i.value());
while (ij.hasNext()) {
@@ -702,7 +703,7 @@ QString QCoreWlanEngine::getSsidFromNetworkName(const QString &name)
if(name == i.key() || name == idCheck) {
return ij.key();
}
- }
+ }
}
return QString();
}
@@ -737,7 +738,6 @@ void QCoreWlanEngine::getUserConfigurations()
CWInterface *wifiInterface = [CWInterface interfaceWithName: [wifiInterfaces objectAtIndex:row]];
NSString *nsInterfaceName = [wifiInterface name];
-
// add user configured system networks
SCDynamicStoreRef dynRef = SCDynamicStoreCreate(kCFAllocatorSystemDefault, (CFStringRef)@"Qt corewlan", nil, nil);
NSDictionary * airportPlist = (NSDictionary *)SCDynamicStoreCopyValue(dynRef, (CFStringRef)[NSString stringWithFormat:@"Setup:/Network/Interface/%@/AirPort", nsInterfaceName]);
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index dfc74f2..c1de4e0 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -203,7 +203,7 @@ void QGenericEngine::doRequestUpdate()
if (interface.flags() & QNetworkInterface::IsLoopBack)
continue;
- // ignore WLAN interface handled in seperate engine
+ // ignore WLAN interface handled in separate engine
if (qGetInterfaceType(interface.name()) == QLatin1String("WLAN"))
continue;
diff --git a/src/plugins/bearer/icd/qicdengine.cpp b/src/plugins/bearer/icd/qicdengine.cpp
index f70a209..7a4cb9d 100644
--- a/src/plugins/bearer/icd/qicdengine.cpp
+++ b/src/plugins/bearer/icd/qicdengine.cpp
@@ -335,7 +335,7 @@ void QIcdEngine::doRequestUpdate()
locker.relock();
}
- if (!ap.scan.network_type.startsWith("WLAN"))
+ if (!ap.scan.network_type.startsWith(QLatin1String("WLAN")))
continue; // not a wlan AP
}
} else {
diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp
index a2ae65c..06e0529 100644
--- a/src/plugins/bearer/icd/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp
@@ -391,7 +391,7 @@ quint64 QNetworkSessionPrivateImpl::getStatistics(bool sent) const
return 0;
}
- foreach (Maemo::IcdStatisticsResult res, stats_results) {
+ foreach (const Maemo::IcdStatisticsResult &res, stats_results) {
if (res.params.network_attrs & ICD_NW_ATTR_IAPNAME) {
/* network_id is the IAP UUID */
if (QString(res.params.network_id.data()) == activeConfig.identifier()) {
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
index 048f628..ecca537 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
@@ -215,7 +215,7 @@ public:
Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag);
- QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0);
+ explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0);
~QNetworkManagerInterfaceAccessPoint();
QDBusInterface *connectionInterface() const;
@@ -248,7 +248,7 @@ class QNetworkManagerInterfaceDevice : public QObject
public:
- QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = 0);
+ explicit QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = 0);
~QNetworkManagerInterfaceDevice();
QString udi() const;
@@ -277,7 +277,8 @@ class QNetworkManagerInterfaceDeviceWired : public QObject
public:
- QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent = 0);
+ explicit QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath,
+ QObject *parent = 0);
~QNetworkManagerInterfaceDeviceWired();
QDBusInterface *connectionInterface() const;
@@ -311,7 +312,8 @@ public:
Rsn = 0x20
};
- QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent = 0);
+ explicit QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath,
+ QObject *parent = 0);
~QNetworkManagerInterfaceDeviceWireless();
QDBusObjectPath path() const;
@@ -342,7 +344,7 @@ class QNetworkManagerSettings : public QObject
public:
- QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0);
+ explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0);
~QNetworkManagerSettings();
QDBusInterface *connectionInterface() const;
@@ -402,7 +404,7 @@ public:
Activated = 2
};
- QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0);
+ explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0);
~ QNetworkManagerConnectionActive();
QDBusInterface *connectionInterface() const;
@@ -430,7 +432,7 @@ class QNetworkManagerIp4Config : public QObject
Q_OBJECT
public:
- QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = 0);
+ explicit QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = 0);
~QNetworkManagerIp4Config();
QStringList domains() const;
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
index 0737942..8910efe 100644
--- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
@@ -241,15 +241,24 @@ void QNetworkSessionPrivateImpl::open()
// => RConnection::ProgressNotification will be used for IAP/SNAP monitoring
iConnectionMonitor.CancelNotifications();
- // Configuration must be at least in Discovered - state for connecting purposes.
- if ((publicConfig.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
+ // Configuration may have been invalidated after session creation by platform
+ // (e.g. configuration has been deleted).
+ if (!publicConfig.isValid()) {
newState(QNetworkSession::Invalid);
iError = QNetworkSession::InvalidConfigurationError;
emit QNetworkSessionPrivate::error(iError);
syncStateWithInterface();
return;
}
+ // If opening a (un)defined configuration, session emits error and enters
+ // NotAvailable -state.
+ if (publicConfig.state() == QNetworkConfiguration::Undefined ||
+ publicConfig.state() == QNetworkConfiguration::Defined) {
+ newState(QNetworkSession::NotAvailable);
+ iError = QNetworkSession::InvalidConfigurationError;
+ emit QNetworkSessionPrivate::error(iError);
+ return;
+ }
TInt error = iSocketServ.Connect();
if (error != KErrNone) {
@@ -450,15 +459,49 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals)
void QNetworkSessionPrivateImpl::stop()
{
- if (!isOpen) {
- return;
+ if (!isOpen &&
+ publicConfig.isValid() &&
+ publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) {
+ // If the publicConfig is type of IAP, enumerate through connections at
+ // connection monitor. If publicConfig is active in that list, stop it.
+ // Otherwise there is nothing to stop. Note: because this QNetworkSession is not open,
+ // activeConfig is not usable.
+ TUint count;
+ TRequestStatus status;
+ iConnectionMonitor.GetConnectionCount(count, status);
+ User::WaitForRequest(status);
+ if (status.Int() != KErrNone) {
+ return;
+ }
+ TUint numSubConnections; // Not used but needed by GetConnectionInfo i/f
+ TUint connectionId;
+ for (TInt i = 1; i <= count; ++i) {
+ // Get (connection monitor's assigned) connection ID
+ TInt ret = iConnectionMonitor.GetConnectionInfo(i, connectionId, numSubConnections);
+ if (ret == KErrNone) {
+ SymbianNetworkConfigurationPrivate *symbianConfig =
+ toSymbianConfig(privateConfiguration(publicConfig));
+
+ QMutexLocker configLocker(&symbianConfig->mutex);
+
+ // See if connection Id matches with our Id. If so, stop() it.
+ if (symbianConfig->connectionId == connectionId) {
+ ret = iConnectionMonitor.SetBoolAttribute(connectionId,
+ 0, // subConnectionId don't care
+ KConnectionStop,
+ ETrue);
+ }
+ }
+ }
+ } else if (isOpen) {
+ // Since we are open, use RConnection to stop the interface
+ isOpen = false;
+ newState(QNetworkSession::Closing);
+ iConnection.Stop(RConnection::EStopAuthoritative);
+ isOpen = true;
+ close(false);
+ emit closed();
}
- isOpen = false;
- newState(QNetworkSession::Closing);
- iConnection.Stop(RConnection::EStopAuthoritative);
- isOpen = true;
- close(false);
- emit closed();
}
void QNetworkSessionPrivateImpl::migrate()
@@ -794,7 +837,7 @@ void QNetworkSessionPrivateImpl::RunL()
TInt statusCode = iStatus.Int();
switch (statusCode) {
- case KErrNone: // Connection created succesfully
+ case KErrNone: // Connection created successfully
{
TInt error = KErrNone;
QNetworkConfiguration newActiveConfig = activeConfiguration();
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h
index 98d4222..35e2c58 100644
--- a/src/plugins/bearer/symbian/qnetworksession_impl.h
+++ b/src/plugins/bearer/symbian/qnetworksession_impl.h
@@ -72,12 +72,11 @@ QT_BEGIN_NAMESPACE
class ConnectionProgressNotifier;
class SymbianEngine;
+class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive,
#ifdef SNAP_FUNCTIONALITY_AVAILABLE
-class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive, public MMobilityProtocolResp,
- public MConnectionMonitorObserver
-#else
-class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive, public MConnectionMonitorObserver
+ public MMobilityProtocolResp,
#endif
+ public MConnectionMonitorObserver
{
Q_OBJECT
public:
diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp
index 4d65b80..440f463 100644
--- a/src/plugins/bearer/symbian/symbianengine.cpp
+++ b/src/plugins/bearer/symbian/symbianengine.cpp
@@ -45,6 +45,16 @@
#include <commdb.h>
#include <cdbcols.h>
#include <d32dbms.h>
+#include <QEventLoop>
+#include <QTimer>
+#include <QTime> // For randgen seeding
+#include <QtCore> // For randgen seeding
+
+// #define QT_BEARERMGMT_CONFIGMGR_DEBUG
+
+#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG
+#include <QDebug>
+#endif
#ifdef SNAP_FUNCTIONALITY_AVAILABLE
#include <cmdestination.h>
@@ -100,10 +110,15 @@ QString SymbianNetworkConfigurationPrivate::bearerName() const
}
SymbianEngine::SymbianEngine(QObject *parent)
-: QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true)
+: QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true),
+ iIgnoringUpdates(false), iTimeToWait(0), iIgnoreEventLoop(0)
{
CActiveScheduler::Add(this);
+ // Seed the randomgenerator
+ qsrand(QTime(0,0,0).secsTo(QTime::currentTime()) + QCoreApplication::applicationPid());
+ iIgnoreEventLoop = new QEventLoop(this);
+
TRAPD(error, ipCommsDB = CCommsDatabase::NewL(EDatabaseTypeIAP));
if (error != KErrNone) {
iInitOk = false;
@@ -138,9 +153,7 @@ SymbianEngine::SymbianEngine(QObject *parent)
updateConfigurations();
updateStatesToSnaps();
-
updateAvailableAccessPoints(); // On first time updates synchronously (without WLAN scans)
-
// Start monitoring IAP and/or SNAP changes in Symbian CommsDB
startCommsDatabaseNotifications();
iFirstUpdate = false;
@@ -231,7 +244,7 @@ void SymbianEngine::updateConfigurationsL()
QList<QString> knownConfigs = accessPointConfigurations.keys();
QList<QString> knownSnapConfigs = snapConfigurations.keys();
-
+
#ifdef SNAP_FUNCTIONALITY_AVAILABLE
// S60 version is >= Series60 3rd Edition Feature Pack 2
TInt error = KErrNone;
@@ -738,8 +751,7 @@ void SymbianEngine::updateStatesToSnaps()
QMutexLocker locker(&mutex);
// Go through SNAPs and set correct state to SNAPs
- QList<QString> snapConfigIdents = snapConfigurations.keys();
- foreach (QString iface, snapConfigIdents) {
+ foreach (const QString &iface, snapConfigurations.keys()) {
bool discovered = false;
bool active = false;
QNetworkConfigurationPrivatePointer ptr = snapConfigurations.value(iface);
@@ -874,6 +886,13 @@ void SymbianEngine::RunL()
{
QMutexLocker locker(&mutex);
+ if (iIgnoringUpdates) {
+#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG
+ qDebug("CommsDB event handling postponed (postpone-timer running because IAPs/SNAPs were updated very recently).");
+#endif
+ return;
+ }
+
if (iStatus != KErrCancel) {
RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int());
switch (event) {
@@ -881,16 +900,32 @@ void SymbianEngine::RunL()
case RDbNotifier::ECommit: /** A transaction has been committed. */
case RDbNotifier::ERollback: /** A transaction has been rolled back */
case RDbNotifier::ERecover: /** The database has been recovered */
- // Note that if further database events occur while a client is handling
- // a request completion, the notifier records the most significant database
- // event and this is signalled as soon as the client issues the next
- // RequestNotification() request.
- // => Stop recording notifications
- stopCommsDatabaseNotifications();
- TRAPD(error, updateConfigurationsL());
- if (error == KErrNone) {
- updateStatesToSnaps();
+#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG
+ qDebug("CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int());
+#endif
+ iIgnoringUpdates = true;
+ // Other events than ECommit get lower priority. In practice with those events,
+ // we delay_before_updating methods, whereas
+ // with ECommit we _update_before_delaying the reaction to next event.
+ // Few important notes: 1) listening to only ECommit does not seem to be adequate,
+ // but updates will be missed. Hence other events are reacted upon too.
+ // 2) RDbNotifier records the most significant event, and that will be returned once
+ // we issue new RequestNotification, and hence updates will not be missed even
+ // when we are 'not reacting to them' for few seconds.
+ if (event == RDbNotifier::ECommit) {
+ TRAPD(error, updateConfigurationsL());
+ if (error == KErrNone) {
+ updateStatesToSnaps();
+ }
+ waitRandomTime();
+ } else {
+ waitRandomTime();
+ TRAPD(error, updateConfigurationsL());
+ if (error == KErrNone) {
+ updateStatesToSnaps();
+ }
}
+ iIgnoringUpdates = false; // Wait time done, allow updating again
iWaitingCommsDatabaseNotifications = true;
break;
default:
@@ -1015,6 +1050,20 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
}
}
+// Waits for 1..4 seconds.
+void SymbianEngine::waitRandomTime()
+{
+ iTimeToWait = (qAbs(qrand()) % 5) * 1000;
+ if (iTimeToWait < 1000) {
+ iTimeToWait = 1000;
+ }
+#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG
+ qDebug("QNetworkConfigurationManager waiting random time: %d ms", iTimeToWait);
+#endif
+ QTimer::singleShot(iTimeToWait, iIgnoreEventLoop, SLOT(quit()));
+ iIgnoreEventLoop->exec();
+}
+
QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aConnectionId)
{
QMutexLocker locker(&mutex);
diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h
index e6af908..2e7ae60 100644
--- a/src/plugins/bearer/symbian/symbianengine.h
+++ b/src/plugins/bearer/symbian/symbianengine.h
@@ -53,6 +53,7 @@
#endif
class CCommsDatabase;
+class QEventLoop;
QT_BEGIN_NAMESPACE
class QTimer;
@@ -148,6 +149,7 @@ private:
void accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo);
void startCommsDatabaseNotifications();
void stopCommsDatabaseNotifications();
+ void waitRandomTime();
QNetworkConfigurationPrivatePointer defaultConfigurationL();
TBool GetS60PlatformVersion(TUint& aMajor, TUint& aMinor) const;
@@ -170,8 +172,10 @@ private: // Data
TBool iOnline;
TBool iInitOk;
TBool iUpdateGoingOn;
+ TBool iIgnoringUpdates;
+ TUint iTimeToWait;
+ QEventLoop* iIgnoreEventLoop;
-
AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner;
friend class QNetworkSessionPrivate;
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
index abe3ffe..93b7cc6 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
@@ -183,82 +183,34 @@ inline my_jpeg_source_mgr::my_jpeg_source_mgr(QIODevice *device)
}
-static bool read_jpeg_size(QIODevice *device, int &w, int &h)
+inline static bool read_jpeg_size(int &w, int &h, j_decompress_ptr cinfo)
{
- bool rt = false;
- struct jpeg_decompress_struct cinfo;
+ (void) jpeg_calc_output_dimensions(cinfo);
- struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(device);
- struct my_error_mgr jerr;
-
- jpeg_create_decompress(&cinfo);
-
- cinfo.src = iod_src;
-
- cinfo.err = jpeg_std_error(&jerr);
- jerr.error_exit = my_error_exit;
-
- if (!setjmp(jerr.setjmp_buffer)) {
-#if defined(Q_OS_UNIXWARE)
- (void) jpeg_read_header(&cinfo, B_TRUE);
-#else
- (void) jpeg_read_header(&cinfo, true);
-#endif
- (void) jpeg_calc_output_dimensions(&cinfo);
-
- w = cinfo.output_width;
- h = cinfo.output_height;
- rt = true;
- }
- jpeg_destroy_decompress(&cinfo);
- delete iod_src;
- return rt;
+ w = cinfo->output_width;
+ h = cinfo->output_height;
+ return true;
}
#define HIGH_QUALITY_THRESHOLD 50
-static bool read_jpeg_format(QIODevice *device, QImage::Format &format)
+inline static bool read_jpeg_format(QImage::Format &format, j_decompress_ptr cinfo)
{
- bool result = false;
- struct jpeg_decompress_struct cinfo;
-
- struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(device);
- struct my_error_mgr jerr;
-
- jpeg_create_decompress(&cinfo);
-
- cinfo.src = iod_src;
-
- cinfo.err = jpeg_std_error(&jerr);
- jerr.error_exit = my_error_exit;
- if (!setjmp(jerr.setjmp_buffer)) {
-#if defined(Q_OS_UNIXWARE)
- (void) jpeg_read_header(&cinfo, B_TRUE);
-#else
- (void) jpeg_read_header(&cinfo, true);
-#endif
- // This does not allocate memory for the whole image
- // or such, so we are safe.
- (void) jpeg_start_decompress(&cinfo);
- result = true;
- switch (cinfo.output_components) {
- case 1:
- format = QImage::Format_Indexed8;
- break;
- case 3:
- case 4:
- format = QImage::Format_RGB32;
- break;
- default:
- result = false;
- break;
- }
- cinfo.output_scanline = cinfo.output_height;
- (void) jpeg_finish_decompress(&cinfo);
+ bool result = true;
+ switch (cinfo->output_components) {
+ case 1:
+ format = QImage::Format_Indexed8;
+ break;
+ case 3:
+ case 4:
+ format = QImage::Format_RGB32;
+ break;
+ default:
+ result = false;
+ break;
}
- jpeg_destroy_decompress(&cinfo);
- delete iod_src;
+ cinfo->output_scanline = cinfo->output_height;
return result;
}
@@ -291,29 +243,11 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info,
return !dest->isNull();
}
-static bool read_jpeg_image(QIODevice *device, QImage *outImage,
+static bool read_jpeg_image(QImage *outImage,
QSize scaledSize, QRect scaledClipRect,
- QRect clipRect, int inQuality )
+ QRect clipRect, int inQuality, j_decompress_ptr info, struct my_error_mgr* err )
{
- struct jpeg_decompress_struct cinfo;
-
- struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(device);
- struct my_error_mgr jerr;
-
- jpeg_create_decompress(&cinfo);
-
- cinfo.src = iod_src;
-
- cinfo.err = jpeg_std_error(&jerr);
- jerr.error_exit = my_error_exit;
-
- if (!setjmp(jerr.setjmp_buffer)) {
-#if defined(Q_OS_UNIXWARE)
- (void) jpeg_read_header(&cinfo, B_TRUE);
-#else
- (void) jpeg_read_header(&cinfo, true);
-#endif
-
+ if (!setjmp(err->setjmp_buffer)) {
// -1 means default quality.
int quality = inQuality;
if (quality < 0)
@@ -335,16 +269,16 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
} else if (clipRect.isEmpty()) {
// No clipping, but scaling: if we can map back to an
// integer pixel boundary, then clip before scaling.
- if ((cinfo.image_width % scaledSize.width()) == 0 &&
- (cinfo.image_height % scaledSize.height()) == 0) {
- int x = scaledClipRect.x() * cinfo.image_width /
+ if ((info->image_width % scaledSize.width()) == 0 &&
+ (info->image_height % scaledSize.height()) == 0) {
+ int x = scaledClipRect.x() * info->image_width /
scaledSize.width();
- int y = scaledClipRect.y() * cinfo.image_height /
+ int y = scaledClipRect.y() * info->image_height /
scaledSize.height();
int width = (scaledClipRect.right() + 1) *
- cinfo.image_width / scaledSize.width() - x;
+ info->image_width / scaledSize.width() - x;
int height = (scaledClipRect.bottom() + 1) *
- cinfo.image_height / scaledSize.height() - y;
+ info->image_height / scaledSize.height() - y;
clipRect = QRect(x, y, width, height);
scaledSize = scaledClipRect.size();
scaledClipRect = QRect();
@@ -358,69 +292,69 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
// Determine the scale factor to pass to libjpeg for quick downscaling.
if (!scaledSize.isEmpty()) {
if (clipRect.isEmpty()) {
- cinfo.scale_denom =
- qMin(cinfo.image_width / scaledSize.width(),
- cinfo.image_height / scaledSize.height());
+ info->scale_denom =
+ qMin(info->image_width / scaledSize.width(),
+ info->image_height / scaledSize.height());
} else {
- cinfo.scale_denom =
+ info->scale_denom =
qMin(clipRect.width() / scaledSize.width(),
clipRect.height() / scaledSize.height());
}
- if (cinfo.scale_denom < 2) {
- cinfo.scale_denom = 1;
- } else if (cinfo.scale_denom < 4) {
- cinfo.scale_denom = 2;
- } else if (cinfo.scale_denom < 8) {
- cinfo.scale_denom = 4;
+ if (info->scale_denom < 2) {
+ info->scale_denom = 1;
+ } else if (info->scale_denom < 4) {
+ info->scale_denom = 2;
+ } else if (info->scale_denom < 8) {
+ info->scale_denom = 4;
} else {
- cinfo.scale_denom = 8;
+ info->scale_denom = 8;
}
- cinfo.scale_num = 1;
+ info->scale_num = 1;
if (!clipRect.isEmpty()) {
// Correct the scale factor so that we clip accurately.
// It is recommended that the clip rectangle be aligned
// on an 8-pixel boundary for best performance.
- while (cinfo.scale_denom > 1 &&
- ((clipRect.x() % cinfo.scale_denom) != 0 ||
- (clipRect.y() % cinfo.scale_denom) != 0 ||
- (clipRect.width() % cinfo.scale_denom) != 0 ||
- (clipRect.height() % cinfo.scale_denom) != 0)) {
- cinfo.scale_denom /= 2;
+ while (info->scale_denom > 1 &&
+ ((clipRect.x() % info->scale_denom) != 0 ||
+ (clipRect.y() % info->scale_denom) != 0 ||
+ (clipRect.width() % info->scale_denom) != 0 ||
+ (clipRect.height() % info->scale_denom) != 0)) {
+ info->scale_denom /= 2;
}
}
}
// If high quality not required, use fast decompression
if( quality < HIGH_QUALITY_THRESHOLD ) {
- cinfo.dct_method = JDCT_IFAST;
- cinfo.do_fancy_upsampling = FALSE;
+ info->dct_method = JDCT_IFAST;
+ info->do_fancy_upsampling = FALSE;
}
- (void) jpeg_calc_output_dimensions(&cinfo);
+ (void) jpeg_calc_output_dimensions(info);
// Determine the clip region to extract.
- QRect imageRect(0, 0, cinfo.output_width, cinfo.output_height);
+ QRect imageRect(0, 0, info->output_width, info->output_height);
QRect clip;
if (clipRect.isEmpty()) {
clip = imageRect;
- } else if (cinfo.scale_denom == cinfo.scale_num) {
+ } else if (info->scale_denom == info->scale_num) {
clip = clipRect.intersected(imageRect);
} else {
// The scale factor was corrected above to ensure that
// we don't miss pixels when we scale the clip rectangle.
- clip = QRect(clipRect.x() / int(cinfo.scale_denom),
- clipRect.y() / int(cinfo.scale_denom),
- clipRect.width() / int(cinfo.scale_denom),
- clipRect.height() / int(cinfo.scale_denom));
+ clip = QRect(clipRect.x() / int(info->scale_denom),
+ clipRect.y() / int(info->scale_denom),
+ clipRect.width() / int(info->scale_denom),
+ clipRect.height() / int(info->scale_denom));
clip = clip.intersected(imageRect);
}
// Allocate memory for the clipped QImage.
- if (!ensureValidImage(outImage, &cinfo, clip.size()))
- longjmp(jerr.setjmp_buffer, 1);
+ if (!ensureValidImage(outImage, info, clip.size()))
+ longjmp(err->setjmp_buffer, 1);
// Avoid memcpy() overhead if grayscale with no clipping.
- bool quickGray = (cinfo.output_components == 1 &&
+ bool quickGray = (info->output_components == 1 &&
clip == imageRect);
if (!quickGray) {
// Ask the jpeg library to allocate a temporary row.
@@ -429,23 +363,23 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
// jpeg_start_decompress(). We can't use "new" here
// because we are inside the setjmp() block and an error
// in the jpeg input stream would cause a memory leak.
- JSAMPARRAY rows = (cinfo.mem->alloc_sarray)
- ((j_common_ptr)&cinfo, JPOOL_IMAGE,
- cinfo.output_width * cinfo.output_components, 1);
+ JSAMPARRAY rows = (info->mem->alloc_sarray)
+ ((j_common_ptr)info, JPOOL_IMAGE,
+ info->output_width * info->output_components, 1);
- (void) jpeg_start_decompress(&cinfo);
+ (void) jpeg_start_decompress(info);
- while (cinfo.output_scanline < cinfo.output_height) {
- int y = int(cinfo.output_scanline) - clip.y();
+ while (info->output_scanline < info->output_height) {
+ int y = int(info->output_scanline) - clip.y();
if (y >= clip.height())
break; // We've read the entire clip region, so abort.
- (void) jpeg_read_scanlines(&cinfo, rows, 1);
+ (void) jpeg_read_scanlines(info, rows, 1);
if (y < 0)
continue; // Haven't reached the starting line yet.
- if (cinfo.output_components == 3) {
+ if (info->output_components == 3) {
// Expand 24->32 bpp.
uchar *in = rows[0] + clip.x() * 3;
QRgb *out = (QRgb*)outImage->scanLine(y);
@@ -453,7 +387,7 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
*out++ = qRgb(in[0], in[1], in[2]);
in += 3;
}
- } else if (cinfo.out_color_space == JCS_CMYK) {
+ } else if (info->out_color_space == JCS_CMYK) {
// Convert CMYK->RGB.
uchar *in = rows[0] + clip.x() * 4;
QRgb *out = (QRgb*)outImage->scanLine(y);
@@ -463,7 +397,7 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
k * in[2] / 255);
in += 4;
}
- } else if (cinfo.output_components == 1) {
+ } else if (info->output_components == 1) {
// Grayscale.
memcpy(outImage->scanLine(y),
rows[0] + clip.x(), clip.width());
@@ -471,37 +405,36 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
}
} else {
// Load unclipped grayscale data directly into the QImage.
- (void) jpeg_start_decompress(&cinfo);
- while (cinfo.output_scanline < cinfo.output_height) {
- uchar *row = outImage->scanLine(cinfo.output_scanline);
- (void) jpeg_read_scanlines(&cinfo, &row, 1);
+ (void) jpeg_start_decompress(info);
+ while (info->output_scanline < info->output_height) {
+ uchar *row = outImage->scanLine(info->output_scanline);
+ (void) jpeg_read_scanlines(info, &row, 1);
}
}
- if (cinfo.output_scanline == cinfo.output_height)
- (void) jpeg_finish_decompress(&cinfo);
+ if (info->output_scanline == info->output_height)
+ (void) jpeg_finish_decompress(info);
- if (cinfo.density_unit == 1) {
- outImage->setDotsPerMeterX(int(100. * cinfo.X_density / 2.54));
- outImage->setDotsPerMeterY(int(100. * cinfo.Y_density / 2.54));
- } else if (cinfo.density_unit == 2) {
- outImage->setDotsPerMeterX(int(100. * cinfo.X_density));
- outImage->setDotsPerMeterY(int(100. * cinfo.Y_density));
+ if (info->density_unit == 1) {
+ outImage->setDotsPerMeterX(int(100. * info->X_density / 2.54));
+ outImage->setDotsPerMeterY(int(100. * info->Y_density / 2.54));
+ } else if (info->density_unit == 2) {
+ outImage->setDotsPerMeterX(int(100. * info->X_density));
+ outImage->setDotsPerMeterY(int(100. * info->Y_density));
}
if (scaledSize.isValid() && scaledSize != clip.size()) {
*outImage = outImage->scaled(scaledSize, Qt::IgnoreAspectRatio, quality >= HIGH_QUALITY_THRESHOLD ? Qt::SmoothTransformation : Qt::FastTransformation);
}
- }
- jpeg_destroy_decompress(&cinfo);
- delete iod_src;
- if (!scaledClipRect.isEmpty())
- *outImage = outImage->copy(scaledClipRect);
- return !outImage->isNull();
+ if (!scaledClipRect.isEmpty())
+ *outImage = outImage->copy(scaledClipRect);
+ return !outImage->isNull();
+ }
+ else
+ return false;
}
-
struct my_jpeg_destination_mgr : public jpeg_destination_mgr {
// Nothing dynamic - cannot rely on destruction over longjump
QIODevice *device;
@@ -745,18 +678,124 @@ static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int s
return success;
}
+class QJpegHandlerPrivate
+{
+public:
+ enum State {
+ Ready,
+ ReadHeader,
+ Error
+ };
+
+ QJpegHandlerPrivate(QJpegHandler *qq)
+ : quality(75), iod_src(0), state(Ready), q(qq)
+ {}
+
+ ~QJpegHandlerPrivate()
+ {
+ if(iod_src)
+ {
+ jpeg_destroy_decompress(&info);
+ delete iod_src;
+ iod_src = 0;
+ }
+ }
+
+ bool readJpegHeader(QIODevice*);
+ bool read(QImage *image);
+
+ int quality;
+ QVariant size;
+ QImage::Format format;
+ QSize scaledSize;
+ QRect scaledClipRect;
+ QRect clipRect;
+ struct jpeg_decompress_struct info;
+ struct my_jpeg_source_mgr * iod_src;
+ struct my_error_mgr err;
+
+ State state;
+
+ QJpegHandler *q;
+};
+
+/*!
+ \internal
+*/
+bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device)
+{
+ if(state == Ready)
+ {
+ state = Error;
+ iod_src = new my_jpeg_source_mgr(device);
+
+ jpeg_create_decompress(&info);
+ info.src = iod_src;
+ info.err = jpeg_std_error(&err);
+ err.error_exit = my_error_exit;
+
+ if (!setjmp(err.setjmp_buffer)) {
+ #if defined(Q_OS_UNIXWARE)
+ (void) jpeg_read_header(&info, B_TRUE);
+ #else
+ (void) jpeg_read_header(&info, true);
+ #endif
+
+ int width = 0;
+ int height = 0;
+ read_jpeg_size(width, height, &info);
+ size = QSize(width, height);
+
+ format = QImage::Format_Invalid;
+ read_jpeg_format(format, &info);
+ state = ReadHeader;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if(state == Error)
+ return false;
+ return true;
+}
+
+bool QJpegHandlerPrivate::read(QImage *image)
+{
+ if(state == Ready)
+ readJpegHeader(q->device());
+
+ if(state == ReadHeader)
+ {
+ bool success = read_jpeg_image(image, scaledSize, scaledClipRect, clipRect, quality, &info, &err);
+ state = success ? Ready : Error;
+ return success;
+ }
+
+ return false;
+
+}
+
QJpegHandler::QJpegHandler()
+ : d(new QJpegHandlerPrivate(this))
+{
+}
+
+QJpegHandler::~QJpegHandler()
{
- quality = 75;
+ delete d;
}
bool QJpegHandler::canRead() const
{
- if (canRead(device())) {
+ if(d->state == QJpegHandlerPrivate::Ready) {
+ if (!canRead(device()))
+ return false;
setFormat("jpeg");
return true;
}
- return false;
+ return d->state != QJpegHandlerPrivate::Error;
}
bool QJpegHandler::canRead(QIODevice *device)
@@ -769,7 +808,6 @@ bool QJpegHandler::canRead(QIODevice *device)
char buffer[2];
if (device->peek(buffer, 2) != 2)
return false;
-
return uchar(buffer[0]) == 0xff && uchar(buffer[1]) == 0xd8;
}
@@ -777,12 +815,12 @@ bool QJpegHandler::read(QImage *image)
{
if (!canRead())
return false;
- return read_jpeg_image(device(), image, scaledSize, scaledClipRect, clipRect, quality);
+ return d->read(image);
}
bool QJpegHandler::write(const QImage &image)
{
- return write_jpeg_image(image, device(), quality);
+ return write_jpeg_image(image, device(), d->quality);
}
bool QJpegHandler::supportsOption(ImageOption option) const
@@ -799,32 +837,19 @@ QVariant QJpegHandler::option(ImageOption option) const
{
switch(option) {
case Quality:
- return quality;
+ return d->quality;
case ScaledSize:
- return scaledSize;
+ return d->scaledSize;
case ScaledClipRect:
- return scaledClipRect;
+ return d->scaledClipRect;
case ClipRect:
- return clipRect;
+ return d->clipRect;
case Size:
- if (canRead() && !device()->isSequential()) {
- qint64 pos = device()->pos();
- int width = 0;
- int height = 0;
- read_jpeg_size(device(), width, height);
- device()->seek(pos);
- return QSize(width, height);
- }
- return QVariant();
+ d->readJpegHeader(device());
+ return d->size;
case ImageFormat:
- if (canRead() && !device()->isSequential()) {
- qint64 pos = device()->pos();
- QImage::Format format = QImage::Format_Invalid;
- read_jpeg_format(device(), format);
- device()->seek(pos);
- return format;
- }
- return QImage::Format_Invalid;
+ d->readJpegHeader(device());
+ return d->format;
default:
return QVariant();
}
@@ -834,16 +859,16 @@ void QJpegHandler::setOption(ImageOption option, const QVariant &value)
{
switch(option) {
case Quality:
- quality = value.toInt();
+ d->quality = value.toInt();
break;
case ScaledSize:
- scaledSize = value.toSize();
+ d->scaledSize = value.toSize();
break;
case ScaledClipRect:
- scaledClipRect = value.toRect();
+ d->scaledClipRect = value.toRect();
break;
case ClipRect:
- clipRect = value.toRect();
+ d->clipRect = value.toRect();
break;
default:
break;
@@ -855,4 +880,7 @@ QByteArray QJpegHandler::name() const
return "jpeg";
}
+
+
+
QT_END_NAMESPACE
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.h b/src/plugins/imageformats/jpeg/qjpeghandler.h
index dfb6b47..c879f21 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.h
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.h
@@ -48,10 +48,12 @@
QT_BEGIN_NAMESPACE
+class QJpegHandlerPrivate;
class QJpegHandler : public QImageIOHandler
{
public:
QJpegHandler();
+ ~QJpegHandler();
bool canRead() const;
bool read(QImage *image);
@@ -66,10 +68,7 @@ public:
bool supportsOption(ImageOption option) const;
private:
- int quality;
- QSize scaledSize;
- QRect scaledClipRect;
- QRect clipRect;
+ QJpegHandlerPrivate *d;
};
QT_END_NAMESPACE
diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h
index 31a0314..49049ad 100644
--- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h
+++ b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h
@@ -100,6 +100,7 @@ private:
void *m_movie;
void *m_movieView;
+ bool m_layouted;
WId m_winId;
QRect m_displayRect;
diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm
index d8dbf9b..8e4dd9b 100644
--- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm
+++ b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm
@@ -154,6 +154,7 @@ QT7MovieViewOutput::QT7MovieViewOutput(QObject *parent)
:QT7VideoWindowControl(parent),
m_movie(0),
m_movieView(0),
+ m_layouted(false),
m_winId(0),
m_fullscreen(false),
m_aspectRatioMode(Qt::KeepAspectRatio),
@@ -166,6 +167,8 @@ QT7MovieViewOutput::QT7MovieViewOutput(QObject *parent)
QT7MovieViewOutput::~QT7MovieViewOutput()
{
+ [(QTMovieView*)m_movieView release];
+ [(QTMovie*)m_movie release];
}
void QT7MovieViewOutput::setupVideoOutput()
@@ -186,6 +189,7 @@ void QT7MovieViewOutput::setupVideoOutput()
[(QTMovieView*)m_movieView setMovie:(QTMovie*)m_movie];
[(NSView *)m_winId addSubview:(QTMovieView*)m_movieView];
+ m_layouted = true;
setDisplayRect(m_displayRect);
}
@@ -196,8 +200,21 @@ void QT7MovieViewOutput::setEnabled(bool)
void QT7MovieViewOutput::setMovie(void *movie)
{
- m_movie = movie;
- setupVideoOutput();
+ if (m_movie != movie) {
+ if (m_movie) {
+ if (m_movieView)
+ [(QTMovieView*)m_movieView setMovie:nil];
+
+ [(QTMovie*)m_movie release];
+ }
+
+ m_movie = movie;
+
+ if (m_movie)
+ [(QTMovie*)m_movie retain];
+
+ setupVideoOutput();
+ }
}
void QT7MovieViewOutput::updateNaturalSize(const QSize &newSize)
@@ -215,8 +232,15 @@ WId QT7MovieViewOutput::winId() const
void QT7MovieViewOutput::setWinId(WId id)
{
- m_winId = id;
- setupVideoOutput();
+ if (m_winId != id) {
+ if (m_movieView && m_layouted) {
+ [(QTMovieView*)m_movieView removeFromSuperview];
+ m_layouted = false;
+ }
+
+ m_winId = id;
+ setupVideoOutput();
+ }
}
QRect QT7MovieViewOutput::displayRect() const
diff --git a/src/qt3support/network/q3socketdevice_win.cpp b/src/qt3support/network/q3socketdevice_win.cpp
index 528b50a..1354cfa 100644
--- a/src/qt3support/network/q3socketdevice_win.cpp
+++ b/src/qt3support/network/q3socketdevice_win.cpp
@@ -47,7 +47,6 @@
#include <string.h>
-# include <qt_windows.h>
#if defined (QT_NO_IPV6)
# include <winsock.h>
#else
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 356b4d0..2650d7f 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -292,6 +292,7 @@ QT_BEGIN_NAMESPACE
\value ExcludeSuperClassProperties The script object will not expose properties inherited from the superclass.
\value ExcludeSuperClassContents Shorthand form for ExcludeSuperClassMethods | ExcludeSuperClassProperties
\value ExcludeDeleteLater The script object will not expose the QObject::deleteLater() slot.
+ \value ExcludeSlots The script object will not expose the QObject's slots.
\value AutoCreateDynamicProperties Properties that don't already exist in the QObject will be created as dynamic properties of that object, rather than as properties of the script object.
\value PreferExistingWrapperObject If a wrapper object with the requested configuration already exists, return that object.
\value SkipMethodsInEnumeration Don't include methods (signals and slots) when enumerating the object's properties.
diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h
index 2ce3183..76461bc 100644
--- a/src/script/api/qscriptengine.h
+++ b/src/script/api/qscriptengine.h
@@ -125,6 +125,7 @@ public:
ExcludeSuperClassContents = 0x0006,
SkipMethodsInEnumeration = 0x0008,
ExcludeDeleteLater = 0x0010,
+ ExcludeSlots = 0x0020,
AutoCreateDynamicProperties = 0x0100,
PreferExistingWrapperObject = 0x0200
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index 5db1165..3fe0e7d 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -1505,8 +1505,9 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
const QScriptValueList &args)
{
Q_D(const QScriptValue);
- if (!d || !d->isJSC())
+ if (!d || !d->isObject())
return QScriptValue();
+ QScript::APIShim shim(d->engine);
JSC::JSValue callee = d->jscValue;
JSC::CallData callData;
JSC::CallType callType = callee.getCallData(callData);
@@ -1582,8 +1583,9 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
const QScriptValue &arguments)
{
Q_D(QScriptValue);
- if (!d || !d->isJSC())
+ if (!d || !d->isObject())
return QScriptValue();
+ QScript::APIShim shim(d->engine);
JSC::JSValue callee = d->jscValue;
JSC::CallData callData;
JSC::CallType callType = callee.getCallData(callData);
@@ -1656,8 +1658,9 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
QScriptValue QScriptValue::construct(const QScriptValueList &args)
{
Q_D(const QScriptValue);
- if (!d || !d->isJSC())
+ if (!d || !d->isObject())
return QScriptValue();
+ QScript::APIShim shim(d->engine);
JSC::JSValue callee = d->jscValue;
JSC::ConstructData constructData;
JSC::ConstructType constructType = callee.getConstructData(constructData);
@@ -1705,8 +1708,9 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args)
QScriptValue QScriptValue::construct(const QScriptValue &arguments)
{
Q_D(QScriptValue);
- if (!d || !d->isJSC())
+ if (!d || !d->isObject())
return QScriptValue();
+ QScript::APIShim shim(d->engine);
JSC::JSValue callee = d->jscValue;
JSC::ConstructData constructData;
JSC::ConstructType constructType = callee.getConstructData(constructData);
diff --git a/src/script/api/qscriptvalueiterator.cpp b/src/script/api/qscriptvalueiterator.cpp
index 5c1e6f2..7fd7093 100644
--- a/src/script/api/qscriptvalueiterator.cpp
+++ b/src/script/api/qscriptvalueiterator.cpp
@@ -100,6 +100,7 @@ public:
if (initialized)
return;
QScriptEnginePrivate *eng_p = engine();
+ QScript::APIShim shim(eng_p);
JSC::ExecState *exec = eng_p->globalExec();
JSC::PropertyNameArray propertyNamesArray(exec);
JSC::asObject(object()->jscValue)->getOwnPropertyNames(exec, propertyNamesArray, JSC::IncludeDontEnumProperties);
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index 765e074..83a811b 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -151,7 +151,8 @@ private:
static bool hasMethodAccess(const QMetaMethod &method, int index, const QScriptEngine::QObjectWrapOptions &opt)
{
return (method.access() != QMetaMethod::Private)
- && ((index != 2) || !(opt & QScriptEngine::ExcludeDeleteLater));
+ && ((index != 2) || !(opt & QScriptEngine::ExcludeDeleteLater))
+ && (!(opt & QScriptEngine::ExcludeSlots) || (method.methodType() != QMetaMethod::Slot));
}
static bool isEnumerableMetaProperty(const QMetaProperty &prop,
diff --git a/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir/Foo.qml b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/Foo.qml
index 2d1a4a3..2d1a4a3 100644
--- a/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir/Foo.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/Foo.qml
diff --git a/tests/auto/macnativeevents/qnativeinput.cpp b/tests/auto/macnativeevents/qnativeinput.cpp
new file mode 100644
index 0000000..c9462a6
--- /dev/null
+++ b/tests/auto/macnativeevents/qnativeinput.cpp
@@ -0,0 +1,378 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnativeinput.h"
+
+QNativeInput::QNativeInput(bool subscribe)
+{
+ if (subscribe)
+ subscribeForNativeEvents();
+}
+
+QNativeInput::~QNativeInput()
+{
+ unsubscribeForNativeEvents();
+}
+
+void QNativeInput::notify(QNativeEvent *event)
+{
+ nativeEvent(event);
+}
+
+void QNativeInput::nativeEvent(QNativeEvent *event)
+{
+ switch (event->id()){
+ case QNativeMouseButtonEvent::eventId:{
+ QNativeMouseButtonEvent *e = static_cast<QNativeMouseButtonEvent *>(event);
+ (e->clickCount > 0) ? nativeMousePressEvent(e) : nativeMouseReleaseEvent(e);
+ break; }
+ case QNativeMouseMoveEvent::eventId:
+ nativeMouseMoveEvent(static_cast<QNativeMouseMoveEvent *>(event));
+ break;
+ case QNativeMouseDragEvent::eventId:
+ nativeMouseDragEvent(static_cast<QNativeMouseDragEvent *>(event));
+ break;
+ case QNativeMouseWheelEvent::eventId:
+ nativeMouseWheelEvent(static_cast<QNativeMouseWheelEvent *>(event));
+ break;
+ case QNativeKeyEvent::eventId:{
+ QNativeKeyEvent *e = static_cast<QNativeKeyEvent *>(event);
+ e->press ? nativeKeyPressEvent(e) : nativeKeyReleaseEvent(e);
+ break; }
+ case QNativeModifierEvent::eventId:
+ nativeModifierEvent(static_cast<QNativeModifierEvent *>(event));
+ break;
+ default:
+ break;
+ }
+}
+
+Qt::Native::Status QNativeInput::sendNativeEvent(const QNativeEvent &event, int pid)
+{
+ switch (event.id()){
+ case QNativeMouseMoveEvent::eventId:
+ return sendNativeMouseMoveEvent(static_cast<const QNativeMouseMoveEvent &>(event));
+ case QNativeMouseButtonEvent::eventId:
+ return sendNativeMouseButtonEvent(static_cast<const QNativeMouseButtonEvent &>(event));
+ case QNativeMouseDragEvent::eventId:
+ return sendNativeMouseDragEvent(static_cast<const QNativeMouseDragEvent &>(event));
+ case QNativeMouseWheelEvent::eventId:
+ return sendNativeMouseWheelEvent(static_cast<const QNativeMouseWheelEvent &>(event));
+ case QNativeKeyEvent::eventId:
+ return sendNativeKeyEvent(static_cast<const QNativeKeyEvent &>(event), pid);
+ case QNativeModifierEvent::eventId:
+ return sendNativeModifierEvent(static_cast<const QNativeModifierEvent &>(event));
+ case QNativeEvent::eventId:
+ qWarning() << "Warning: Cannot send a pure native event. Use a sub class.";
+ default:
+ return Qt::Native::Failure;
+ }
+}
+
+QNativeEvent::QNativeEvent(Qt::KeyboardModifiers modifiers)
+ : modifiers(modifiers){}
+
+QNativeMouseEvent::QNativeMouseEvent(QPoint pos, Qt::KeyboardModifiers modifiers)
+ : QNativeEvent(modifiers), globalPos(pos){}
+
+QNativeMouseMoveEvent::QNativeMouseMoveEvent(QPoint pos, Qt::KeyboardModifiers modifiers)
+ : QNativeMouseEvent(pos, modifiers){}
+
+QNativeMouseButtonEvent::QNativeMouseButtonEvent(QPoint globalPos, Qt::MouseButton button, int clickCount, Qt::KeyboardModifiers modifiers)
+ : QNativeMouseEvent(globalPos, modifiers), button(button), clickCount(clickCount){}
+
+QNativeMouseDragEvent::QNativeMouseDragEvent(QPoint globalPos, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
+ : QNativeMouseButtonEvent(globalPos, button, true, modifiers){}
+
+QNativeMouseWheelEvent::QNativeMouseWheelEvent(QPoint globalPos, int delta, Qt::KeyboardModifiers modifiers)
+ : QNativeMouseEvent(globalPos, modifiers), delta(delta){}
+
+QNativeKeyEvent::QNativeKeyEvent(int nativeKeyCode, bool press, Qt::KeyboardModifiers modifiers)
+ : QNativeEvent(modifiers), nativeKeyCode(nativeKeyCode), press(press), character(QChar()){}
+
+QNativeModifierEvent::QNativeModifierEvent(Qt::KeyboardModifiers modifiers, int nativeKeyCode)
+ : QNativeEvent(modifiers), nativeKeyCode(nativeKeyCode){}
+
+QNativeKeyEvent::QNativeKeyEvent(int nativeKeyCode, bool press, QChar character, Qt::KeyboardModifiers modifiers)
+ : QNativeEvent(modifiers), nativeKeyCode(nativeKeyCode), press(press), character(character){}
+
+static QString getButtonAsString(const QNativeMouseButtonEvent *e)
+{
+ switch (e->button){
+ case Qt::LeftButton:
+ return "button = LeftButton";
+ break;
+ case Qt::RightButton:
+ return "button = RightButton";
+ break;
+ case Qt::MidButton:
+ return "button = MidButton";
+ break;
+ default:
+ return "button = Other";
+ break;
+ }
+}
+
+static QString getModifiersAsString(const QNativeEvent *e)
+{
+ if (e->modifiers == 0)
+ return "modifiers = none";
+
+ QString tmp = "modifiers = ";
+ if (e->modifiers.testFlag(Qt::ShiftModifier))
+ tmp += "Shift";
+ if (e->modifiers.testFlag(Qt::ControlModifier))
+ tmp += "Control";
+ if (e->modifiers.testFlag(Qt::AltModifier))
+ tmp += "Alt";
+ if (e->modifiers.testFlag(Qt::MetaModifier))
+ tmp += "Meta";
+ return tmp;
+}
+
+static QString getPosAsString(QPoint pos)
+{
+ return QString("QPoint(%1, %2)").arg(pos.x()).arg(pos.y());
+}
+
+static QString getBoolAsString(bool b)
+{
+ return b ? QString("true") : QString("false");
+}
+
+QString QNativeMouseMoveEvent::toString() const
+{
+ return QString("QNativeMouseMoveEvent(globalPos = %1 %2)").arg(getPosAsString(globalPos))
+ .arg(getModifiersAsString(this));
+}
+
+QString QNativeMouseButtonEvent::toString() const
+{
+ return QString("QNativeMouseButtonEvent(globalPos = %1, %2, clickCount = %3, %4)").arg(getPosAsString(globalPos))
+ .arg(getButtonAsString(this)).arg(clickCount).arg(getModifiersAsString(this));
+}
+
+QString QNativeMouseDragEvent::toString() const
+{
+ return QString("QNativeMouseDragEvent(globalPos = %1, %2, clickCount = %3, %4)").arg(getPosAsString(globalPos))
+ .arg(getButtonAsString(this)).arg(clickCount).arg(getModifiersAsString(this));
+}
+
+QString QNativeMouseWheelEvent::toString() const
+{
+ return QString("QNativeMouseWheelEvent(globalPos = %1, delta = %2, %3)").arg(getPosAsString(globalPos))
+ .arg(delta).arg(getModifiersAsString(this));
+}
+
+QString QNativeKeyEvent::toString() const
+{
+ return QString("QNativeKeyEvent(press = %1, native key code = %2, character = %3, %4)").arg(getBoolAsString(press))
+ .arg(nativeKeyCode).arg(character.isPrint() ? character : QString("<no char>"))
+ .arg(getModifiersAsString(this));
+}
+
+QString QNativeModifierEvent::toString() const
+{
+ return QString("QNativeModifierEvent(%1, native key code = %2)").arg(getModifiersAsString(this))
+ .arg(nativeKeyCode);
+}
+
+QDebug operator<<(QDebug d, QNativeEvent *e)
+{
+ Q_UNUSED(e);
+ return d << e->toString();
+}
+
+QDebug operator<<(QDebug d, const QNativeEvent &e)
+{
+ Q_UNUSED(e);
+ return d << e.toString();
+}
+
+QTextStream &operator<<(QTextStream &s, QNativeEvent *e)
+{
+ return s << e->eventId << " " << e->modifiers << " QNativeEvent";
+}
+
+QTextStream &operator<<(QTextStream &s, QNativeMouseEvent *e)
+{
+ return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->modifiers << " " << e->toString();
+}
+
+QTextStream &operator<<(QTextStream &s, QNativeMouseMoveEvent *e)
+{
+ return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->modifiers << " " << e->toString();
+}
+
+QTextStream &operator<<(QTextStream &s, QNativeMouseButtonEvent *e)
+{
+ return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->button
+ << " " << e->clickCount << " " << e->modifiers << " " << e->toString();
+}
+
+QTextStream &operator<<(QTextStream &s, QNativeMouseDragEvent *e)
+{
+ return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->button << " " << e->clickCount
+ << " " << e->modifiers << " " << e->toString();
+}
+
+QTextStream &operator<<(QTextStream &s, QNativeMouseWheelEvent *e)
+{
+ return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->delta
+ << " " << e->modifiers << " " << e->toString();
+}
+
+QTextStream &operator<<(QTextStream &s, QNativeKeyEvent *e)
+{
+ return s << e->eventId << " " << e->press << " " << e->nativeKeyCode << " " << e->character
+ << " " << e->modifiers << " " << e->toString();
+}
+
+QTextStream &operator<<(QTextStream &s, QNativeModifierEvent *e)
+{
+ return s << e->eventId << " " << e->modifiers << " " << e->nativeKeyCode << " " << e->toString();
+}
+
+
+
+
+QTextStream &operator>>(QTextStream &s, QNativeMouseMoveEvent *e)
+{
+ // Skip reading eventId.
+ QString humanReadable;
+ int x, y, modifiers;
+ s >> x >> y >> modifiers >> humanReadable;
+ e->globalPos.setX(x);
+ e->globalPos.setY(y);
+ e->modifiers = Qt::KeyboardModifiers(modifiers);
+ return s;
+}
+
+QTextStream &operator>>(QTextStream &s, QNativeMouseButtonEvent *e)
+{
+ // Skip reading eventId.
+ QString humanReadable;
+ int x, y, button, clickCount, modifiers;
+ s >> x >> y >> button >> clickCount >> modifiers >> humanReadable;
+ e->globalPos.setX(x);
+ e->globalPos.setY(y);
+ e->clickCount = clickCount;
+ e->modifiers = Qt::KeyboardModifiers(modifiers);
+ switch (button){
+ case 1:
+ e->button = Qt::LeftButton;
+ break;
+ case 2:
+ e->button = Qt::RightButton;
+ break;
+ case 3:
+ e->button = Qt::MidButton;
+ break;
+ default:
+ e->button = Qt::NoButton;
+ break;
+ }
+ return s;
+}
+
+QTextStream &operator>>(QTextStream &s, QNativeMouseDragEvent *e)
+{
+ // Skip reading eventId.
+ QString humanReadable;
+ int x, y, button, clickCount, modifiers;
+ s >> x >> y >> button >> clickCount >> modifiers >> humanReadable;
+ e->globalPos.setX(x);
+ e->globalPos.setY(y);
+ e->clickCount = clickCount;
+ e->modifiers = Qt::KeyboardModifiers(modifiers);
+ switch (button){
+ case 1:
+ e->button = Qt::LeftButton;
+ break;
+ case 2:
+ e->button = Qt::RightButton;
+ break;
+ case 3:
+ e->button = Qt::MidButton;
+ break;
+ default:
+ e->button = Qt::NoButton;
+ break;
+ }
+ return s;
+}
+
+QTextStream &operator>>(QTextStream &s, QNativeMouseWheelEvent *e)
+{
+ // Skip reading eventId.
+ QString humanReadable;
+ int x, y, modifiers;
+ s >> x >> y >> e->delta >> modifiers >> humanReadable;
+ e->globalPos.setX(x);
+ e->globalPos.setY(y);
+ e->modifiers = Qt::KeyboardModifiers(modifiers);
+ return s;
+}
+
+QTextStream &operator>>(QTextStream &s, QNativeKeyEvent *e)
+{
+ // Skip reading eventId.
+ QString humanReadable;
+ int press, modifiers;
+ QString character;
+ s >> press >> e->nativeKeyCode >> character >> modifiers >> humanReadable;
+ e->press = bool(press);
+ e->character = character[0];
+ e->modifiers = Qt::KeyboardModifiers(modifiers);
+ return s;
+}
+
+QTextStream &operator>>(QTextStream &s, QNativeModifierEvent *e)
+{
+ // Skip reading eventId.
+ QString humanReadable;
+ int modifiers;
+ s >> modifiers >> e->nativeKeyCode >> humanReadable;
+ e->modifiers = Qt::KeyboardModifiers(modifiers);
+ return s;
+}
+
diff --git a/tests/auto/macnativeevents/qnativeinput.h b/tests/auto/macnativeevents/qnativeinput.h
new file mode 100644
index 0000000..a98e4e4
--- /dev/null
+++ b/tests/auto/macnativeevents/qnativeinput.h
@@ -0,0 +1,228 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef Q_NATIVE_INPUT
+#define Q_NATIVE_INPUT
+
+#include <QtCore>
+
+namespace Qt {
+namespace Native {
+ enum Status {Success, Failure};
+}}
+
+// ----------------------------------------------------------------------------
+// Declare a set of native events that can be used to communicate with
+// client applications in an platform independent way
+// ----------------------------------------------------------------------------
+
+class QNativeEvent
+{
+public:
+ static const int eventId = 1;
+
+ QNativeEvent(Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ virtual ~QNativeEvent(){};
+ virtual int id() const { return eventId; };
+ virtual QString toString() const = 0;
+ Qt::KeyboardModifiers modifiers; // Yields for mouse events too.
+};
+
+class QNativeMouseEvent : public QNativeEvent {
+public:
+ static const int eventId = 2;
+
+ QNativeMouseEvent(){};
+ QNativeMouseEvent(QPoint globalPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ virtual ~QNativeMouseEvent(){};
+ virtual int id() const { return eventId; };
+
+ QPoint globalPos;
+};
+
+class QNativeMouseMoveEvent : public QNativeMouseEvent {
+public:
+ static const int eventId = 4;
+
+ QNativeMouseMoveEvent(){};
+ QNativeMouseMoveEvent(QPoint globalPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ virtual ~QNativeMouseMoveEvent(){};
+ virtual int id() const { return eventId; };
+ virtual QString toString() const;
+};
+
+class QNativeMouseButtonEvent : public QNativeMouseEvent {
+public:
+ static const int eventId = 8;
+
+ QNativeMouseButtonEvent(){};
+ QNativeMouseButtonEvent(QPoint globalPos, Qt::MouseButton button, int clickCount, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ virtual ~QNativeMouseButtonEvent(){};
+ virtual int id() const { return eventId; };
+ virtual QString toString() const;
+
+ Qt::MouseButton button;
+ int clickCount;
+};
+
+class QNativeMouseDragEvent : public QNativeMouseButtonEvent {
+public:
+ static const int eventId = 16;
+
+ QNativeMouseDragEvent(){};
+ QNativeMouseDragEvent(QPoint globalPos, Qt::MouseButton button, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ virtual ~QNativeMouseDragEvent(){};
+ virtual int id() const { return eventId; };
+ virtual QString toString() const;
+};
+
+class QNativeMouseWheelEvent : public QNativeMouseEvent {
+public:
+ static const int eventId = 32;
+
+ QNativeMouseWheelEvent(){};
+ QNativeMouseWheelEvent(QPoint globalPos, int delta, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ virtual ~QNativeMouseWheelEvent(){};
+ virtual int id() const { return eventId; };
+ virtual QString toString() const;
+
+ int delta;
+};
+
+class QNativeKeyEvent : public QNativeEvent {
+ public:
+ static const int eventId = 64;
+
+ QNativeKeyEvent(){};
+ QNativeKeyEvent(int nativeKeyCode, bool press, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ QNativeKeyEvent(int nativeKeyCode, bool press, QChar character, Qt::KeyboardModifiers modifiers);
+ virtual ~QNativeKeyEvent(){};
+ virtual int id() const { return eventId; };
+ virtual QString toString() const;
+
+ int nativeKeyCode;
+ bool press;
+ QChar character;
+
+ // Some Qt to Native mappings:
+ static int Key_A;
+ static int Key_B;
+ static int Key_C;
+ static int Key_1;
+ static int Key_Backspace;
+ static int Key_Enter;
+ static int Key_Del;
+};
+
+class QNativeModifierEvent : public QNativeEvent {
+public:
+ static const int eventId = 128;
+
+ QNativeModifierEvent(Qt::KeyboardModifiers modifiers = Qt::NoModifier, int nativeKeyCode = 0);
+ virtual ~QNativeModifierEvent(){};
+ virtual int id() const { return eventId; };
+ virtual QString toString() const;
+
+ int nativeKeyCode;
+};
+
+// ----------------------------------------------------------------------------
+// Declare a set of related output / input functions for convenience:
+// ----------------------------------------------------------------------------
+
+QDebug operator<<(QDebug d, QNativeEvent *e);
+QDebug operator<<(QDebug d, const QNativeEvent &e);
+
+QTextStream &operator<<(QTextStream &s, QNativeEvent *e);
+QTextStream &operator<<(QTextStream &s, QNativeMouseEvent *e);
+QTextStream &operator<<(QTextStream &s, QNativeMouseMoveEvent *e);
+QTextStream &operator<<(QTextStream &s, QNativeMouseButtonEvent *e);
+QTextStream &operator<<(QTextStream &s, QNativeMouseDragEvent *e);
+QTextStream &operator<<(QTextStream &s, QNativeMouseWheelEvent *e);
+QTextStream &operator<<(QTextStream &s, QNativeKeyEvent *e);
+QTextStream &operator<<(QTextStream &s, QNativeModifierEvent *e);
+
+QTextStream &operator>>(QTextStream &s, QNativeMouseMoveEvent *e);
+QTextStream &operator>>(QTextStream &s, QNativeMouseButtonEvent *e);
+QTextStream &operator>>(QTextStream &s, QNativeMouseDragEvent *e);
+QTextStream &operator>>(QTextStream &s, QNativeMouseWheelEvent *e);
+QTextStream &operator>>(QTextStream &s, QNativeKeyEvent *e);
+QTextStream &operator>>(QTextStream &s, QNativeModifierEvent *e);
+
+// ----------------------------------------------------------------------------
+// Declare the main class that is supposed to be sub-classed by components
+// that are to receive native events
+// ----------------------------------------------------------------------------
+
+class QNativeInput
+{
+ public:
+ QNativeInput(bool subscribe = true);
+ virtual ~QNativeInput();
+
+ // Callback methods. Should be implemented by interested sub-classes:
+ void notify(QNativeEvent *event);
+ virtual void nativeEvent(QNativeEvent *event);
+ virtual void nativeMousePressEvent(QNativeMouseButtonEvent *){};
+ virtual void nativeMouseReleaseEvent(QNativeMouseButtonEvent *){};
+ virtual void nativeMouseMoveEvent(QNativeMouseMoveEvent *){};
+ virtual void nativeMouseDragEvent(QNativeMouseDragEvent *){};
+ virtual void nativeMouseWheelEvent(QNativeMouseWheelEvent *){};
+ virtual void nativeKeyPressEvent(QNativeKeyEvent *){};
+ virtual void nativeKeyReleaseEvent(QNativeKeyEvent *){};
+ virtual void nativeModifierEvent(QNativeModifierEvent *){};
+
+ // The following methods will differ in implementation from OS to OS:
+ static Qt::Native::Status sendNativeMouseButtonEvent(const QNativeMouseButtonEvent &event);
+ static Qt::Native::Status sendNativeMouseMoveEvent(const QNativeMouseMoveEvent &event);
+ static Qt::Native::Status sendNativeMouseDragEvent(const QNativeMouseDragEvent &event);
+ static Qt::Native::Status sendNativeMouseWheelEvent(const QNativeMouseWheelEvent &event);
+ static Qt::Native::Status sendNativeKeyEvent(const QNativeKeyEvent &event, int pid = 0);
+ static Qt::Native::Status sendNativeModifierEvent(const QNativeModifierEvent &event);
+ // sendNativeEvent will NOT differ from OS to OS.
+ static Qt::Native::Status sendNativeEvent(const QNativeEvent &event, int pid = 0);
+
+ // The following methods will differ in implementation from OS to OS:
+ Qt::Native::Status subscribeForNativeEvents();
+ Qt::Native::Status unsubscribeForNativeEvents();
+};
+
+#endif // Q_NATIVE_INPUT
diff --git a/tests/auto/macnativeevents/qnativeinput_mac.cpp b/tests/auto/macnativeevents/qnativeinput_mac.cpp
new file mode 100644
index 0000000..143a633
--- /dev/null
+++ b/tests/auto/macnativeevents/qnativeinput_mac.cpp
@@ -0,0 +1,382 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnativeinput.h"
+#include <Carbon/Carbon.h>
+#include <QtCore>
+
+// ************************************************************
+// Quartz
+// ************************************************************
+
+static Qt::KeyboardModifiers getModifiersFromQuartzEvent(CGEventRef inEvent)
+{
+ Qt::KeyboardModifiers m;
+ CGEventFlags flags = CGEventGetFlags(inEvent);
+ if (flags & kCGEventFlagMaskShift || flags & kCGEventFlagMaskAlphaShift)
+ m |= Qt::ShiftModifier;
+ if (flags & kCGEventFlagMaskControl)
+ m |= Qt::MetaModifier;
+ if (flags & kCGEventFlagMaskAlternate)
+ m |= Qt::AltModifier;
+ if (flags & kCGEventFlagMaskCommand)
+ m |= Qt::ControlModifier;
+ return m;
+}
+
+static void setModifiersFromQNativeEvent(CGEventRef inEvent, const QNativeEvent &event)
+{
+ CGEventFlags flags = 0;
+ if (event.modifiers.testFlag(Qt::ShiftModifier))
+ flags |= kCGEventFlagMaskShift;
+ if (event.modifiers.testFlag(Qt::MetaModifier))
+ flags |= kCGEventFlagMaskControl;
+ if (event.modifiers.testFlag(Qt::AltModifier))
+ flags |= kCGEventFlagMaskAlternate;
+ if (event.modifiers.testFlag(Qt::ControlModifier))
+ flags |= kCGEventFlagMaskCommand;
+ CGEventSetFlags(inEvent, flags);
+}
+
+static QPoint getMouseLocationFromQuartzEvent(CGEventRef inEvent)
+{
+ CGPoint pos = CGEventGetLocation(inEvent);
+ QPoint tmp;
+ tmp.setX(pos.x);
+ tmp.setY(pos.y);
+ return tmp;
+}
+
+static QChar getCharFromQuartzEvent(CGEventRef inEvent)
+{
+ UniCharCount count = 0;
+ UniChar c;
+ CGEventKeyboardGetUnicodeString(inEvent, 1, &count, &c);
+ return QChar(c);
+}
+
+static CGEventRef EventHandler_Quartz(CGEventTapProxy proxy, CGEventType type, CGEventRef inEvent, void *refCon)
+{
+ Q_UNUSED(proxy);
+ QNativeInput *nativeInput = static_cast<QNativeInput *>(refCon);
+ switch (type){
+ case kCGEventKeyDown:{
+ QNativeKeyEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.nativeKeyCode = CGEventGetIntegerValueField(inEvent, kCGKeyboardEventKeycode);
+ e.character = getCharFromQuartzEvent(inEvent);
+ e.press = true;
+ nativeInput->notify(&e);
+ break;
+ }
+ case kCGEventKeyUp:{
+ QNativeKeyEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.nativeKeyCode = CGEventGetIntegerValueField(inEvent, kCGKeyboardEventKeycode);
+ e.character = getCharFromQuartzEvent(inEvent);
+ e.press = false;
+ nativeInput->notify(&e);
+ break;
+ }
+ case kCGEventLeftMouseDown:{
+ QNativeMouseButtonEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.globalPos = getMouseLocationFromQuartzEvent(inEvent);
+ e.clickCount = CGEventGetIntegerValueField(inEvent, kCGMouseEventClickState);
+ e.button = Qt::LeftButton;
+ nativeInput->notify(&e);
+ break;
+ }
+ case kCGEventLeftMouseUp:{
+ QNativeMouseButtonEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.globalPos = getMouseLocationFromQuartzEvent(inEvent);
+ e.clickCount = 0;
+ e.button = Qt::LeftButton;
+ nativeInput->notify(&e);
+ break;
+ }
+ case kCGEventRightMouseDown:{
+ QNativeMouseButtonEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.globalPos = getMouseLocationFromQuartzEvent(inEvent);
+ e.clickCount = CGEventGetIntegerValueField(inEvent, kCGMouseEventClickState);
+ e.button = Qt::RightButton;
+ nativeInput->notify(&e);
+ break;
+ }
+ case kCGEventRightMouseUp:{
+ QNativeMouseButtonEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.globalPos = getMouseLocationFromQuartzEvent(inEvent);
+ e.clickCount = 0;
+ e.button = Qt::RightButton;
+ nativeInput->notify(&e);
+ break;
+ }
+ case kCGEventMouseMoved:{
+ QNativeMouseMoveEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.globalPos = getMouseLocationFromQuartzEvent(inEvent);
+ nativeInput->notify(&e);
+ break;
+ }
+ case kCGEventLeftMouseDragged:{
+ QNativeMouseDragEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.globalPos = getMouseLocationFromQuartzEvent(inEvent);
+ e.clickCount = CGEventGetIntegerValueField(inEvent, kCGMouseEventClickState);
+ e.button = Qt::LeftButton;
+ nativeInput->notify(&e);
+ break;
+ }
+ case kCGEventScrollWheel:{
+ QNativeMouseWheelEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.delta = CGEventGetIntegerValueField(inEvent, kCGScrollWheelEventDeltaAxis1);
+ e.globalPos = getMouseLocationFromQuartzEvent(inEvent);
+ nativeInput->notify(&e);
+ break;
+ }
+ case kCGEventFlagsChanged:{
+ QNativeModifierEvent e;
+ e.modifiers = getModifiersFromQuartzEvent(inEvent);
+ e.nativeKeyCode = CGEventGetIntegerValueField(inEvent, kCGKeyboardEventKeycode);
+ nativeInput->notify(&e);
+ break;
+ }
+
+ }
+
+ return inEvent;
+}
+
+Qt::Native::Status insertEventHandler_Quartz(QNativeInput *nativeInput, int pid = 0)
+{
+ uid_t uid = geteuid();
+ if (uid != 0)
+ qWarning("MacNativeEvents: You must be root to listen for key events!");
+
+ CFMachPortRef port;
+ if (!pid){
+ port = CGEventTapCreate(kCGHIDEventTap,
+ kCGHeadInsertEventTap, kCGEventTapOptionListenOnly,
+ kCGEventMaskForAllEvents, EventHandler_Quartz, nativeInput);
+ } else {
+ ProcessSerialNumber psn;
+ GetProcessForPID(pid, &psn);
+ port = CGEventTapCreateForPSN(&psn,
+ kCGHeadInsertEventTap, kCGEventTapOptionListenOnly,
+ kCGEventMaskForAllEvents, EventHandler_Quartz, nativeInput);
+ }
+
+ CFRunLoopSourceRef eventSrc = CFMachPortCreateRunLoopSource(NULL, port, 0);
+ CFRunLoopAddSource((CFRunLoopRef) GetCFRunLoopFromEventLoop(GetMainEventLoop()),
+ eventSrc, kCFRunLoopCommonModes);
+
+ return Qt::Native::Success;
+}
+
+Qt::Native::Status removeEventHandler_Quartz()
+{
+ return Qt::Native::Success; // ToDo:
+}
+
+Qt::Native::Status sendNativeKeyEventToProcess_Quartz(const QNativeKeyEvent &event, int pid)
+{
+ ProcessSerialNumber psn;
+ GetProcessForPID(pid, &psn);
+
+ CGEventRef e = CGEventCreateKeyboardEvent(0, (uint)event.nativeKeyCode, event.press);
+ setModifiersFromQNativeEvent(e, event);
+ SetFrontProcess(&psn);
+ CGEventPostToPSN(&psn, e);
+ CFRelease(e);
+ return Qt::Native::Success;
+}
+
+Qt::Native::Status sendNativeKeyEvent_Quartz(const QNativeKeyEvent &event)
+{
+ CGEventRef e = CGEventCreateKeyboardEvent(0, (uint)event.nativeKeyCode, event.press);
+ setModifiersFromQNativeEvent(e, event);
+ CGEventPost(kCGHIDEventTap, e);
+ CFRelease(e);
+ return Qt::Native::Success;
+}
+
+Qt::Native::Status sendNativeMouseMoveEvent_Quartz(const QNativeMouseMoveEvent &event)
+{
+ CGPoint pos;
+ pos.x = event.globalPos.x();
+ pos.y = event.globalPos.y();
+
+ CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0);
+ setModifiersFromQNativeEvent(e, event);
+ CGEventPost(kCGHIDEventTap, e);
+ CFRelease(e);
+ return Qt::Native::Success;
+}
+
+Qt::Native::Status sendNativeMouseButtonEvent_Quartz(const QNativeMouseButtonEvent &event)
+{
+ CGPoint pos;
+ pos.x = event.globalPos.x();
+ pos.y = event.globalPos.y();
+
+ CGEventType type = 0;
+ if (event.button == Qt::LeftButton)
+ type = (event.clickCount > 0) ? kCGEventLeftMouseDown : kCGEventLeftMouseUp;
+ else if (event.button == Qt::RightButton)
+ type = (event.clickCount > 0) ? kCGEventRightMouseDown : kCGEventRightMouseUp;
+ else
+ type = (event.clickCount > 0) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp;
+
+ CGEventRef e = CGEventCreateMouseEvent(0, type, pos, event.button);
+ setModifiersFromQNativeEvent(e, event);
+ CGEventSetIntegerValueField(e, kCGMouseEventClickState, event.clickCount);
+ CGEventPost(kCGHIDEventTap, e);
+ CFRelease(e);
+ return Qt::Native::Success;
+}
+
+Qt::Native::Status sendNativeMouseDragEvent_Quartz(const QNativeMouseDragEvent &event)
+{
+ CGPoint pos;
+ pos.x = event.globalPos.x();
+ pos.y = event.globalPos.y();
+
+ CGEventType type = 0;
+ if (event.button == Qt::LeftButton)
+ type = kCGEventLeftMouseDragged;
+ else if (event.button == Qt::RightButton)
+ type = kCGEventRightMouseDragged;
+ else
+ type = kCGEventOtherMouseDragged;
+
+ CGEventRef e = CGEventCreateMouseEvent(0, type, pos, event.button);
+ setModifiersFromQNativeEvent(e, event);
+ CGEventPost(kCGHIDEventTap, e);
+ CFRelease(e);
+ return Qt::Native::Success;
+}
+
+Qt::Native::Status sendNativeMouseWheelEvent_Quartz(const QNativeMouseWheelEvent &event)
+{
+ CGPoint pos;
+ pos.x = event.globalPos.x();
+ pos.y = event.globalPos.y();
+
+ CGEventRef e = CGEventCreateScrollWheelEvent(0, kCGScrollEventUnitPixel, 1, 0);
+ CGEventSetIntegerValueField(e, kCGScrollWheelEventDeltaAxis1, event.delta);
+ CGEventSetLocation(e, pos);
+ setModifiersFromQNativeEvent(e, event);
+ CGEventPost(kCGHIDEventTap, e);
+ CFRelease(e);
+
+ return Qt::Native::Success;
+}
+
+Qt::Native::Status sendNativeModifierEvent_Quartz(const QNativeModifierEvent &event)
+{
+ CGEventRef e = CGEventCreateKeyboardEvent(0, (uint)event.nativeKeyCode, 0);
+ CGEventSetType(e, kCGEventFlagsChanged);
+ setModifiersFromQNativeEvent(e, event);
+ CGEventPost(kCGHIDEventTap, e);
+ CFRelease(e);
+ return Qt::Native::Success;
+}
+
+// ************************************************************
+// QNativeInput methods:
+// ************************************************************
+
+Qt::Native::Status QNativeInput::sendNativeMouseButtonEvent(const QNativeMouseButtonEvent &event)
+{
+ return sendNativeMouseButtonEvent_Quartz(event);
+}
+
+Qt::Native::Status QNativeInput::sendNativeMouseMoveEvent(const QNativeMouseMoveEvent &event)
+{
+ return sendNativeMouseMoveEvent_Quartz(event);
+}
+
+Qt::Native::Status QNativeInput::sendNativeMouseDragEvent(const QNativeMouseDragEvent &event)
+{
+ return sendNativeMouseDragEvent_Quartz(event);
+}
+
+Qt::Native::Status QNativeInput::sendNativeMouseWheelEvent(const QNativeMouseWheelEvent &event)
+{
+ return sendNativeMouseWheelEvent_Quartz(event);
+}
+
+Qt::Native::Status QNativeInput::sendNativeKeyEvent(const QNativeKeyEvent &event, int pid)
+{
+ if (!pid)
+ return sendNativeKeyEvent_Quartz(event);
+ else
+ return sendNativeKeyEventToProcess_Quartz(event, pid);
+}
+
+Qt::Native::Status QNativeInput::sendNativeModifierEvent(const QNativeModifierEvent &event)
+{
+ return sendNativeModifierEvent_Quartz(event);
+}
+
+Qt::Native::Status QNativeInput::subscribeForNativeEvents()
+{
+ return insertEventHandler_Quartz(this);
+}
+
+Qt::Native::Status QNativeInput::unsubscribeForNativeEvents()
+{
+ return removeEventHandler_Quartz();
+}
+
+// Some Qt to Mac mappings:
+int QNativeKeyEvent::Key_A = 0;
+int QNativeKeyEvent::Key_B = 11;
+int QNativeKeyEvent::Key_C = 8;
+int QNativeKeyEvent::Key_1 = 18;
+int QNativeKeyEvent::Key_Backspace = 51;
+int QNativeKeyEvent::Key_Enter = 36;
+int QNativeKeyEvent::Key_Del = 117;
+
diff --git a/tests/auto/macnativeevents/qnativeplayer.cpp b/tests/auto/macnativeevents/qnativeplayer.cpp
new file mode 100644
index 0000000..92298ef
--- /dev/null
+++ b/tests/auto/macnativeevents/qnativeplayer.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnativeplayer.h"
+
+QNativePlayer::QNativePlayer()
+{
+ currIndex = -1;
+ playbackMultiplier = 1.0;
+ wait = false;
+}
+
+QNativePlayer::~QNativePlayer()
+{
+ for (int i=0; i<eventList.size(); i++)
+ delete eventList.takeAt(i).second;
+}
+
+void QNativePlayer::sendNextEvent()
+{
+ QNativeEvent *e = eventList.at(currIndex).second;
+ if (e)
+ QNativeInput::sendNativeEvent(*e);
+ waitNextEvent();
+}
+
+void QNativePlayer::waitNextEvent()
+{
+ if (++currIndex >= eventList.size()){
+ emit done();
+ stop();
+ return;
+ }
+
+ int interval = eventList.at(currIndex).first;
+ QTimer::singleShot(interval * playbackMultiplier, this, SLOT(sendNextEvent()));
+}
+
+void QNativePlayer::append(int waitMs, QNativeEvent *event)
+{
+ eventList.append(QPair<int, QNativeEvent *>(waitMs, event));
+}
+
+void QNativePlayer::play(Playback playback)
+{
+ waitNextEvent();
+
+ wait = (playback == WaitUntilFinished);
+ while (wait)
+ QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents);
+}
+
+void QNativePlayer::stop()
+{
+ wait = false;
+ QAbstractEventDispatcher::instance()->interrupt();
+}
+
+// ************************************************************************
+
+QEventOutputList::QEventOutputList()
+{
+ wait = true;
+}
+
+QEventOutputList::~QEventOutputList()
+{
+ qDeleteAll(*this);
+}
+
+bool QEventOutputList::waitUntilEmpty(int maxEventWaitTime)
+{
+ int currSize = size();
+ QTime time;
+ time.restart();
+ while (wait){
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
+
+ if (isEmpty()){
+ return true;
+ }
+ else if (currSize == size()){
+ if (time.elapsed() > maxEventWaitTime){
+ return false;
+ }
+ }
+ else{
+ currSize = size();
+ time.restart();
+ }
+ }
+ return false;
+}
+
+void QEventOutputList::sleep(int sleepTime)
+{
+ QTime time;
+ time.restart();
+ while (time.elapsed() < sleepTime)
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
+}
diff --git a/tests/auto/macnativeevents/qnativeplayer.h b/tests/auto/macnativeevents/qnativeplayer.h
new file mode 100644
index 0000000..61ee162
--- /dev/null
+++ b/tests/auto/macnativeevents/qnativeplayer.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef Q_NATIVE_PLAYBACK
+#define Q_NATIVE_PLAYBACK
+
+#include <QtCore>
+#include "qnativeinput.h"
+
+class QNativePlayer : public QObject
+{
+ Q_OBJECT;
+
+ public:
+ enum Playback {ReturnImmediately, WaitUntilFinished};
+
+ QNativePlayer();
+ ~QNativePlayer();
+
+ void append(int waitMs, QNativeEvent *event = 0);
+ void play(Playback playback = WaitUntilFinished);
+ void stop();
+ float playbackMultiplier;
+
+signals:
+ void done();
+
+private slots:
+ void sendNextEvent();
+
+ private:
+ void waitNextEvent();
+
+ QList<QPair<int, QNativeEvent *> > eventList;
+ int currIndex;
+ bool wait;
+};
+
+// ******************************************************************
+
+class QEventOutputList : public QList<QEvent *>
+{
+public:
+ QEventOutputList();
+ ~QEventOutputList();
+ bool waitUntilEmpty(int maxEventWaitTime = 1000);
+ bool wait;
+
+ // Useful method. Just sleep and process events:
+ static void sleep(int sleepTime);
+};
+
+
+#endif
diff --git a/tests/auto/macnativeevents/tst_macnativeevents.cpp b/tests/auto/macnativeevents/tst_macnativeevents.cpp
new file mode 100644
index 0000000..ccadd54
--- /dev/null
+++ b/tests/auto/macnativeevents/tst_macnativeevents.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QWidget>
+#include <QPushButton>
+#include <QtTest/QtTest>
+
+#include "qnativeinput.h"
+#include "qnativeplayer.h"
+
+#ifdef Q_OS_MAC
+
+QT_USE_NAMESPACE
+
+class tst_MacNativeEvents : public QObject
+{
+Q_OBJECT
+private slots:
+ void testLeftMousePressRelease();
+};
+
+void tst_MacNativeEvents::testLeftMousePressRelease()
+{
+ QPushButton w("click me");
+ w.show();
+ QPoint p = w.geometry().center();
+
+ QNativePlayer player;
+ player.append(50, new QNativeMouseButtonEvent(p, Qt::LeftButton, 1, Qt::NoModifier));
+ player.append(50, new QNativeMouseButtonEvent(p, Qt::LeftButton, 0, Qt::NoModifier));
+ player.play();
+}
+
+#include "tst_macnativeevents.moc"
+
+QTEST_MAIN(tst_MacNativeEvents)
+
+#else
+
+QTEST_NOOP_MAIN
+
+#endif
diff --git a/tests/auto/macnativeevents/tst_macnativeevents.pro b/tests/auto/macnativeevents/tst_macnativeevents.pro
new file mode 100644
index 0000000..a0293d4
--- /dev/null
+++ b/tests/auto/macnativeevents/tst_macnativeevents.pro
@@ -0,0 +1,16 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Wed Nov 29 22:24:47 2006
+######################################################################
+
+load(qttest_p4)
+TEMPLATE = app
+DEPENDPATH += .
+INCLUDEPATH += .
+LIBS += -framework Carbon
+
+HEADERS += qnativeinput.h qnativeplayer.h
+SOURCES += qnativeinput.cpp qnativeplayer.cpp qnativeinput_mac.cpp
+
+SOURCES += tst_macnativeevents.cpp
+
+requires(mac)
diff --git a/tests/auto/other.pro b/tests/auto/other.pro
index e220d1a..3c8f856 100644
--- a/tests/auto/other.pro
+++ b/tests/auto/other.pro
@@ -37,6 +37,7 @@ SUBDIRS=\
contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter
mac: {
SUBDIRS += macgui \
+ macnativeevents \
macplist \
qaccessibility_mac
}
diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp
index f6fce32..c1db8f2 100644
--- a/tests/auto/qdiriterator/tst_qdiriterator.cpp
+++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp
@@ -198,6 +198,54 @@ void tst_QDirIterator::iterateRelativeDirectory_data()
#endif
"entrylist/writable").split(',');
+ QTest::newRow("NoDot")
+ << QString("entrylist") << QDirIterator::IteratorFlags(0)
+ << QDir::Filters(QDir::AllEntries | QDir::NoDot) << QStringList("*")
+ << QString(
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
+ "entrylist/..,"
+#endif
+ "entrylist/file,"
+#ifndef Q_NO_SYMLINKS
+ "entrylist/linktofile.lnk,"
+#endif
+ "entrylist/directory,"
+#if !defined(Q_NO_SYMLINKS) && !defined(Q_NO_SYMLINKS_TO_DIRS)
+ "entrylist/linktodirectory.lnk,"
+#endif
+ "entrylist/writable").split(',');
+
+ QTest::newRow("NoDotDot")
+ << QString("entrylist") << QDirIterator::IteratorFlags(0)
+ << QDir::Filters(QDir::AllEntries | QDir::NoDotDot) << QStringList("*")
+ << QString(
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
+ "entrylist/.,"
+#endif
+ "entrylist/file,"
+#ifndef Q_NO_SYMLINKS
+ "entrylist/linktofile.lnk,"
+#endif
+ "entrylist/directory,"
+#if !defined(Q_NO_SYMLINKS) && !defined(Q_NO_SYMLINKS_TO_DIRS)
+ "entrylist/linktodirectory.lnk,"
+#endif
+ "entrylist/writable").split(',');
+
+ QTest::newRow("NoDotAndDotDot")
+ << QString("entrylist") << QDirIterator::IteratorFlags(0)
+ << QDir::Filters(QDir::AllEntries | QDir::NoDotAndDotDot) << QStringList("*")
+ << QString(
+ "entrylist/file,"
+#ifndef Q_NO_SYMLINKS
+ "entrylist/linktofile.lnk,"
+#endif
+ "entrylist/directory,"
+#if !defined(Q_NO_SYMLINKS) && !defined(Q_NO_SYMLINKS_TO_DIRS)
+ "entrylist/linktodirectory.lnk,"
+#endif
+ "entrylist/writable").split(',');
+
QTest::newRow("QDir::Subdirectories | QDir::FollowSymlinks")
<< QString("entrylist") << QDirIterator::IteratorFlags(QDirIterator::Subdirectories | QDirIterator::FollowSymlinks)
<< QDir::Filters(QDir::NoFilter) << QStringList("*")
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index f407b12..8722a86 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -196,6 +196,7 @@ private slots:
void miscWithUncPathAsCurrentDir();
void standarderror();
void handle();
+ void nativeHandleLeaks();
void readEof_data();
void readEof();
@@ -392,6 +393,7 @@ void tst_QFile::cleanupTestCase()
QFile::remove("resources");
QFile::remove("qfile_map_testfile");
QFile::remove("readAllBuffer.txt");
+ QFile::remove("qt_file.tmp");
}
//------------------------------------------
@@ -2538,6 +2540,51 @@ void tst_QFile::handle()
#endif
}
+void tst_QFile::nativeHandleLeaks()
+{
+ int fd1, fd2;
+
+#ifdef Q_OS_WIN
+ HANDLE handle1, handle2;
+#endif
+
+ {
+ QFile file("qt_file.tmp");
+ QVERIFY( file.open(QIODevice::ReadWrite) );
+
+ fd1 = file.handle();
+ QVERIFY( -1 != fd1 );
+ }
+
+#ifdef Q_OS_WIN
+ handle1 = ::CreateFileA("qt_file.tmp", GENERIC_READ, 0, NULL,
+ OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ QVERIFY( INVALID_HANDLE_VALUE != handle1 );
+ QVERIFY( ::CloseHandle(handle1) );
+#endif
+
+ {
+ QFile file("qt_file.tmp");
+ QVERIFY( file.open(QIODevice::ReadOnly) );
+
+ fd2 = file.handle();
+ QVERIFY( -1 != fd2 );
+ }
+
+#ifdef Q_OS_WIN
+ handle2 = ::CreateFileA("qt_file.tmp", GENERIC_READ, 0, NULL,
+ OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ QVERIFY( INVALID_HANDLE_VALUE != handle2 );
+ QVERIFY( ::CloseHandle(handle2) );
+#endif
+
+ QCOMPARE( fd2, fd1 );
+
+#ifdef Q_OS_WIN
+ QCOMPARE( handle2, handle1 );
+#endif
+}
+
void tst_QFile::readEof_data()
{
QTest::addColumn<QString>("filename");
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index c0ad8bf..92a7f2e 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -7719,7 +7719,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem()
QTest::qWait(50);
// Make sure all visible items are repainted.
- QCOMPARE(item1->repaints, 0);
+ QCOMPARE(item1->repaints, 1);
QCOMPARE(item2->repaints, 1);
QCOMPARE(item3->repaints, 1);
@@ -9819,6 +9819,16 @@ void tst_QGraphicsItem::scenePosChange()
QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 4);
QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+
+ root->setX(1);
+ QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 5);
+ QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
+ QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+
+ root->setY(1);
+ QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 6);
+ QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
+ QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
}
void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 6ef4305..3b2a716 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -93,6 +93,7 @@ private slots:
void task232634_childrenDeselectionSignal();
void task260134_layoutChangedWithAllSelected();
void QTBUG5671_layoutChangedWithAllSelected();
+ void QTBUG2804_layoutChangedTreeSelection();
private:
QAbstractItemModel *model;
@@ -2327,5 +2328,31 @@ void tst_QItemSelectionModel::QTBUG5671_layoutChangedWithAllSelected()
QVERIFY(selection.isSelected(index));
}
+void tst_QItemSelectionModel::QTBUG2804_layoutChangedTreeSelection()
+{
+ QStandardItemModel model;
+ QStandardItem top1("Child1"), top2("Child2"), top3("Child3");
+ QStandardItem sub11("Alpha"), sub12("Beta"), sub13("Gamma"), sub14("Delta"),
+ sub21("Alpha"), sub22("Beta"), sub23("Gamma"), sub24("Delta");
+ top1.appendColumn(QList<QStandardItem*>() << &sub11 << &sub12 << &sub13 << &sub14);
+ top2.appendColumn(QList<QStandardItem*>() << &sub21 << &sub22 << &sub23 << &sub24);
+ model.appendColumn(QList<QStandardItem*>() << &top1 << &top2 << &top3);
+
+ QItemSelectionModel selModel(&model);
+
+ selModel.select(sub11.index(), QItemSelectionModel::Select);
+ selModel.select(sub12.index(), QItemSelectionModel::Select);
+ selModel.select(sub21.index(), QItemSelectionModel::Select);
+ selModel.select(sub23.index(), QItemSelectionModel::Select);
+
+ QModelIndexList list = selModel.selectedIndexes();
+ QCOMPARE(list.count(), 4);
+
+ model.sort(0); //this will provoke a relayout
+
+ QCOMPARE(selModel.selectedIndexes().count(), 4);
+}
+
+
QTEST_MAIN(tst_QItemSelectionModel)
#include "tst_qitemselectionmodel.moc"
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index 21a6f32..182f73b 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -158,15 +158,9 @@ void tst_QLocale::ctor()
QCoreApplication app(argc, (char**)&argv);
#endif
QLocale default_locale = QLocale::system();
-
- QVERIFY(!default_locale.monthName(1, QLocale::LongFormat).isEmpty());
- QVERIFY(!default_locale.monthName(1, QLocale::ShortFormat).isEmpty());
- QVERIFY(default_locale.language() != 0);
-
QLocale::Language default_lang = default_locale.language();
QLocale::Country default_country = default_locale.country();
-
qDebug("Default: %s/%s", QLocale::languageToString(default_lang).toLatin1().constData(),
QLocale::countryToString(default_country).toLatin1().constData());
diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
index 4b56f77..c08120c 100644
--- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
+++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include <QLocalServer>
#include <QLocalSocket>
+#include <QTimer>
#include "../../qbearertestcommon.h"
#include <qnetworkconfigmanager.h>
#include <qnetworksession.h>
@@ -53,6 +54,9 @@
QT_USE_NAMESPACE
+// Can be used to configure tests that require manual attention (such as roaming)
+//#define QNETWORKSESSION_MANUAL_TESTS 1
+
Q_DECLARE_METATYPE(QNetworkConfiguration)
Q_DECLARE_METATYPE(QNetworkConfiguration::Type);
Q_DECLARE_METATYPE(QNetworkSession::State);
@@ -75,6 +79,9 @@ private slots:
void repeatedOpenClose();
void roamingErrorCodes();
+
+ void sessionStop_data();
+ void sessionStop();
void sessionProperties_data();
void sessionProperties();
@@ -106,6 +113,7 @@ private:
// Helper functions
bool openSession(QNetworkSession *session);
bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration = true);
+void updateConfigurations();
QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfiguration::Type configType);
void tst_QNetworkSession::initTestCase()
@@ -226,14 +234,13 @@ void tst_QNetworkSession::cleanupTestCase()
void tst_QNetworkSession::invalidSession()
{
- // Verify that session created with invalid configuration remains in invalid state
+ // 1. Verify that session created with invalid configuration remains in invalid state
QNetworkSession session(QNetworkConfiguration(), 0);
QVERIFY(!session.isOpen());
QVERIFY(session.state() == QNetworkSession::Invalid);
QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError);
- // Verify that opening session with invalid configuration both 1) emits invalidconfigurationerror
- // and 2) sets session's state as invalid.
+ // 2. Verify that opening session with invalid configuration both 1) emits invalidconfigurationerror and 2) sets session's state as invalid.
QSignalSpy errorSpy(&session, SIGNAL(error(QNetworkSession::SessionError)));
session.open();
session.waitForOpened(1000); // Should bail out right away
@@ -244,24 +251,56 @@ void tst_QNetworkSession::invalidSession()
QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError);
QVERIFY(session.state() == QNetworkSession::Invalid);
- // Check same thing with a config from platform (there are subtle differences
- // because emtpy configuration does not have private pointer). Test with config
- // in '(un)defined' state
- QList<QNetworkConfiguration> allConfigs = manager.allConfigurations();
- foreach(QNetworkConfiguration config, allConfigs) {
- if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) {
- QNetworkSession session2(config);
- QSignalSpy errorSpy2(&session2, SIGNAL(error(QNetworkSession::SessionError)));
- session2.open();
- session2.waitForOpened(1000); // Should bail out right away
- QVERIFY(errorSpy2.count() == 1);
- QNetworkSession::SessionError error2 =
- qvariant_cast<QNetworkSession::SessionError> (errorSpy2.first().at(0));
- QVERIFY(error2 == QNetworkSession::InvalidConfigurationError);
- QVERIFY(session2.state() == QNetworkSession::Invalid);
- break; // Once is enough
- }
+#ifdef QNETWORKSESSION_MANUAL_TESTS
+ QNetworkConfiguration definedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint);
+ if (definedConfig.isValid()) {
+ // 3. Verify that opening a session with defined configuration emits error and enters notavailable-state
+ // TODO these timer waits should be changed to waiting appropriate signals, now these wait excessively
+ qDebug() << "Shutdown WLAN IAP (waiting 60 seconds): " << definedConfig.name();
+ QTest::qWait(60000);
+ // Shutting down WLAN should bring back to defined -state.
+ QVERIFY((definedConfig.state() & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined);
+ QNetworkSession definedSession(definedConfig);
+ QSignalSpy errorSpy(&definedSession, SIGNAL(error(QNetworkSession::SessionError)));
+ QNetworkSession::SessionError sessionError;
+
+ definedSession.open();
+
+ QVERIFY(definedConfig.isValid()); // Session remains valid
+ QVERIFY(definedSession.state() == QNetworkSession::NotAvailable); // State is not available because WLAN is not in coverage
+ QVERIFY(!errorSpy.isEmpty()); // Session tells with error about invalidated configuration
+ sessionError = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0));
+ qDebug() << "Error code is: " << sessionError;
+ QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError);
+
+ qDebug() << "Turn the WLAN IAP back on (waiting 60 seconds): " << definedConfig.name();
+ QTest::qWait(60000);
+ updateConfigurations();
+
+ QVERIFY(definedConfig.state() == QNetworkConfiguration::Discovered);
}
+
+ QNetworkConfiguration invalidatedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint);
+ if (invalidatedConfig.isValid()) {
+ // 4. Verify that invalidating a session after its successfully configured works
+ QNetworkSession invalidatedSession(invalidatedConfig);
+ QSignalSpy errorSpy(&invalidatedSession, SIGNAL(error(QNetworkSession::SessionError)));
+ QNetworkSession::SessionError sessionError;
+
+ qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name();
+ QTest::qWait(60000);
+
+ invalidatedSession.open();
+ QVERIFY(!invalidatedConfig.isValid());
+ QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid);
+ QVERIFY(!errorSpy.isEmpty());
+
+ sessionError = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0));
+ QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError);
+ qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name();
+ QTest::qWait(60000);
+ }
+#endif
}
void tst_QNetworkSession::sessionProperties_data()
@@ -382,7 +421,6 @@ void tst_QNetworkSession::repeatedOpenClose() {
}
void tst_QNetworkSession::roamingErrorCodes() {
-
#ifndef Q_OS_SYMBIAN
QSKIP("Roaming supported on Symbian.", SkipAll);
#else
@@ -410,8 +448,9 @@ void tst_QNetworkSession::roamingErrorCodes() {
QVERIFY(iapSession.state() == QNetworkSession::Disconnected);
QVERIFY(adminIapSession.state() == QNetworkSession::Disconnected);
#endif // Q_OS_SYMBIAN
- /*
- // Check for roaming error. Challenging to automate, therefore commented out.
+
+#ifdef QNETWORKSESSION_MANUAL_TESTS
+ // Check for roaming error.
// Case requires that you have controllable WLAN in Internet SNAP (only).
QNetworkConfiguration snapConfig = suitableConfiguration("bearer_not_relevant_with_snaps", QNetworkConfiguration::ServiceNetwork);
if (!snapConfig.isValid()) {
@@ -439,7 +478,144 @@ void tst_QNetworkSession::roamingErrorCodes() {
error = qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0));
QVERIFY(error == QNetworkSession::SessionAbortedError);
QVERIFY(iapSession2.state() == QNetworkSession::Disconnected);
- */
+#endif
+}
+
+
+void tst_QNetworkSession::sessionStop_data() {
+ QTest::addColumn<QString>("bearerType");
+ QTest::addColumn<QNetworkConfiguration::Type>("configurationType");
+
+ QTest::newRow("SNAP") << "bearer_type_not_relevant_with_SNAPs" << QNetworkConfiguration::ServiceNetwork;
+ QTest::newRow("WLAN_IAP") << "WLAN" << QNetworkConfiguration::InternetAccessPoint;
+ QTest::newRow("Cellular_IAP") << "cellular" << QNetworkConfiguration::InternetAccessPoint;
+}
+
+void tst_QNetworkSession::sessionStop()
+{
+#ifndef Q_OS_SYMBIAN
+ QSKIP("Testcase contains mainly Symbian specific checks, because it is only platform to really support interface (IAP-level) Stop.", SkipAll);
+#endif
+ QFETCH(QString, bearerType);
+ QFETCH(QNetworkConfiguration::Type, configurationType);
+
+ int configWaitdelayInMs = 2000;
+
+ QNetworkConfiguration config = suitableConfiguration(bearerType, configurationType);
+ if (!config.isValid()) {
+ QSKIP("No suitable configurations, skipping this round of session stop test.", SkipSingle);
+ }
+ qDebug() << "Using following configuration to open and stop a session: " << config.name();
+
+ QNetworkSession openedSession(config);
+ QNetworkSession closedSession(config);
+ QNetworkSession innocentSession(config);
+ QNetworkConfigurationManager mgr;
+
+ QSignalSpy closedSessionOpenedSpy(&closedSession, SIGNAL(opened()));
+ QSignalSpy closedSessionClosedSpy(&closedSession, SIGNAL(closed()));
+ QSignalSpy closedSessionStateChangedSpy(&closedSession, SIGNAL(stateChanged(QNetworkSession::State)));
+ QSignalSpy closedErrorSpy(&closedSession, SIGNAL(error(QNetworkSession::SessionError)));
+
+ QSignalSpy innocentSessionClosedSpy(&innocentSession, SIGNAL(closed()));
+ QSignalSpy innocentSessionStateChangedSpy(&innocentSession, SIGNAL(stateChanged(QNetworkSession::State)));
+ QSignalSpy innocentErrorSpy(&innocentSession, SIGNAL(error(QNetworkSession::SessionError)));
+ QNetworkSession::SessionError sessionError;
+
+ // 1. Verify that stopping an opened session works (the simplest usecase).
+ qDebug("----------1. Verify that stopping an opened session works (the simplest usecase)");
+ QSignalSpy configChangeSpy(&mgr, SIGNAL(configurationChanged(QNetworkConfiguration)));
+ QVERIFY(openSession(&openedSession));
+ qDebug("Waiting for %d ms to get all configurationChange signals from platform.", configWaitdelayInMs);
+ // Clear signals caused by opening
+ closedSessionOpenedSpy.clear();
+ closedSessionClosedSpy.clear();
+ closedSessionStateChangedSpy.clear();
+ closedErrorSpy.clear();
+ openedSession.stop();
+
+ QVERIFY(openedSession.state() == QNetworkSession::Disconnected);
+ QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals
+ QVERIFY(config.state() != QNetworkConfiguration::Active);
+
+ // 2. Verify that stopping a session based on non-connected configuration does nothing
+ qDebug("----------2. Verify that stopping a session based on non-connected configuration does nothing");
+ QNetworkSession::State closedSessionOriginalState = closedSession.state();
+ // Clear all possible signals
+ configChangeSpy.clear();
+ closedSessionOpenedSpy.clear();
+ closedSessionClosedSpy.clear();
+ closedSessionStateChangedSpy.clear();
+ closedErrorSpy.clear();
+
+ closedSession.stop();
+ qDebug("Waiting for %d ms to get all configurationChange signals from platform.", configWaitdelayInMs);
+ QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals
+
+ QVERIFY(closedSessionOpenedSpy.isEmpty());
+ QVERIFY(closedSessionClosedSpy.isEmpty());
+ QVERIFY(closedSessionStateChangedSpy.isEmpty());
+ QVERIFY(closedErrorSpy.isEmpty());
+ QVERIFY(closedSession.state() == closedSessionOriginalState); // State remains
+
+ // 3. Check that stopping a opened session affects also other opened session based on the same configuration.
+ if (config.type() == QNetworkConfiguration::InternetAccessPoint) {
+ qDebug("----------3. Check that stopping a opened session affects also other opened session based on the same configuration.");
+ QVERIFY(openSession(&openedSession));
+ QVERIFY(openSession(&innocentSession));
+
+ configChangeSpy.clear();
+ innocentSessionClosedSpy.clear();
+ innocentSessionStateChangedSpy.clear();
+ innocentErrorSpy.clear();
+
+ openedSession.stop();
+ qDebug("Waiting for %d ms to get all configurationChange signals from platform.", configWaitdelayInMs);
+ QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals
+
+ QVERIFY(!innocentSessionClosedSpy.isEmpty());
+ QVERIFY(!innocentSessionStateChangedSpy.isEmpty());
+ QVERIFY(!innocentErrorSpy.isEmpty());
+ QVERIFY(innocentSession.state() == QNetworkSession::Disconnected);
+ QVERIFY(openedSession.state() == QNetworkSession::Disconnected);
+ sessionError = qvariant_cast<QNetworkSession::SessionError>(innocentErrorSpy.first().at(0));
+ QVERIFY(sessionError == QNetworkSession::SessionAbortedError);
+
+ innocentSessionClosedSpy.clear();
+ innocentSessionStateChangedSpy.clear();
+ innocentErrorSpy.clear();
+ } else {
+ qDebug("----------3. Skip for SNAP configuration.");
+ }
+ // 4. Check that stopping a non-opened session stops the other session based on the
+ // same configuration if configuration is IAP. Stopping closed SNAP session has no impact on other opened SNAP session.
+ if (config.type() == QNetworkConfiguration::ServiceNetwork) {
+ qDebug("----------4. Skip for SNAP configuration.");
+ } else if (config.type() == QNetworkConfiguration::InternetAccessPoint) {
+ qDebug("----------4. Check that stopping a non-opened session stops the other session based on the same configuration");
+ QVERIFY(openSession(&innocentSession));
+ qDebug("Waiting for %d ms after open to make sure all platform indications are propagated", configWaitdelayInMs);
+ QTest::qWait(configWaitdelayInMs);
+ closedSession.stop();
+ qDebug("Waiting for %d ms to get all configurationChange signals from platform..", configWaitdelayInMs);
+ QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals
+
+ QVERIFY(!innocentSessionClosedSpy.isEmpty());
+ QVERIFY(!innocentSessionStateChangedSpy.isEmpty());
+ QVERIFY(!innocentErrorSpy.isEmpty());
+ QVERIFY(innocentSession.state() == QNetworkSession::Disconnected);
+ QVERIFY(closedSession.state() == QNetworkSession::Disconnected);
+ sessionError = qvariant_cast<QNetworkSession::SessionError>(innocentErrorSpy.first().at(0));
+ QVERIFY(sessionError == QNetworkSession::SessionAbortedError);
+ QVERIFY(config.state() == QNetworkConfiguration::Discovered);
+ }
+
+ // 5. Sanity check that stopping invalid session does not crash
+ qDebug("----------5. Sanity check that stopping invalid session does not crash");
+ QNetworkSession invalidSession(QNetworkConfiguration(), 0);
+ QVERIFY(invalidSession.state() == QNetworkSession::Invalid);
+ invalidSession.stop();
+ QVERIFY(invalidSession.state() == QNetworkSession::Invalid);
}
void tst_QNetworkSession::userChoiceSession_data()
@@ -796,14 +972,13 @@ void tst_QNetworkSession::sessionOpenCloseStop()
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(0).at(0));
if (state == QNetworkSession::Roaming) {
QTRY_VERIFY(!errorSpy.isEmpty() || stateChangedSpy.count() > 1);
- if (stateChangedSpy.count() > 1) {
- state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(1).at(0));
- if (state == QNetworkSession::Connected) {
- roamedSuccessfully = true;
- QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected);
- }
+ if (stateChangedSpy.count() > 1 &&
+ qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(1).at(0)) ==
+ QNetworkSession::Connected) {
+ roamedSuccessfully = true;
}
}
+
if (roamedSuccessfully) {
QString configId = session.sessionProperty("ActiveConfiguration").toString();
QNetworkConfiguration config = manager.configurationFromIdentifier(configId);
@@ -838,8 +1013,9 @@ void tst_QNetworkSession::sessionOpenCloseStop()
}
QTRY_VERIFY(!sessionClosedSpy.isEmpty());
- QVERIFY(session.state() == QNetworkSession::Disconnected);
- QVERIFY(session2.state() == QNetworkSession::Disconnected);
+
+ QTRY_VERIFY(session.state() == QNetworkSession::Disconnected);
+ QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected);
}
QVERIFY(errorSpy2.isEmpty());
@@ -1059,6 +1235,7 @@ void tst_QNetworkSession::outOfProcessSession()
// Ignores configurations in other than 'discovered' -state. Returns invalid (QNetworkConfiguration())
// if none found.
QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfiguration::Type configType) {
+
// Refresh configurations and derive configurations matching given parameters.
QNetworkConfigurationManager mgr;
QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted()));
@@ -1099,6 +1276,15 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur
}
}
+// A convinience-function: updates configurations and waits that they are updated.
+void updateConfigurations()
+{
+ QNetworkConfigurationManager mgr;
+ QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted()));
+ mgr.updateConfigurations();
+ QTRY_NOOP(updateSpy.count() == 1);
+}
+
// A convinience function for test-cases: opens the given configuration and return
// true if it was done gracefully.
bool openSession(QNetworkSession *session) {
@@ -1198,8 +1384,8 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) {
return false;
}
if (lastSessionOnConfiguration &&
- session->configuration().state() != QNetworkConfiguration::Discovered) {
- qDebug("tst_QNetworkSession::closeSession() failure: session's configuration is not back in 'Discovered' -state.");
+ session->configuration().state() == QNetworkConfiguration::Active) {
+ qDebug("tst_QNetworkSession::closeSession() failure: session's configuration is still in active state.");
return false;
}
return true;
@@ -1270,4 +1456,3 @@ void tst_QNetworkSession::sessionAutoClose()
QTEST_MAIN(tst_QNetworkSession)
#include "tst_qnetworksession.moc"
-
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 0161a68..8da3484 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -128,6 +128,7 @@ private slots:
void isSignalConnected();
void qMetaObjectConnect();
void qMetaObjectDisconnectOne();
+ void sameName();
protected:
};
@@ -162,7 +163,7 @@ class SenderObject : public QObject
Q_OBJECT
public:
- SenderObject() : recursionCount(0) {}
+ SenderObject() : aPublicSlotCalled(0), recursionCount(0) {}
void emitSignal1AfterRecursion()
{
@@ -185,11 +186,12 @@ signals:
QT_MOC_COMPAT void signal5();
public slots:
- void aPublicSlot(){}
+ void aPublicSlot() { aPublicSlotCalled++; }
public:
Q_INVOKABLE void invoke1(){}
Q_SCRIPTABLE void sinvoke1(){}
+ int aPublicSlotCalled;
protected:
Q_INVOKABLE QT_MOC_COMPAT void invoke2(){}
Q_INVOKABLE QT_MOC_COMPAT void invoke2(int){}
@@ -429,12 +431,14 @@ public:
public slots:
void on_Sender_signalNoParams() { ++called_slot1; }
- void on_Sender_signalWithParams(int i = 0) { ++called_slot2; }
- void on_Sender_signalWithParams(int i, QString string) { ++called_slot3; }
+ void on_Sender_signalWithParams(int i = 0) { ++called_slot2; Q_UNUSED(i); }
+ void on_Sender_signalWithParams(int i, QString string) { ++called_slot3; Q_UNUSED(i);Q_UNUSED(string); }
void on_Sender_signalManyParams() { ++called_slot4; }
- void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff) { ++called_slot5; }
- void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff, bool dummy) { ++called_slot6; }
- void on_Sender_signalManyParams2(int i1, int i2, int i3, QString string, bool onoff) { ++called_slot7; }
+ void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff) { ++called_slot5; Q_UNUSED(i1);Q_UNUSED(i2);Q_UNUSED(i3);Q_UNUSED(string);Q_UNUSED(onoff); }
+ void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff, bool dummy)
+ { ++called_slot6; Q_UNUSED(i1);Q_UNUSED(i2);Q_UNUSED(i3);Q_UNUSED(string);Q_UNUSED(onoff); Q_UNUSED(dummy);}
+ void on_Sender_signalManyParams2(int i1, int i2, int i3, QString string, bool onoff)
+ { ++called_slot7; Q_UNUSED(i1);Q_UNUSED(i2);Q_UNUSED(i3);Q_UNUSED(string);Q_UNUSED(onoff); }
void slotLoopBack() { ++called_slot8; }
protected slots:
@@ -2090,21 +2094,21 @@ public slots:
void constUintPointerSlot(const uint *) { }
void constUlongPointerSlot(const ulong *) { }
- void structSlot(Struct s) { }
- void classSlot(Class c) { }
- void enumSlot(Enum e) { }
+ void structSlot(Struct s) { Q_UNUSED(s); }
+ void classSlot(Class c) { Q_UNUSED(c); }
+ void enumSlot(Enum e) { Q_UNUSED(e); }
- void structPointerSlot(Struct *s) { }
- void classPointerSlot(Class *c) { }
- void enumPointerSlot(Enum *e) { }
+ void structPointerSlot(Struct *s) { Q_UNUSED(s); }
+ void classPointerSlot(Class *c) { Q_UNUSED(c); }
+ void enumPointerSlot(Enum *e) { Q_UNUSED(e); }
- void constStructPointerSlot(const Struct *s) { }
- void constClassPointerSlot(const Class *c) { }
- void constEnumPointerSlot(const Enum *e) { }
+ void constStructPointerSlot(const Struct *s) { Q_UNUSED(s); }
+ void constClassPointerSlot(const Class *c) { Q_UNUSED(c); }
+ void constEnumPointerSlot(const Enum *e) { Q_UNUSED(e); }
- void constStructPointerConstPointerSlot(const Struct * const *s) { }
- void constClassPointerConstPointerSlot(const Class * const *c) { }
- void constEnumPointerConstPointerSlot(const Enum * const *e) { }
+ void constStructPointerConstPointerSlot(const Struct * const *s) { Q_UNUSED(s); }
+ void constClassPointerConstPointerSlot(const Class * const *c) { Q_UNUSED(c); }
+ void constEnumPointerConstPointerSlot(const Enum * const *e) { Q_UNUSED(e); }
void uintSlot(uint) {};
void unsignedintSlot(unsigned int) {};
@@ -3550,5 +3554,41 @@ void tst_QObject::qMetaObjectDisconnectOne()
delete r1;
}
+class ConfusingObject : public SenderObject
+{ Q_OBJECT
+public slots:
+ void signal1() { s++; }
+signals:
+ void aPublicSlot();
+public:
+ int s;
+ ConfusingObject() : s(0) {}
+ friend class tst_QObject;
+};
+
+void tst_QObject::sameName()
+{
+ ConfusingObject c1, c2;
+ QVERIFY(connect(&c1, SIGNAL(signal1()), &c1, SLOT(signal1())));
+ c1.emitSignal1();
+ QCOMPARE(c1.s, 1);
+
+ QVERIFY(connect(&c2, SIGNAL(signal1()), &c1, SIGNAL(signal1())));
+ c2.emitSignal1();
+ QCOMPARE(c1.s, 2);
+
+ QVERIFY(connect(&c2, SIGNAL(aPublicSlot()), &c1, SLOT(signal1())));
+ c2.aPublicSlot();
+ QCOMPARE(c2.aPublicSlotCalled, 0);
+ QCOMPARE(c1.aPublicSlotCalled, 0);
+ QCOMPARE(c1.s, 3);
+
+ QVERIFY(connect(&c2, SIGNAL(aPublicSlot()), &c1, SLOT(aPublicSlot())));
+ c2.aPublicSlot();
+ QCOMPARE(c2.aPublicSlotCalled, 0);
+ QCOMPARE(c1.aPublicSlotCalled, 1);
+ QCOMPARE(c1.s, 4);
+}
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
index b4ce561..c1496f7 100644
--- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -533,6 +533,7 @@ private slots:
void objectDeleted();
void connectToDestroyedSignal();
void emitAfterReceiverDeleted();
+ void inheritedSlots();
private:
QScriptEngine *m_engine;
@@ -2658,6 +2659,21 @@ void tst_QScriptExtQObject::enumerate_data()
<< "mySignal()"
// slots
<< "mySlot()" << "myOtherSlot()");
+
+ QTest::newRow( "don't enumerate slots" )
+ << int(QScriptEngine::ExcludeSlots)
+ << (QStringList()
+ // meta-object-defined properties:
+ // inherited
+ << "objectName"
+ // non-inherited
+ << "p1" << "p2" << "p4" << "p6"
+ // dynamic properties
+ << "dp1" << "dp2" << "dp3"
+ // inherited signals
+ << "destroyed(QObject*)" << "destroyed()"
+ // signals
+ << "mySignal()");
}
void tst_QScriptExtQObject::enumerate()
@@ -2850,6 +2866,28 @@ void tst_QScriptExtQObject::wrapOptions()
QVERIFY(obj.property("intProperty").isValid());
QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
}
+ // exclude slots
+ {
+ QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
+ QScriptEngine::ExcludeSlots);
+ QVERIFY(!obj.property("deleteLater").isValid());
+ QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
+ QVERIFY(!obj.property("mySlot").isValid());
+ QVERIFY(!(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember));
+
+ QVERIFY(obj.property("myInvokable").isFunction());
+ QVERIFY(obj.propertyFlags("myInvokable") & QScriptValue::QObjectMember);
+
+ QVERIFY(obj.property("mySignal").isFunction());
+ QVERIFY(obj.propertyFlags("mySignal") & QScriptValue::QObjectMember);
+ QVERIFY(obj.property("destroyed").isFunction());
+ QVERIFY(obj.propertyFlags("destroyed") & QScriptValue::QObjectMember);
+
+ QVERIFY(obj.property("objectName").isValid());
+ QVERIFY(obj.propertyFlags("objectName") & QScriptValue::QObjectMember);
+ QVERIFY(obj.property("intProperty").isValid());
+ QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
+ }
// exclude all that we can
{
QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
@@ -2871,6 +2909,33 @@ void tst_QScriptExtQObject::wrapOptions()
QCOMPARE(obj.property("child")
.strictlyEquals(QScriptValue(m_engine, 123)), true);
}
+ // exclude absolutely all that we can
+ {
+ QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
+ QScriptEngine::ExcludeSuperClassMethods
+ | QScriptEngine::ExcludeSuperClassProperties
+ | QScriptEngine::ExcludeChildObjects
+ | QScriptEngine::ExcludeSlots);
+ QVERIFY(!obj.property("deleteLater").isValid());
+ QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
+
+ QVERIFY(!obj.property("mySlot").isValid());
+ QVERIFY(!(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember));
+
+ QVERIFY(obj.property("mySignal").isFunction());
+ QVERIFY(obj.propertyFlags("mySignal") & QScriptValue::QObjectMember);
+
+ QVERIFY(obj.property("myInvokable").isFunction());
+ QVERIFY(obj.propertyFlags("myInvokable") & QScriptValue::QObjectMember);
+
+ QVERIFY(!obj.property("objectName").isValid());
+ QVERIFY(!(obj.propertyFlags("objectName") & QScriptValue::QObjectMember));
+
+ QVERIFY(obj.property("intProperty").isValid());
+ QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
+
+ QVERIFY(!obj.property("child").isValid());
+ }
delete child;
}
@@ -3043,5 +3108,27 @@ void tst_QScriptExtQObject::emitAfterReceiverDeleted()
}
}
+void tst_QScriptExtQObject::inheritedSlots()
+{
+ QScriptEngine eng;
+
+ QPushButton prototypeButton;
+ QScriptValue scriptPrototypeButton = eng.newQObject(&prototypeButton);
+
+ QPushButton button;
+ QScriptValue scriptButton = eng.newQObject(&button, QScriptEngine::QtOwnership,
+ QScriptEngine::ExcludeSlots);
+ scriptButton.setPrototype(scriptPrototypeButton);
+
+ QVERIFY(scriptButton.property("click").isFunction());
+ QVERIFY(scriptButton.property("click").strictlyEquals(scriptPrototypeButton.property("click")));
+
+ QSignalSpy prototypeButtonClickedSpy(&prototypeButton, SIGNAL(clicked()));
+ QSignalSpy buttonClickedSpy(&button, SIGNAL(clicked()));
+ scriptButton.property("click").call(scriptButton);
+ QCOMPARE(buttonClickedSpy.count(), 1);
+ QCOMPARE(prototypeButtonClickedSpy.count(), 0);
+}
+
QTEST_MAIN(tst_QScriptExtQObject)
#include "tst_qscriptextqobject.moc"
diff --git a/tests/auto/qshortcut/tst_qshortcut.cpp b/tests/auto/qshortcut/tst_qshortcut.cpp
index 39518c5..6df4cc4 100644
--- a/tests/auto/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/qshortcut/tst_qshortcut.cpp
@@ -224,10 +224,10 @@ void tst_QShortcut::initTestCase()
mainW->setFixedSize( 100, 100 );
mainW->setCentralWidget( edit );
mainW->show();
- mainW->activateWindow();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(mainW);
#endif
+ mainW->activateWindow();
QTest::qWait(100);
connect( mainW->statusBar(), SIGNAL(messageChanged(const QString&)),
this, SLOT(statusMessage(const QString&)) );
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index d79ebb9..1bea4b7 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -938,6 +938,11 @@ void tst_QString::sprintf()
// Check utf8 conversion for %s
QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString("\366\344\374\326\304\334\370\346\345\330\306\305"));
+ // Check codecForCStrings is used to read non-modifier sequences in the format string
+ QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+ QCOMPARE(a.sprintf("\303\251\303\250\303\240 %s", "\303\251\303\250\303\240"), QString("\303\251\303\250\303\240 \303\251\303\250\303\240"));
+ QTextCodec::setCodecForCStrings(0);
+
int n1;
a.sprintf("%s%n%s", "hello", &n1, "goodbye");
QCOMPARE(n1, 5);
diff --git a/tests/auto/qtranslator/qtranslator.pro b/tests/auto/qtranslator/qtranslator.pro
index 30ffc1c..2b08b4a 100644
--- a/tests/auto/qtranslator/qtranslator.pro
+++ b/tests/auto/qtranslator/qtranslator.pro
@@ -1,6 +1,6 @@
load(qttest_p4)
SOURCES += tst_qtranslator.cpp
-
+RESOURCES += qtranslator.qrc
wince*|symbian*: {
addFiles.sources = hellotr_la.qm msgfmt_from_po.qm
diff --git a/tests/auto/qtranslator/qtranslator.qrc b/tests/auto/qtranslator/qtranslator.qrc
new file mode 100644
index 0000000..333dcfa
--- /dev/null
+++ b/tests/auto/qtranslator/qtranslator.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/tst_qtranslator">
+ <file>hellotr_la.qm</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/qtranslator/tst_qtranslator.cpp b/tests/auto/qtranslator/tst_qtranslator.cpp
index 44fc10c..f2bfbf0 100644
--- a/tests/auto/qtranslator/tst_qtranslator.cpp
+++ b/tests/auto/qtranslator/tst_qtranslator.cpp
@@ -70,6 +70,8 @@ private slots:
void testLanguageChange();
void plural();
void translate_qm_file_generated_with_msgfmt();
+ void loadFromResource();
+ void loadDirectory();
private:
int languageChangeEventCounter;
@@ -237,5 +239,22 @@ void tst_QTranslator::translate_qm_file_generated_with_msgfmt()
qApp->removeTranslator(&translator);
}
+void tst_QTranslator::loadFromResource()
+{
+ QTranslator tor;
+ tor.load(":/tst_qtranslator/hellotr_la.qm");
+ QVERIFY(!tor.isEmpty());
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+}
+
+void tst_QTranslator::loadDirectory()
+{
+ QVERIFY(QFileInfo("../qtranslator").isDir());
+
+ QTranslator tor;
+ tor.load("qtranslator", "..");
+ QVERIFY(tor.isEmpty());
+}
+
QTEST_MAIN(tst_QTranslator)
#include "tst_qtranslator.moc"
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp
index b9a1b0e..4bc7027 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp
@@ -363,8 +363,9 @@ void BookmarkManager::refeshBookmarkMenu()
bookmarkMenu->addAction(tr("Manage Bookmarks..."), this,
SLOT(manageBookmarks()));
- bookmarkMenu->addAction(tr("Add Bookmark..."), this, SLOT(addBookmark()),
- QKeySequence(tr("Ctrl+D")));
+ bookmarkMenu->addAction(QIcon::fromTheme("bookmark-new"),
+ tr("Add Bookmark..."), this, SLOT(addBookmark()),
+ QKeySequence(tr("Ctrl+D")));
bookmarkMenu->addSeparator();
const QModelIndex &root = bookmarkModel->index(0, 0, QModelIndex());
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index c403aa7..913e342 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -409,6 +409,11 @@ void MainWindow::setupActions()
QMenu *menu = menuBar()->addMenu(tr("&File"));
+ m_newTabAction = menu->addAction(tr("New &Tab"), m_centralWidget, SLOT(newTab()));
+ m_newTabAction->setShortcut(QKeySequence::AddTab);
+
+ menu->addSeparator();
+
m_pageSetupAction = menu->addAction(tr("Page Set&up..."), m_centralWidget,
SLOT(pageSetup()));
m_printPreviewAction = menu->addAction(tr("Print Preview..."), m_centralWidget,
@@ -421,14 +426,12 @@ void MainWindow::setupActions()
menu->addSeparator();
- m_newTabAction = menu->addAction(tr("New &Tab"), m_centralWidget, SLOT(newTab()));
- m_newTabAction->setShortcut(QKeySequence::AddTab);
-
m_closeTabAction = menu->addAction(tr("&Close Tab"), m_centralWidget,
SLOT(closeTab()));
m_closeTabAction->setShortcuts(QKeySequence::Close);
- QAction *tmp = menu->addAction(tr("&Quit"), this, SLOT(close()));
+ QAction *tmp = menu->addAction(QIcon::fromTheme("application-exit"),
+ tr("&Quit"), this, SLOT(close()));
tmp->setMenuRole(QAction::QuitRole);
#ifdef Q_OS_WIN
tmp->setShortcut(QKeySequence(tr("CTRL+Q")));
@@ -532,6 +535,8 @@ void MainWindow::setupActions()
m_aboutAction->setMenuRole(QAction::AboutRole);
#ifdef Q_WS_X11
+ m_newTabAction->setIcon(QIcon::fromTheme("tab-new", m_newTabAction->icon()));
+ m_closeTabAction->setIcon(QIcon::fromTheme("window-close", m_closeTabAction->icon()));
m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon()));
m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon()));
m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon()));
@@ -541,7 +546,10 @@ void MainWindow::setupActions()
m_copyAction->setIcon(QIcon::fromTheme("edit-copy" , m_copyAction->icon()));
m_findAction->setIcon(QIcon::fromTheme("edit-find" , m_findAction->icon()));
m_homeAction->setIcon(QIcon::fromTheme("go-home" , m_homeAction->icon()));
+ m_pageSetupAction->setIcon(QIcon::fromTheme("document-page-setup", m_pageSetupAction->icon()));
+ m_printPreviewAction->setIcon(QIcon::fromTheme("document-print-preview", m_printPreviewAction->icon()));
m_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->icon()));
+ m_aboutAction->setIcon(QIcon::fromTheme("help-about", m_aboutAction->icon()));
#endif
QToolBar *navigationBar = addToolBar(tr("Navigation Toolbar"));
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 0aca545..0b14cba 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -1886,7 +1886,7 @@ bool Configure::findFile( const QString &fileName )
const QString file = fileName.toLower();
const QString pathEnvVar = QString::fromLocal8Bit(getenv("PATH"));
const QString mingwPath = dictionary["QMAKESPEC"].endsWith("-g++") ?
- findFileInPaths("mingw32-g++.exe", pathEnvVar) : QString();
+ findFileInPaths("g++.exe", pathEnvVar) : QString();
QString paths;
if (file.endsWith(".h")) {
@@ -1978,7 +1978,7 @@ bool Configure::checkAvailability(const QString &part)
{
bool available = false;
if (part == "STYLE_WINDOWSXP")
- available = (findFile("uxtheme.h"));
+ available = findFile("uxtheme.h");
else if (part == "ZLIB")
available = findFile("zlib.h");
@@ -3508,14 +3508,15 @@ void Configure::buildQmake()
args += makefile;
cout << "Creating qmake..." << endl;
- int exitCode = 0;
- if( exitCode = Environment::execute(args, QStringList(), QStringList()) ) {
+ int exitCode = Environment::execute(args, QStringList(), QStringList());
+ if( exitCode ) {
args.clear();
args += dictionary[ "MAKE" ];
args += "-f";
args += makefile;
args += "clean";
- if( exitCode = Environment::execute(args, QStringList(), QStringList())) {
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if(exitCode) {
cout << "Cleaning qmake failed, return code " << exitCode << endl << endl;
dictionary[ "DONE" ] = "error";
} else {
@@ -3523,7 +3524,8 @@ void Configure::buildQmake()
args += dictionary[ "MAKE" ];
args += "-f";
args += makefile;
- if (exitCode = Environment::execute(args, QStringList(), QStringList())) {
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
cout << "Building qmake failed, return code " << exitCode << endl << endl;
dictionary[ "DONE" ] = "error";
}
@@ -3567,8 +3569,8 @@ void Configure::buildHostTools()
QDir().mkpath(toolBuildPath);
QDir::setCurrent(toolSourcePath);
- int exitCode = 0;
- if (exitCode = Environment::execute(args, QStringList(), QStringList())) {
+ int exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
cout << "qmake failed, return code " << exitCode << endl << endl;
dictionary["DONE"] = "error";
break;
@@ -3578,18 +3580,21 @@ void Configure::buildHostTools()
args.clear();
args += dictionary["MAKE"];
QDir::setCurrent(toolBuildPath);
- if (exitCode = Environment::execute(args, QStringList(), QStringList())) {
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
args.clear();
args += dictionary["MAKE"];
args += "clean";
- if(exitCode = Environment::execute(args, QStringList(), QStringList())) {
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if(exitCode) {
cout << "Cleaning " << hostToolsDirs.at(i) << " failed, return code " << exitCode << endl << endl;
dictionary["DONE"] = "error";
break;
} else {
args.clear();
args += dictionary["MAKE"];
- if (exitCode = Environment::execute(args, QStringList(), QStringList())) {
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
cout << "Building " << hostToolsDirs.at(i) << " failed, return code " << exitCode << endl << endl;
dictionary["DONE"] = "error";
break;
diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp
index e93f9a0..74bebb2 100644
--- a/tools/configure/environment.cpp
+++ b/tools/configure/environment.cpp
@@ -357,7 +357,7 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv
QString args = qt_create_commandline(program, arguments);
QByteArray envlist = qt_create_environment(fullEnv);
- DWORD exitCode = -1;
+ DWORD exitCode = DWORD(-1);
PROCESS_INFORMATION procInfo;
memset(&procInfo, 0, sizeof(procInfo));
@@ -378,7 +378,7 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv
}
- if (exitCode == -1) {
+ if (exitCode == DWORD(-1)) {
switch(GetLastError()) {
case E2BIG:
cerr << "execute: Argument list exceeds 1024 bytes" << endl;
diff --git a/tools/designer/src/components/formeditor/formwindowmanager.cpp b/tools/designer/src/components/formeditor/formwindowmanager.cpp
index 88b4ac5..ce809ff 100644
--- a/tools/designer/src/components/formeditor/formwindowmanager.cpp
+++ b/tools/designer/src/components/formeditor/formwindowmanager.cpp
@@ -523,10 +523,11 @@ void FormWindowManager::setupActions()
connect(m_actionShowFormWindowSettingsDialog, SIGNAL(triggered()), this, SLOT(slotActionShowFormWindowSettingsDialog()));
m_actionShowFormWindowSettingsDialog->setEnabled(false);
-
+#ifdef Q_WS_X11
m_actionCopy->setIcon(QIcon::fromTheme("edit-copy", m_actionCopy->icon()));
m_actionCut->setIcon(QIcon::fromTheme("edit-cut", m_actionCut->icon()));
m_actionPaste->setIcon(QIcon::fromTheme("edit-paste", m_actionPaste->icon()));
+ m_actionDelete->setIcon(QIcon::fromTheme("edit-delete", m_actionDelete->icon()));
// These do not currently exist, but will allow theme authors to fill in the gaps
m_actionBreakLayout->setIcon(QIcon::fromTheme("designer-break-layout", m_actionBreakLayout->icon()));
@@ -536,6 +537,7 @@ void FormWindowManager::setupActions()
m_actionSplitHorizontal->setIcon(QIcon::fromTheme("designer-split-horizontal", m_actionSplitHorizontal->icon()));
m_actionSplitVertical->setIcon(QIcon::fromTheme("designer-split-vertical", m_actionSplitVertical->icon()));
m_actionAdjustSize->setIcon(QIcon::fromTheme("designer-adjust-size", m_actionAdjustSize->icon()));
+#endif
}
void FormWindowManager::slotActionCutActivated()
diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.cpp b/tools/designer/src/components/propertyeditor/propertyeditor.cpp
index 512cc82..86d7bdf 100644
--- a/tools/designer/src/components/propertyeditor/propertyeditor.cpp
+++ b/tools/designer/src/components/propertyeditor/propertyeditor.cpp
@@ -79,6 +79,7 @@
#include <QtGui/QToolButton>
#include <QtGui/QActionGroup>
#include <QtGui/QLabel>
+#include <QtGui/QPainter>
#include <QtCore/QDebug>
#include <QtCore/QTextStream>
@@ -98,6 +99,53 @@ QT_BEGIN_NAMESPACE
// ---------------------------------------------------------------------------------
namespace qdesigner_internal {
+
+// ----------- ElidingLabel
+// QLabel does not support text eliding so we need a helper class
+
+class ElidingLabel : public QWidget
+{
+public:
+ ElidingLabel(const QString &text = QString(), QWidget *parent = 0)
+ : QWidget(parent),
+ m_text(text),
+ m_mode(Qt::ElideRight) {
+ setContentsMargins(3, 2, 3, 2);
+ }
+ QSize sizeHint() const;
+ void paintEvent(QPaintEvent *e);
+ void setText(const QString &text) {
+ m_text = text;
+ updateGeometry();
+ }
+ void setElidemode(Qt::TextElideMode mode) {
+ m_mode = mode;
+ updateGeometry();
+ }
+private:
+ QString m_text;
+ Qt::TextElideMode m_mode;
+};
+
+QSize ElidingLabel::sizeHint() const
+{
+ QSize size = fontMetrics().boundingRect(m_text).size();
+ size += QSize(contentsMargins().left() + contentsMargins().right(),
+ contentsMargins().top() + contentsMargins().bottom());
+ return size;
+}
+
+void ElidingLabel::paintEvent(QPaintEvent *e) {
+ QPainter painter(this);
+ painter.setPen(QColor(0, 0, 0, 60));
+ painter.setBrush(QColor(255, 255, 255, 40));
+ painter.drawRect(rect().adjusted(0, 0, -1, -1));
+ painter.setPen(palette().windowText().color());
+ painter.drawText(contentsRect(), Qt::AlignLeft,
+ fontMetrics().elidedText(m_text, Qt::ElideRight, width(), 0));
+}
+
+
// ----------- PropertyEditor::Strings
PropertyEditor::Strings::Strings() :
@@ -186,7 +234,7 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare
m_coloringAction(new QAction(createIconSet(QLatin1String("color.png")), tr("Color Groups"), this)),
m_treeAction(new QAction(tr("Tree View"), this)),
m_buttonAction(new QAction(tr("Drop Down Button View"), this)),
- m_classLabel(new QLabel),
+ m_classLabel(new ElidingLabel),
m_sorting(false),
m_coloring(false),
m_brightness(false)
@@ -223,11 +271,6 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare
actionGroup->addAction(m_buttonAction);
connect(actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotViewTriggered(QAction*)));
- QWidget *classWidget = new QWidget;
- QHBoxLayout *l = new QHBoxLayout(classWidget);
- l->setContentsMargins(5, 0, 5, 0);
- l->addWidget(m_classLabel);
-
// Add actions
QActionGroup *addDynamicActionGroup = new QActionGroup(this);
connect(addDynamicActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotAddDynamicProperty(QAction*)));
@@ -269,7 +312,6 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare
#endif
// Assemble toolbar
QToolBar *toolBar = new QToolBar;
- toolBar->addWidget(classWidget);
toolBar->addWidget(m_filterWidget);
toolBar->addWidget(createDropDownButton(m_addDynamicAction));
toolBar->addAction(m_removeDynamicAction);
@@ -292,6 +334,8 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(toolBar);
+ layout->addWidget(m_classLabel);
+ layout->addSpacerItem(new QSpacerItem(0,1));
layout->addWidget(m_stackedWidget);
layout->setMargin(0);
layout->setSpacing(0);
@@ -778,9 +822,14 @@ void PropertyEditor::updateToolBarLabel()
className = realClassName(m_object);
}
- QString classLabelText = objectName;
- classLabelText += QLatin1Char('\n');
+ m_classLabel->setVisible(!objectName.isEmpty() || !className.isEmpty());
+ m_classLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+
+ QString classLabelText;
+ if (!objectName.isEmpty())
+ classLabelText += objectName + QLatin1String(" : ");
classLabelText += className;
+
m_classLabel->setText(classLabelText);
m_classLabel->setToolTip(tr("Object: %1\nClass: %2").arg(objectName).arg(className));
}
diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.h b/tools/designer/src/components/propertyeditor/propertyeditor.h
index 5869c94..f0ea94f 100644
--- a/tools/designer/src/components/propertyeditor/propertyeditor.h
+++ b/tools/designer/src/components/propertyeditor/propertyeditor.h
@@ -62,9 +62,7 @@ class QtTreePropertyBrowser;
class QtProperty;
class QtVariantProperty;
class QtBrowserItem;
-
class QStackedWidget;
-class QLabel;
namespace qdesigner_internal {
@@ -72,6 +70,7 @@ class StringProperty;
class DesignerPropertyManager;
class DesignerEditorFactory;
class FilterWidget;
+class ElidingLabel;
class QT_PROPERTYEDITOR_EXPORT PropertyEditor: public QDesignerPropertyEditor
{
@@ -186,7 +185,7 @@ private:
QAction *m_coloringAction;
QAction *m_treeAction;
QAction *m_buttonAction;
- QLabel *m_classLabel;
+ ElidingLabel *m_classLabel;
bool m_sorting;
bool m_coloring;
diff --git a/tools/designer/src/designer/qdesigner_actions.cpp b/tools/designer/src/designer/qdesigner_actions.cpp
index 887ba98..6776351 100644
--- a/tools/designer/src/designer/qdesigner_actions.cpp
+++ b/tools/designer/src/designer/qdesigner_actions.cpp
@@ -200,9 +200,15 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench)
#endif
m_previewManager(0)
{
+#ifdef Q_WS_X11
m_newFormAction->setIcon(QIcon::fromTheme("document-new", m_newFormAction->icon()));
m_openFormAction->setIcon(QIcon::fromTheme("document-open", m_openFormAction->icon()));
m_saveFormAction->setIcon(QIcon::fromTheme("document-save", m_saveFormAction->icon()));
+ m_saveFormAsAction->setIcon(QIcon::fromTheme("document-save-as", m_saveFormAsAction->icon()));
+ m_printPreviewAction->setIcon(QIcon::fromTheme("document-print", m_printPreviewAction->icon()));
+ m_closeFormAction->setIcon(QIcon::fromTheme("window-close", m_closeFormAction->icon()));
+ m_quitAction->setIcon(QIcon::fromTheme("application-exit", m_quitAction->icon()));
+#endif
Q_ASSERT(m_core != 0);
qdesigner_internal::QDesignerFormWindowManager *ifwm = qobject_cast<qdesigner_internal::QDesignerFormWindowManager *>(m_core->formWindowManager());
@@ -490,13 +496,13 @@ QAction *QDesignerActions::createRecentFilesMenu()
}
updateRecentFileActions();
menu->addSeparator();
- act = new QAction(tr("Clear &Menu"), this);
+ act = new QAction(QIcon::fromTheme("edit-clear"), tr("Clear &Menu"), this);
act->setObjectName(QLatin1String("__qt_action_clear_menu_"));
connect(act, SIGNAL(triggered()), this, SLOT(clearRecentFiles()));
m_recentFilesActions->addAction(act);
menu->addAction(act);
- act = new QAction(tr("&Recent Forms"), this);
+ act = new QAction(QIcon::fromTheme("document-open-recent"), tr("&Recent Forms"), this);
act->setMenu(menu);
return act;
}
diff --git a/tools/designer/src/lib/shared/qtresourceview.cpp b/tools/designer/src/lib/shared/qtresourceview.cpp
index 859f239..3c7010c 100644
--- a/tools/designer/src/lib/shared/qtresourceview.cpp
+++ b/tools/designer/src/lib/shared/qtresourceview.cpp
@@ -377,7 +377,8 @@ void QtResourceViewPrivate::createPaths()
if (!m_resourceModel)
return;
- const QString root(QLatin1Char(':'));
+ // Resource root up until 4.6 was ':', changed to ":/" as of 4.7
+ const QString root(QLatin1String(":/"));
QMap<QString, QString> contents = m_resourceModel->contents();
QMapIterator<QString, QString> itContents(contents);
diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp
index 321fe8c..7d73596 100644
--- a/tools/linguist/linguist/mainwindow.cpp
+++ b/tools/linguist/linguist/mainwindow.cpp
@@ -1810,28 +1810,50 @@ QString MainWindow::friendlyString(const QString& str)
return f.simplified();
}
+static inline void setThemeIcon(QAction *action, const char *name, const char *fallback)
+{
+ const QIcon fallbackIcon(MainWindow::resourcePrefix() + QLatin1String(fallback));
+#ifdef Q_WS_X11
+ action->setIcon(QIcon::fromTheme(QLatin1String(name), fallbackIcon));
+#else
+ Q_UNUSED(name)
+ action->setIcon(fallbackIcon);
+#endif
+}
+
void MainWindow::setupMenuBar()
{
+ // There are no fallback icons for these
+#ifdef Q_WS_X11
+ m_ui.menuRecentlyOpenedFiles->setIcon(QIcon::fromTheme(QLatin1String("document-open-recent")));
+ m_ui.actionCloseAll->setIcon(QIcon::fromTheme(QLatin1String("window-close")));
+ m_ui.actionExit->setIcon(QIcon::fromTheme(QLatin1String("application-exit")));
+ m_ui.actionSelectAll->setIcon(QIcon::fromTheme(QLatin1String("edit-select-all")));
+#endif
+
+ // Prefer theme icons when available for these actions
+ setThemeIcon(m_ui.actionOpen, "document-open", "/fileopen.png");
+ setThemeIcon(m_ui.actionOpenAux, "document-open", "/fileopen.png");
+ setThemeIcon(m_ui.actionSave, "document-save", "/filesave.png");
+ setThemeIcon(m_ui.actionSaveAll, "document-save", "/filesave.png");
+ setThemeIcon(m_ui.actionPrint, "document-print", "/print.png");
+ setThemeIcon(m_ui.actionRedo, "edit-redo", "/redo.png");
+ setThemeIcon(m_ui.actionUndo, "edit-undo", "/undo.png");
+ setThemeIcon(m_ui.actionCut, "edit-cut", "/editcut.png");
+ setThemeIcon(m_ui.actionCopy, "edit-copy", "/editcopy.png");
+ setThemeIcon(m_ui.actionPaste, "edit-paste", "/editpaste.png");
+ setThemeIcon(m_ui.actionFind, "edit-find", "/searchfind.png");
+
+ // No well defined theme icons for these actions
m_ui.actionAccelerators->setIcon(QIcon(resourcePrefix() + QLatin1String("/accelerator.png")));
m_ui.actionOpenPhraseBook->setIcon(QIcon(resourcePrefix() + QLatin1String("/book.png")));
m_ui.actionDoneAndNext->setIcon(QIcon(resourcePrefix() + QLatin1String("/doneandnext.png")));
- m_ui.actionCopy->setIcon(QIcon(resourcePrefix() + QLatin1String("/editcopy.png")));
- m_ui.actionCut->setIcon(QIcon(resourcePrefix() + QLatin1String("/editcut.png")));
- m_ui.actionPaste->setIcon(QIcon(resourcePrefix() + QLatin1String("/editpaste.png")));
- m_ui.actionOpen->setIcon(QIcon(resourcePrefix() + QLatin1String("/fileopen.png")));
- m_ui.actionOpenAux->setIcon(QIcon(resourcePrefix() + QLatin1String("/fileopen.png")));
- m_ui.actionSaveAll->setIcon(QIcon(resourcePrefix() + QLatin1String("/filesave.png")));
- m_ui.actionSave->setIcon(QIcon(resourcePrefix() + QLatin1String("/filesave.png")));
m_ui.actionNext->setIcon(QIcon(resourcePrefix() + QLatin1String("/next.png")));
m_ui.actionNextUnfinished->setIcon(QIcon(resourcePrefix() + QLatin1String("/nextunfinished.png")));
m_ui.actionPhraseMatches->setIcon(QIcon(resourcePrefix() + QLatin1String("/phrase.png")));
m_ui.actionEndingPunctuation->setIcon(QIcon(resourcePrefix() + QLatin1String("/punctuation.png")));
m_ui.actionPrev->setIcon(QIcon(resourcePrefix() + QLatin1String("/prev.png")));
m_ui.actionPrevUnfinished->setIcon(QIcon(resourcePrefix() + QLatin1String("/prevunfinished.png")));
- m_ui.actionPrint->setIcon(QIcon(resourcePrefix() + QLatin1String("/print.png")));
- m_ui.actionRedo->setIcon(QIcon(resourcePrefix() + QLatin1String("/redo.png")));
- m_ui.actionFind->setIcon(QIcon(resourcePrefix() + QLatin1String("/searchfind.png")));
- m_ui.actionUndo->setIcon(QIcon(resourcePrefix() + QLatin1String("/undo.png")));
m_ui.actionPlaceMarkerMatches->setIcon(QIcon(resourcePrefix() + QLatin1String("/validateplacemarkers.png")));
m_ui.actionWhatsThis->setIcon(QIcon(resourcePrefix() + QLatin1String("/whatsthis.png")));
diff --git a/tools/qdoc3/helpprojectwriter.cpp b/tools/qdoc3/helpprojectwriter.cpp
index 71810e4..edba097 100644
--- a/tools/qdoc3/helpprojectwriter.cpp
+++ b/tools/qdoc3/helpprojectwriter.cpp
@@ -41,6 +41,7 @@
#include <QHash>
#include <QMap>
+#include <qdebug.h>
#include "atom.h"
#include "helpprojectwriter.h"
@@ -116,6 +117,11 @@ void HelpProjectWriter::readSelectors(SubProject &subproject, const QStringList
typeHash["property"] = Node::Property;
typeHash["variable"] = Node::Variable;
typeHash["target"] = Node::Target;
+#ifdef QDOC_QML
+ typeHash["qmlproperty"] = Node::QmlProperty;
+ typeHash["qmlsignal"] = Node::QmlSignal;
+ typeHash["qmlmethod"] = Node::QmlMethod;
+#endif
QHash<QString, Node::SubType> subTypeHash;
subTypeHash["example"] = Node::Example;
@@ -127,6 +133,8 @@ void HelpProjectWriter::readSelectors(SubProject &subproject, const QStringList
subTypeHash["externalpage"] = Node::ExternalPage;
#ifdef QDOC_QML
subTypeHash["qmlclass"] = Node::QmlClass;
+ subTypeHash["qmlpropertygroup"] = Node::QmlPropertyGroup;
+ subTypeHash["qmlbasictype"] = Node::QmlBasicType;
#endif
QSet<Node::SubType> allSubTypes = QSet<Node::SubType>::fromList(subTypeHash.values());
@@ -176,7 +184,13 @@ QStringList HelpProjectWriter::keywordDetails(const Node *node) const
{
QStringList details;
- if (node->parent() && !node->parent()->name().isEmpty()) {
+ if (node->type() == Node::QmlProperty) {
+ // "name"
+ details << node->name();
+ // "id"
+ details << node->parent()->parent()->name()+"::"+node->name();
+ }
+ else if (node->parent() && !node->parent()->name().isEmpty()) {
// "name"
if (node->type() == Node::Enum || node->type() == Node::Typedef)
details << node->parent()->name()+"::"+node->name();
@@ -184,29 +198,29 @@ QStringList HelpProjectWriter::keywordDetails(const Node *node) const
details << node->name();
// "id"
details << node->parent()->name()+"::"+node->name();
- } else if (node->type() == Node::Fake) {
+ }
+ else if (node->type() == Node::Fake) {
const FakeNode *fake = static_cast<const FakeNode *>(node);
-#ifdef QDOC_QML
if (fake->subType() == Node::QmlClass) {
details << (QmlClassNode::qmlOnly ? fake->name() : fake->fullTitle());
details << "QML." + fake->name();
- } else
-#endif
- {
+ }
+ else {
details << fake->fullTitle();
details << fake->fullTitle();
}
- } else {
+ }
+ else {
details << node->name();
details << node->name();
}
details << tree->fullDocumentLocation(node);
-
return details;
}
bool HelpProjectWriter::generateSection(HelpProject &project,
- QXmlStreamWriter & /* writer */, const Node *node)
+ QXmlStreamWriter & /* writer */,
+ const Node *node)
{
if (!node->url().isEmpty())
return false;
@@ -225,9 +239,10 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
if (node->type() == Node::Fake) {
const FakeNode *fake = static_cast<const FakeNode *>(node);
objName = fake->fullTitle();
- } else
+ }
+ else
objName = tree->fullDocumentName(node);
-
+
// Only add nodes to the set for each subproject if they match a selector.
// Those that match will be listed in the table of contents.
@@ -289,6 +304,9 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
break;
case Node::Property:
+ case Node::QmlProperty:
+ case Node::QmlSignal:
+ case Node::QmlMethod:
project.keywords.append(keywordDetails(node));
break;
@@ -399,7 +417,7 @@ void HelpProjectWriter::generateSections(HelpProject &project,
{
if (!generateSection(project, writer, node))
return;
-
+
if (node->isInnerNode()) {
const InnerNode *inner = static_cast<const InnerNode *>(node);
@@ -408,8 +426,23 @@ void HelpProjectWriter::generateSections(HelpProject &project,
foreach (const Node *node, inner->childNodes()) {
if (node->access() == Node::Private)
continue;
- if (node->type() == Node::Fake)
- childMap[static_cast<const FakeNode *>(node)->fullTitle()] = node;
+ if (node->type() == Node::Fake) {
+ /*
+ Don't visit QML property group nodes,
+ but visit their children, which are all
+ QML property nodes.
+ */
+ if (node->subType() == Node::QmlPropertyGroup) {
+ const InnerNode* inner = static_cast<const InnerNode*>(node);
+ foreach (const Node* n, inner->childNodes()) {
+ if (n->access() == Node::Private)
+ continue;
+ childMap[tree->fullDocumentName(n)] = n;
+ }
+ }
+ else
+ childMap[static_cast<const FakeNode *>(node)->fullTitle()] = node;
+ }
else {
if (node->type() == Node::Function) {
const FunctionNode *funcNode = static_cast<const FunctionNode *>(node);
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index c1e3678..cd3da3e 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -405,7 +405,9 @@ void HtmlGenerator::generateTree(const Tree *tree, CodeMarker *marker)
generateIndex(fileBase, projectUrl, projectDescription);
generatePageIndex(outputDir() + "/" + fileBase + ".pageindex", marker);
+ //qDebug() << "start helpProjectWriter->generate(myTree)";
helpProjectWriter->generate(myTree);
+ //qDebug() << "end helpProjectWriter->generate(myTree)";
}
void HtmlGenerator::startText(const Node * /* relative */,
diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h
index 1017813..215a7ae 100644
--- a/tools/qdoc3/node.h
+++ b/tools/qdoc3/node.h
@@ -163,6 +163,7 @@ class Node
virtual bool isInnerNode() const = 0;
virtual bool isReimp() const { return false; }
virtual bool isFunction() const { return false; }
+ virtual bool isQmlNode() const { return false; }
Type type() const { return typ; }
virtual SubType subType() const { return NoSubType; }
InnerNode *parent() const { return par; }
@@ -380,6 +381,7 @@ class QmlClassNode : public FakeNode
const QString& name,
const ClassNode* cn);
virtual ~QmlClassNode();
+ virtual bool isQmlNode() const { return true; }
const ClassNode* classNode() const { return cnode; }
virtual QString fileBase() const;
@@ -401,6 +403,7 @@ class QmlBasicTypeNode : public FakeNode
QmlBasicTypeNode(InnerNode *parent,
const QString& name);
virtual ~QmlBasicTypeNode() { }
+ virtual bool isQmlNode() const { return true; }
};
class QmlPropGroupNode : public FakeNode
@@ -410,6 +413,7 @@ class QmlPropGroupNode : public FakeNode
const QString& name,
bool attached);
virtual ~QmlPropGroupNode() { }
+ virtual bool isQmlNode() const { return true; }
const QString& element() const { return parent()->name(); }
void setDefault() { isdefault = true; }
@@ -441,6 +445,7 @@ class QmlPropertyNode : public LeafNode
bool isDesignable() const { return fromTrool(des,false); }
bool isWritable() const { return fromTrool(wri,true); }
bool isAttached() const { return att; }
+ virtual bool isQmlNode() const { return true; }
const QString& element() const { return static_cast<QmlPropGroupNode*>(parent())->element(); }
@@ -609,6 +614,9 @@ class FunctionNode : public LeafNode
QString signature(bool values = false) const;
const QString& element() const { return parent()->name(); }
bool isAttached() const { return att; }
+ virtual bool isQmlNode() const {
+ return ((type() == QmlSignal) || (type() == QmlMethod));
+ }
void debug() const;
diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp
index 7dcc8c3..31bbf54 100644
--- a/tools/qdoc3/tree.cpp
+++ b/tools/qdoc3/tree.cpp
@@ -1121,6 +1121,15 @@ bool Tree::generateIndexSection(QXmlStreamWriter &writer,
case Node::Target:
nodeName = "target";
break;
+ case Node::QmlProperty:
+ nodeName = "qmlproperty";
+ break;
+ case Node::QmlSignal:
+ nodeName = "qmlsignal";
+ break;
+ case Node::QmlMethod:
+ nodeName = "qmlmethod";
+ break;
default:
return false;
}
@@ -1210,7 +1219,7 @@ bool Tree::generateIndexSection(QXmlStreamWriter &writer,
if (fullName != objName)
writer.writeAttribute("fullname", fullName);
writer.writeAttribute("href", fullDocumentLocation(node));
- if (node->type() != Node::Fake)
+ if ((node->type() != Node::Fake) && (!node->isQmlNode()))
writer.writeAttribute("location", node->location().fileName());
switch (node->type()) {
@@ -1265,6 +1274,12 @@ bool Tree::generateIndexSection(QXmlStreamWriter &writer,
case Node::ExternalPage:
writer.writeAttribute("subtype", "externalpage");
break;
+ case Node::QmlClass:
+ writer.writeAttribute("subtype", "qmlclass");
+ break;
+ case Node::QmlBasicType:
+ writer.writeAttribute("subtype", "qmlbasictype");
+ break;
default:
break;
}
@@ -1337,6 +1352,12 @@ bool Tree::generateIndexSection(QXmlStreamWriter &writer,
}
break;
+ case Node::QmlProperty:
+ {
+ const QmlPropertyNode *qpn = static_cast<const QmlPropertyNode*>(node);
+ writer.writeAttribute("type", qpn->dataType());
+ }
+ break;
case Node::Property:
{
const PropertyNode *propertyNode = static_cast<const PropertyNode*>(node);
@@ -1524,9 +1545,22 @@ void Tree::generateIndexSections(QXmlStreamWriter &writer,
if (node->isInnerNode()) {
const InnerNode *inner = static_cast<const InnerNode *>(node);
- // Recurse to write an element for this child node and all its children.
- foreach (const Node *child, inner->childNodes())
- generateIndexSections(writer, child, generateInternalNodes);
+ foreach (const Node *child, inner->childNodes()) {
+ /*
+ Don't generate anything for a QML property group node.
+ It is just a place holder for a collection of QML property
+ nodes. Recurse to its children, which are the QML property
+ nodes.
+ */
+ if (child->subType() == Node::QmlPropertyGroup) {
+ const InnerNode *pgn = static_cast<const InnerNode*>(child);
+ foreach (const Node *c, pgn->childNodes()) {
+ generateIndexSections(writer, c, generateInternalNodes);
+ }
+ }
+ else
+ generateIndexSections(writer, child, generateInternalNodes);
+ }
/*
foreach (const Node *child, inner->relatedNodes()) {
@@ -1931,9 +1965,23 @@ QString Tree::fullDocumentLocation(const Node *node) const
if ((parentNode = node->relates()))
parentName = fullDocumentLocation(node->relates());
- else if ((parentNode = node->parent()))
- parentName = fullDocumentLocation(node->parent());
-
+ else if ((parentNode = node->parent())) {
+ if (parentNode->subType() == Node::QmlPropertyGroup) {
+ parentNode = parentNode->parent();
+ parentName = "qml-" + parentNode->fileBase() + ".html";
+ }
+ else
+ parentName = fullDocumentLocation(node->parent());
+ }
+#if 0
+ if (node->type() == Node::QmlProperty) {
+ qDebug() << "Node::QmlProperty:" << node->name()
+ << "parentName:" << parentName;
+ if (parentNode)
+ qDebug() << "PARENT NODE" << parentNode->type()
+ << parentNode->subType() << parentNode->name();
+ }
+#endif
switch (node->type()) {
case Node::Class:
case Node::Namespace:
@@ -1980,6 +2028,15 @@ QString Tree::fullDocumentLocation(const Node *node) const
case Node::Property:
anchorRef = "#" + node->name() + "-prop";
break;
+ case Node::QmlProperty:
+ anchorRef = "#" + node->name() + "-prop";
+ break;
+ case Node::QmlSignal:
+ anchorRef = "#" + node->name() + "-signal";
+ break;
+ case Node::QmlMethod:
+ anchorRef = "#" + node->name() + "-method";
+ break;
case Node::Variable:
anchorRef = "#" + node->name() + "-var";
break;
@@ -2019,6 +2076,8 @@ QString Tree::fullDocumentLocation(const Node *node) const
}
/*!
+ Construct the full document name for \a node and return the
+ name.
*/
QString Tree::fullDocumentName(const Node *node) const
{
@@ -2029,10 +2088,11 @@ QString Tree::fullDocumentName(const Node *node) const
const Node *n = node;
do {
- if (!n->name().isEmpty())
+ if (!n->name().isEmpty() &&
+ ((n->type() != Node::Fake) || (n->subType() != Node::QmlPropertyGroup)))
pieces.insert(0, n->name());
- if (n->type() == Node::Fake)
+ if ((n->type() == Node::Fake) && (n->subType() != Node::QmlPropertyGroup))
break;
// Examine the parent node if one exists.
diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp
index af08777..80e5e34 100644
--- a/tools/runonphone/main.cpp
+++ b/tools/runonphone/main.cpp
@@ -44,6 +44,7 @@
#include <QStringList>
#include <QScopedPointer>
#include <QTimer>
+#include <QFileInfo>
#include "symbianutils/trkutils.h"
#include "symbianutils/trkdevice.h"
#include "symbianutils/launcher.h"
@@ -51,9 +52,9 @@
#include "trksignalhandler.h"
#include "serenum.h"
-void printUsage(QTextStream& outstream)
+void printUsage(QTextStream& outstream, QString exeName)
{
- outstream << "runtest [options] <program> [program arguments]" << endl
+ outstream << exeName << " [options] [program] [program arguments]" << endl
<< "-s, --sis <file> specify sis file to install" << endl
<< "-p, --portname <COMx> specify COM port to use by device name" << endl
<< "-f, --portfriendlyname <substring> specify COM port to use by friendly name" << endl
@@ -61,7 +62,9 @@ void printUsage(QTextStream& outstream)
<< "-v, --verbose show debugging output" << endl
<< "-q, --quiet hide progress messages" << endl
<< endl
- << "USB COM ports can usually be autodetected" << endl;
+ << "USB COM ports can usually be autodetected, use -p or -f to force a specific port." << endl
+ << "If using System TRK, it is possible to copy the program directly to sys/bin on the phone." << endl
+ << "-s can be used with both System and Application TRK to install the program" << endl;
}
int main(int argc, char *argv[])
@@ -86,22 +89,22 @@ int main(int argc, char *argv[])
return 1;
}
QString param = args.at(i+1);
- if(arg.compare("--portname", Qt::CaseSensitive) == 0
+ if (arg.compare("--portname", Qt::CaseSensitive) == 0
|| arg.compare("-p", Qt::CaseSensitive) == 0) {
serialPortName = param;
i++;
}
- else if(arg.compare("--portfriendlyname", Qt::CaseSensitive) == 0
+ else if (arg.compare("--portfriendlyname", Qt::CaseSensitive) == 0
|| arg.compare("-f", Qt::CaseSensitive) == 0) {
serialPortFriendlyName = param;
i++;
}
- else if(arg.compare("--sis", Qt::CaseSensitive) == 0
+ else if (arg.compare("--sis", Qt::CaseSensitive) == 0
|| arg.compare("-s", Qt::CaseSensitive) == 0) {
sisFile = param;
i++;
}
- else if(arg.compare("--timeout", Qt::CaseSensitive) == 0
+ else if (arg.compare("--timeout", Qt::CaseSensitive) == 0
|| arg.compare("-t", Qt::CaseSensitive) == 0) {
bool ok;
timeout = param.toInt(&ok);
@@ -111,10 +114,10 @@ int main(int argc, char *argv[])
}
i++;
}
- else if(arg.compare("--verbose", Qt::CaseSensitive) == 0
+ else if (arg.compare("--verbose", Qt::CaseSensitive) == 0
|| arg.compare("-v", Qt::CaseSensitive) == 0)
loglevel=2;
- else if(arg.compare("--quiet", Qt::CaseSensitive) == 0
+ else if (arg.compare("--quiet", Qt::CaseSensitive) == 0
|| arg.compare("-q", Qt::CaseSensitive) == 0)
loglevel=0;
else
@@ -128,8 +131,8 @@ int main(int argc, char *argv[])
}
}
- if(exeFile.isEmpty()) {
- printUsage(outstream);
+ if (exeFile.isEmpty() && sisFile.isEmpty()) {
+ printUsage(outstream, args[0]);
return 1;
}
@@ -161,24 +164,26 @@ int main(int argc, char *argv[])
}
QScopedPointer<trk::Launcher> launcher;
-
- if (sisFile.isEmpty()) {
- launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyRun));
- launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + exeFile);
- errstream << "System TRK required to copy EXE, use --sis if using Application TRK" << endl;
- } else {
- launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyInstallRun));
- launcher->addStartupActions(trk::Launcher::ActionInstall);
+ launcher.reset(new trk::Launcher(trk::Launcher::ActionPingOnly));
+ QFileInfo info(exeFile);
+ if (!sisFile.isEmpty()) {
+ launcher->addStartupActions(trk::Launcher::ActionCopyInstall);
launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis");
launcher->setInstallFileName("c:\\data\\testtemp.sis");
}
+ else if (info.exists()) {
+ launcher->addStartupActions(trk::Launcher::ActionCopy);
+ launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + info.fileName());
+ }
+ if (!exeFile.isEmpty()) {
+ launcher->addStartupActions(trk::Launcher::ActionRun);
+ launcher->setFileName(QString("c:\\sys\\bin\\") + info.fileName());
+ launcher->setCommandLineArgs(cmdLine);
+ }
if (loglevel > 0)
outstream << "Connecting to target via " << serialPortName << endl;
launcher->setTrkServerName(serialPortName);
- launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile);
- launcher->setCommandLineArgs(cmdLine);
-
if (loglevel > 1)
launcher->setVerbose(1);
diff --git a/tools/runonphone/symbianutils/launcher.cpp b/tools/runonphone/symbianutils/launcher.cpp
index 408829b..92b494a 100644
--- a/tools/runonphone/symbianutils/launcher.cpp
+++ b/tools/runonphone/symbianutils/launcher.cpp
@@ -44,6 +44,7 @@
#include "trkutils_p.h"
#include "trkdevice.h"
#include "bluetoothlistener.h"
+#include "symbiandevicemanager.h"
#include <QtCore/QTimer>
#include <QtCore/QDateTime>
@@ -100,12 +101,15 @@ Launcher::Launcher(Actions startupActions,
d(new LauncherPrivate(dev))
{
d->m_startupActions = startupActions;
- connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult)));
- connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close()));
+ connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult)));
}
Launcher::~Launcher()
{
+ // Destroyed before protocol was through: Close
+ if (d->m_closeDevice && d->m_device->isOpen())
+ d->m_device->close();
+ emit destroyed(d->m_device->port());
logMessage("Shutting down.\n");
delete d;
}
@@ -214,11 +218,6 @@ bool Launcher::startServer(QString *errorMessage)
}
if (!d->m_device->isOpen() && !d->m_device->open(errorMessage))
return false;
- if (d->m_closeDevice) {
- connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close()));
- } else {
- disconnect(this, SIGNAL(finished()), d->m_device.data(), 0);
- }
setState(Connecting);
// Set up the temporary 'waiting' state if we do not get immediate connection
QTimer::singleShot(1000, this, SLOT(slotWaitingForTrk()));
@@ -266,6 +265,13 @@ void Launcher::logMessage(const QString &msg)
qDebug() << "LAUNCHER: " << qPrintable(msg);
}
+void Launcher::handleFinished()
+{
+ if (d->m_closeDevice)
+ d->m_device->close();
+ emit finished();
+}
+
void Launcher::terminate()
{
switch (state()) {
@@ -287,7 +293,7 @@ void Launcher::terminate()
case Connecting:
case WaitingForTrk:
setState(Disconnected);
- emit finished();
+ handleFinished();
break;
}
}
@@ -446,7 +452,7 @@ void Launcher::handleTrkVersion(const TrkResult &result)
if (result.errorCode() || result.data.size() < 5) {
if (d->m_startupActions == ActionPingOnly) {
setState(Disconnected);
- emit finished();
+ handleFinished();
}
return;
}
@@ -455,11 +461,13 @@ void Launcher::handleTrkVersion(const TrkResult &result)
d->m_session.trkAppVersion.protocolMajor = result.data.at(3);
d->m_session.trkAppVersion.protocolMinor = result.data.at(4);
setState(DeviceDescriptionReceived);
+ const QString msg = deviceDescription();
+ emit deviceDescriptionReceived(trkServerName(), msg);
// Ping mode: Log & Terminate
if (d->m_startupActions == ActionPingOnly) {
- qWarning("%s", qPrintable(deviceDescription()));
+ qWarning("%s", qPrintable(msg));
setState(Disconnected);
- emit finished();
+ handleFinished();
}
}
@@ -586,7 +594,7 @@ void Launcher::handleWaitForFinished(const TrkResult &result)
{
logMessage(" FINISHED: " + stringFromArray(result.data));
setState(Disconnected);
- emit finished();
+ handleFinished();
}
void Launcher::handleSupportMask(const TrkResult &result)
@@ -704,18 +712,14 @@ QByteArray Launcher::startProcessMessage(const QString &executable,
{
// It's not started yet
QByteArray ba;
- appendShort(&ba, 0, TargetByteOrder); // create new process
+ appendShort(&ba, 0, TargetByteOrder); // create new process (kDSOSProcessItem)
ba.append(char(0)); // options - currently unused
- if(arguments.isEmpty()) {
- appendString(&ba, executable.toLocal8Bit(), TargetByteOrder);
- return ba;
- }
- // Append full command line as one string (leading length information).
- QByteArray commandLineBa;
- commandLineBa.append(executable.toLocal8Bit());
- commandLineBa.append('\0');
- commandLineBa.append(arguments.join(QString(QLatin1Char(' '))).toLocal8Bit());
- appendString(&ba, commandLineBa, TargetByteOrder);
+ // One string consisting of binary terminated by '\0' and arguments terminated by '\0'
+ QByteArray commandLineBa = executable.toLocal8Bit();
+ commandLineBa.append(char(0));
+ if (!arguments.isEmpty())
+ commandLineBa.append(arguments.join(QString(QLatin1Char(' '))).toLocal8Bit());
+ appendString(&ba, commandLineBa, TargetByteOrder, true);
return ba;
}
@@ -737,4 +741,37 @@ void Launcher::resumeProcess(uint pid, uint tid)
appendInt(&ba, tid, BigEndian);
d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE");
}
+
+// Acquire a device from SymbianDeviceManager, return 0 if not available.
+Launcher *Launcher::acquireFromDeviceManager(const QString &serverName,
+ QObject *parent,
+ QString *errorMessage)
+{
+ SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance();
+ const QSharedPointer<trk::TrkDevice> device = sdm->acquireDevice(serverName);
+ if (device.isNull()) {
+ *errorMessage = tr("Unable to acquire a device for port '%1'. It appears to be in use.").arg(serverName);
+ return 0;
+ }
+ // Wire release signal.
+ Launcher *rc = new Launcher(trk::Launcher::ActionPingOnly, device, parent);
+ connect(rc, SIGNAL(deviceDescriptionReceived(QString,QString)),
+ sdm, SLOT(setAdditionalInformation(QString,QString)));
+ connect(rc, SIGNAL(destroyed(QString)), sdm, SLOT(releaseDevice(QString)));
+ return rc;
+}
+
+// Preliminary release of device, disconnecting the signal.
+void Launcher::releaseToDeviceManager(Launcher *launcher)
+{
+ SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance();
+ // Disentangle launcher and its device, remove connection from destroyed
+ launcher->setCloseDevice(false);
+ TrkDevice *device = launcher->trkDevice().data();
+ launcher->disconnect(device);
+ device->disconnect(launcher);
+ launcher->disconnect(sdm);
+ sdm->releaseDevice(launcher->trkServerName());
+}
+
} // namespace trk
diff --git a/tools/runonphone/symbianutils/launcher.h b/tools/runonphone/symbianutils/launcher.h
index 2b23fd8..c47285c 100644
--- a/tools/runonphone/symbianutils/launcher.h
+++ b/tools/runonphone/symbianutils/launcher.h
@@ -97,7 +97,7 @@ public:
void setInstallFileName(const QString &name);
void setCommandLineArgs(const QStringList &args);
bool startServer(QString *errorMessage);
- void setVerbose(int v);
+ void setVerbose(int v);
void setSerialFrame(bool b);
bool serialFrame() const;
// Close device or leave it open
@@ -109,6 +109,15 @@ public:
// becomes valid after successful execution of ActionPingOnly
QString deviceDescription(unsigned verbose = 0u) const;
+ // Acquire a device from SymbianDeviceManager, return 0 if not available.
+ // The device will be released on destruction.
+ static Launcher *acquireFromDeviceManager(const QString &serverName,
+ QObject *parent,
+ QString *errorMessage);
+ // Preliminary release of device, disconnecting the signal.
+ static void releaseToDeviceManager(Launcher *l);
+
+ // Create Trk message to start a process.
static QByteArray startProcessMessage(const QString &executable,
const QStringList &arguments);
// Parse a TrkNotifyStopped message
@@ -119,6 +128,7 @@ public:
static QString msgStopped(uint pid, uint tid, uint address, const QString &why);
signals:
+ void deviceDescriptionReceived(const QString &port, const QString &description);
void copyingStarted();
void canNotConnect(const QString &errorMessage);
void canNotCreateFile(const QString &filename, const QString &errorMessage);
@@ -135,6 +145,8 @@ signals:
void copyProgress(int percent);
void stateChanged(int);
void processStopped(uint pc, uint pid, uint tid, const QString& reason);
+ // Emitted by the destructor, for releasing devices of SymbianDeviceManager by name
+ void destroyed(const QString &serverName);
public slots:
void terminate();
@@ -167,6 +179,7 @@ private:
void copyFileToRemote();
void installRemotePackageSilently();
void startInferiorIfNeeded();
+ void handleFinished();
void logMessage(const QString &msg);
void setState(State s);
diff --git a/tools/runonphone/symbianutils/symbiandevicemanager.cpp b/tools/runonphone/symbianutils/symbiandevicemanager.cpp
index f663816..8877ea1 100644
--- a/tools/runonphone/symbianutils/symbiandevicemanager.cpp
+++ b/tools/runonphone/symbianutils/symbiandevicemanager.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "symbiandevicemanager.h"
+#include "trkdevice.h"
#include <QtCore/QSettings>
#include <QtCore/QStringList>
@@ -48,6 +49,7 @@
#include <QtCore/QTextStream>
#include <QtCore/QSharedData>
#include <QtCore/QScopedPointer>
+#include <QtCore/QSignalMapper>
namespace SymbianUtils {
@@ -61,19 +63,51 @@ const char *SymbianDeviceManager::linuxBlueToothDeviceRootC = "/dev/rfcomm";
// ------------- SymbianDevice
class SymbianDeviceData : public QSharedData {
public:
- SymbianDeviceData() : type(SerialPortCommunication) {}
+ SymbianDeviceData();
+ ~SymbianDeviceData();
+
+ inline bool isOpen() const { return !device.isNull() && device->isOpen(); }
+ void forcedClose();
QString portName;
QString friendlyName;
QString deviceDesc;
QString manufacturer;
+ QString additionalInformation;
+
DeviceCommunicationType type;
+ QSharedPointer<trk::TrkDevice> device;
+ bool deviceAcquired;
};
+SymbianDeviceData::SymbianDeviceData() :
+ type(SerialPortCommunication),
+ deviceAcquired(false)
+{
+}
+
+SymbianDeviceData::~SymbianDeviceData()
+{
+ forcedClose();
+}
+
+void SymbianDeviceData::forcedClose()
+{
+ // Close the device when unplugging. Should devices be in 'acquired' state,
+ // their owners should hit on write failures.
+ // Apart from the <shared item> destructor, also called by the devicemanager
+ // to ensure it also happens if other shared instances are still around.
+ if (isOpen()) {
+ if (deviceAcquired)
+ qWarning("Device on '%s' unplugged while an operation is in progress.",
+ qPrintable(portName));
+ device->close();
+ }
+}
+
SymbianDevice::SymbianDevice(SymbianDeviceData *data) :
m_data(data)
{
-
}
SymbianDevice::SymbianDevice() :
@@ -96,6 +130,11 @@ SymbianDevice::~SymbianDevice()
{
}
+void SymbianDevice::forcedClose()
+{
+ m_data->forcedClose();
+}
+
QString SymbianDevice::portName() const
{
return m_data->portName;
@@ -106,6 +145,51 @@ QString SymbianDevice::friendlyName() const
return m_data->friendlyName;
}
+QString SymbianDevice::additionalInformation() const
+{
+ return m_data->additionalInformation;
+}
+
+void SymbianDevice::setAdditionalInformation(const QString &a)
+{
+ m_data->additionalInformation = a;
+}
+
+SymbianDevice::TrkDevicePtr SymbianDevice::acquireDevice()
+{
+ if (debug)
+ qDebug() << "SymbianDevice::acquireDevice" << m_data->portName
+ << "acquired: " << m_data->deviceAcquired << " open: " << isOpen();
+ if (isNull() || m_data->deviceAcquired)
+ return TrkDevicePtr();
+ if (m_data->device.isNull()) {
+ m_data->device = TrkDevicePtr(new trk::TrkDevice);
+ m_data->device->setPort(m_data->portName);
+ m_data->device->setSerialFrame(m_data->type == SerialPortCommunication);
+ }
+ m_data->deviceAcquired = true;
+ return m_data->device;
+}
+
+void SymbianDevice::releaseDevice(TrkDevicePtr *ptr /* = 0 */)
+{
+ if (debug)
+ qDebug() << "SymbianDevice::releaseDevice" << m_data->portName
+ << " open: " << isOpen();
+ if (m_data->deviceAcquired) {
+ if (m_data->device->isOpen())
+ m_data->device->clearWriteQueue();
+ // Release if a valid pointer was passed in.
+ if (ptr && !ptr->isNull()) {
+ ptr->data()->disconnect();
+ *ptr = TrkDevicePtr();
+ }
+ m_data->deviceAcquired = false;
+ } else {
+ qWarning("Internal error: Attempt to release device that is not acquired.");
+ }
+}
+
QString SymbianDevice::deviceDesc() const
{
return m_data->deviceDesc;
@@ -123,7 +207,12 @@ DeviceCommunicationType SymbianDevice::type() const
bool SymbianDevice::isNull() const
{
- return !m_data->portName.isEmpty();
+ return m_data->portName.isEmpty();
+}
+
+bool SymbianDevice::isOpen() const
+{
+ return m_data->isOpen();
}
QString SymbianDevice::toString() const
@@ -158,7 +247,7 @@ int SymbianDevice::compare(const SymbianDevice &rhs) const
return 0;
}
-QDebug operator<<(QDebug d, const SymbianDevice &cd)
+SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDevice &cd)
{
d.nospace() << cd.toString();
return d;
@@ -166,10 +255,11 @@ QDebug operator<<(QDebug d, const SymbianDevice &cd)
// ------------- SymbianDeviceManagerPrivate
struct SymbianDeviceManagerPrivate {
- SymbianDeviceManagerPrivate() : m_initialized(false) {}
+ SymbianDeviceManagerPrivate() : m_initialized(false), m_destroyReleaseMapper(0) {}
bool m_initialized;
SymbianDeviceManager::SymbianDeviceList m_devices;
+ QSignalMapper *m_destroyReleaseMapper;
};
SymbianDeviceManager::SymbianDeviceManager(QObject *parent) :
@@ -185,8 +275,7 @@ SymbianDeviceManager::~SymbianDeviceManager()
SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::devices() const
{
- if (!d->m_initialized)
- const_cast<SymbianDeviceManager*>(this)->update(false);
+ ensureInitialized();
return d->m_devices;
}
@@ -194,6 +283,7 @@ QString SymbianDeviceManager::toString() const
{
QString rc;
QTextStream str(&rc);
+ str << d->m_devices.size() << " devices:\n";
const int count = d->m_devices.size();
for (int i = 0; i < count; i++) {
str << '#' << i << ' ';
@@ -203,13 +293,37 @@ QString SymbianDeviceManager::toString() const
return rc;
}
+int SymbianDeviceManager::findByPortName(const QString &p) const
+{
+ ensureInitialized();
+ const int count = d->m_devices.size();
+ for (int i = 0; i < count; i++)
+ if (d->m_devices.at(i).portName() == p)
+ return i;
+ return -1;
+}
+
QString SymbianDeviceManager::friendlyNameForPort(const QString &port) const
{
- foreach (const SymbianDevice &device, d->m_devices) {
- if (device.portName() == port)
- return device.friendlyName();
- }
- return QString();
+ const int idx = findByPortName(port);
+ return idx == -1 ? QString() : d->m_devices.at(idx).friendlyName();
+}
+
+SymbianDeviceManager::TrkDevicePtr
+ SymbianDeviceManager::acquireDevice(const QString &port)
+{
+ ensureInitialized();
+ const int idx = findByPortName(port);
+ if (idx == -1) {
+ qWarning("Attempt to acquire device '%s' that does not exist.", qPrintable(port));
+ if (debug)
+ qDebug() << *this;
+ return TrkDevicePtr();
+ }
+ const TrkDevicePtr rc = d->m_devices[idx].acquireDevice();
+ if (debug)
+ qDebug() << "SymbianDeviceManager::acquireDevice" << port << " returns " << !rc.isNull();
+ return rc;
}
void SymbianDeviceManager::update()
@@ -217,12 +331,38 @@ void SymbianDeviceManager::update()
update(true);
}
+void SymbianDeviceManager::releaseDevice(const QString &port)
+{
+ const int idx = findByPortName(port);
+ if (debug)
+ qDebug() << "SymbianDeviceManager::releaseDevice" << port << idx << sender();
+ if (idx != -1) {
+ d->m_devices[idx].releaseDevice();
+ } else {
+ qWarning("Attempt to release non-existing device %s.", qPrintable(port));
+ }
+}
+
+void SymbianDeviceManager::setAdditionalInformation(const QString &port, const QString &ai)
+{
+ const int idx = findByPortName(port);
+ if (idx != -1)
+ d->m_devices[idx].setAdditionalInformation(ai);
+}
+
+void SymbianDeviceManager::ensureInitialized() const
+{
+ if (!d->m_initialized) // Flag is set in update()
+ const_cast<SymbianDeviceManager*>(this)->update(false);
+}
+
void SymbianDeviceManager::update(bool emitSignals)
{
+ static int n = 0;
typedef SymbianDeviceList::iterator SymbianDeviceListIterator;
if (debug)
- qDebug(">SerialDeviceLister::update(%d)\n%s", int(emitSignals),
+ qDebug(">SerialDeviceLister::update(#%d, signals=%d)\n%s", n++, int(emitSignals),
qPrintable(toString()));
d->m_initialized = true;
@@ -230,8 +370,11 @@ void SymbianDeviceManager::update(bool emitSignals)
SymbianDeviceList newDevices = serialPorts() + blueToothDevices();
if (newDevices.size() > 1)
qStableSort(newDevices.begin(), newDevices.end());
- if (d->m_devices == newDevices) // Happy, nothing changed.
+ if (d->m_devices == newDevices) { // Happy, nothing changed.
+ if (debug)
+ qDebug("<SerialDeviceLister::update: unchanged\n");
return;
+ }
// Merge the lists and emit the respective added/removed signals, assuming
// no one can plug a different device on the same port at the speed of lightning
if (!d->m_devices.isEmpty()) {
@@ -240,7 +383,8 @@ void SymbianDeviceManager::update(bool emitSignals)
if (newDevices.contains(*oldIt)) {
++oldIt;
} else {
- const SymbianDevice toBeDeleted = *oldIt;
+ SymbianDevice toBeDeleted = *oldIt;
+ toBeDeleted.forcedClose();
oldIt = d->m_devices.erase(oldIt);
if (emitSignals)
emit deviceRemoved(toBeDeleted);
@@ -301,16 +445,30 @@ SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::blueToothDevices()
// Bluetooth devices are created on connection. List the existing ones
// or at least the first one.
const QString prefix = QLatin1String(linuxBlueToothDeviceRootC);
- const QString friendlyFormat = QLatin1String("Bluetooth device (%1)");
+ const QString blueToothfriendlyFormat = QLatin1String("Bluetooth device (%1)");
for (int d = 0; d < 4; d++) {
QScopedPointer<SymbianDeviceData> device(new SymbianDeviceData);
device->type = BlueToothCommunication;
device->portName = prefix + QString::number(d);
if (d == 0 || QFileInfo(device->portName).exists()) {
- device->friendlyName = friendlyFormat.arg(device->portName);
+ device->friendlyName = blueToothfriendlyFormat.arg(device->portName);
rc.push_back(SymbianDevice(device.take()));
}
}
+ // New kernel versions support /dev/ttyUSB0, /dev/ttyUSB1. Trk responds
+ // on the latter (usually), try first.
+ static const char *usbTtyDevices[] = { "/dev/ttyUSB1", "/dev/ttyUSB0" };
+ const int usbTtyCount = sizeof(usbTtyDevices)/sizeof(const char *);
+ for (int d = 0; d < usbTtyCount; d++) {
+ const QString ttyUSBDevice = QLatin1String(usbTtyDevices[d]);
+ if (QFileInfo(ttyUSBDevice).exists()) {
+ SymbianDeviceData *device = new SymbianDeviceData;
+ device->type = SerialPortCommunication;
+ device->portName = ttyUSBDevice;
+ device->friendlyName = QString::fromLatin1("USB/Serial device (%1)").arg(device->portName);
+ rc.push_back(SymbianDevice(device));
+ }
+ }
#endif
return rc;
}
@@ -322,7 +480,7 @@ SymbianDeviceManager *SymbianDeviceManager::instance()
return symbianDeviceManager();
}
-QDebug operator<<(QDebug d, const SymbianDeviceManager &sdm)
+SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDeviceManager &sdm)
{
d.nospace() << sdm.toString();
return d;
diff --git a/tools/runonphone/symbianutils/symbiandevicemanager.h b/tools/runonphone/symbianutils/symbiandevicemanager.h
index dcf131a..180173d 100644
--- a/tools/runonphone/symbianutils/symbiandevicemanager.h
+++ b/tools/runonphone/symbianutils/symbiandevicemanager.h
@@ -46,12 +46,17 @@
#include <QtCore/QObject>
#include <QtCore/QExplicitlySharedDataPointer>
+#include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE
class QDebug;
class QTextStream;
QT_END_NAMESPACE
+namespace trk {
+ class TrkDevice;
+}
+
namespace SymbianUtils {
struct SymbianDeviceManagerPrivate;
@@ -62,11 +67,16 @@ enum DeviceCommunicationType {
BlueToothCommunication = 1
};
-// SymbianDevice, explicitly shared.
+// SymbianDevice: Explicitly shared device data and a TrkDevice
+// instance that can be acquired (exclusively) for use.
+// A device removal from the manager will result in the
+// device being closed.
class SYMBIANUTILS_EXPORT SymbianDevice {
explicit SymbianDevice(SymbianDeviceData *data);
friend class SymbianDeviceManager;
public:
+ typedef QSharedPointer<trk::TrkDevice> TrkDevicePtr;
+
SymbianDevice();
SymbianDevice(const SymbianDevice &rhs);
SymbianDevice &operator=(const SymbianDevice &rhs);
@@ -77,6 +87,17 @@ public:
bool isNull() const;
QString portName() const;
QString friendlyName() const;
+ QString additionalInformation() const;
+ void setAdditionalInformation(const QString &);
+
+ // Acquire: Mark the device as 'out' and return a shared pointer
+ // unless it is already in use by another owner. The result should not
+ // be passed on further.
+ TrkDevicePtr acquireDevice();
+ // Give back a device and mark it as 'free'.
+ void releaseDevice(TrkDevicePtr *ptr = 0);
+
+ bool isOpen() const;
// Windows only.
QString deviceDesc() const;
@@ -86,10 +107,12 @@ public:
QString toString() const;
private:
+ void forcedClose();
+
QExplicitlySharedDataPointer<SymbianDeviceData> m_data;
};
-QDebug operator<<(QDebug d, const SymbianDevice &);
+SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDevice &);
inline bool operator==(const SymbianDevice &d1, const SymbianDevice &d2)
{ return d1.compare(d2) == 0; }
@@ -100,13 +123,15 @@ inline bool operator<(const SymbianDevice &d1, const SymbianDevice &d2)
/* SymbianDeviceManager: Singleton that maintains a list of Symbian devices.
* and emits change signals.
- * On Windows, the update slot must be connected to a signal
- * emitted from an event handler listening for WM_DEVICECHANGE. */
+ * On Windows, the update slot must be connected to a [delayed] signal
+ * emitted from an event handler listening for WM_DEVICECHANGE.
+ * Device removal will result in the device being closed. */
class SYMBIANUTILS_EXPORT SymbianDeviceManager : public QObject
{
Q_OBJECT
public:
typedef QList<SymbianDevice> SymbianDeviceList;
+ typedef QSharedPointer<trk::TrkDevice> TrkDevicePtr;
static const char *linuxBlueToothDeviceRootC;
@@ -120,17 +145,25 @@ public:
SymbianDeviceList devices() const;
QString toString() const;
+ // Acquire a device for use. See releaseDevice().
+ TrkDevicePtr acquireDevice(const QString &port);
+
+ int findByPortName(const QString &p) const;
QString friendlyNameForPort(const QString &port) const;
public slots:
void update();
+ // Relase a device, make it available for further use.
+ void releaseDevice(const QString &port);
+ void setAdditionalInformation(const QString &port, const QString &ai);
signals:
- void deviceRemoved(const SymbianDevice &d);
- void deviceAdded(const SymbianDevice &d);
+ void deviceRemoved(const SymbianUtils::SymbianDevice &d);
+ void deviceAdded(const SymbianUtils::SymbianDevice &d);
void updated();
private:
+ void ensureInitialized() const;
void update(bool emitSignals);
SymbianDeviceList serialPorts() const;
SymbianDeviceList blueToothDevices() const;
@@ -138,7 +171,7 @@ private:
SymbianDeviceManagerPrivate *d;
};
-QDebug operator<<(QDebug d, const SymbianDeviceManager &);
+SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDeviceManager &);
} // namespace SymbianUtils
diff --git a/tools/runonphone/symbianutils/trkdevice.cpp b/tools/runonphone/symbianutils/trkdevice.cpp
index b327ab3..bd24300 100644
--- a/tools/runonphone/symbianutils/trkdevice.cpp
+++ b/tools/runonphone/symbianutils/trkdevice.cpp
@@ -52,6 +52,7 @@
#include <QtCore/QMutex>
#include <QtCore/QWaitCondition>
#include <QtCore/QSharedPointer>
+#include <QtCore/QScopedPointer>
#include <QtCore/QMetaType>
#ifdef Q_OS_WIN
@@ -102,6 +103,11 @@ QString winErrorMessage(unsigned long error)
enum { verboseTrk = 0 };
+static inline QString msgAccessingClosedDevice(const QString &msg)
+{
+ return QString::fromLatin1("Error: Attempt to access device '%1', which is closed.").arg(msg);
+}
+
namespace trk {
///////////////////////////////////////////////////////////////////////
@@ -155,10 +161,11 @@ namespace trk {
///////////////////////////////////////////////////////////////////////
class TrkWriteQueue
-{
+{
Q_DISABLE_COPY(TrkWriteQueue)
public:
explicit TrkWriteQueue();
+ void clear();
// Enqueue messages.
void queueTrkMessage(byte code, TrkCallback callback,
@@ -208,13 +215,24 @@ TrkWriteQueue::TrkWriteQueue() :
{
}
+void TrkWriteQueue::clear()
+{
+ m_trkWriteToken = 0;
+ m_trkWriteBusy = false;
+ m_trkWriteQueue.clear();
+ const int discarded = m_writtenTrkMessages.size();
+ m_writtenTrkMessages.clear();
+ if (verboseTrk)
+ qDebug() << "TrkWriteQueue::clear: discarded " << discarded;
+}
+
byte TrkWriteQueue::nextTrkWriteToken()
{
++m_trkWriteToken;
if (m_trkWriteToken == 0)
++m_trkWriteToken;
if (verboseTrk)
- qDebug() << "Write token: " << m_trkWriteToken;
+ qDebug() << "nextTrkWriteToken:" << m_trkWriteToken;
return m_trkWriteToken;
}
@@ -349,7 +367,7 @@ class WriterThread : public QThread
{
Q_OBJECT
Q_DISABLE_COPY(WriterThread)
-public:
+public:
explicit WriterThread(const QSharedPointer<DeviceContext> &context);
// Enqueue messages.
@@ -357,6 +375,8 @@ public:
const QByteArray &data, const QVariant &cookie);
void queueTrkInitialPing();
+ void clearWriteQueue();
+
// Call this from the device read notification with the results.
void slotHandleResult(const TrkResult &result);
@@ -374,7 +394,7 @@ public slots:
private slots:
void invokeNoopMessage(const trk::TrkMessage &);
-private:
+private:
bool write(const QByteArray &data, QString *errorMessage);
inline int writePendingMessage();
@@ -462,6 +482,7 @@ void WriterThread::terminate()
m_waitCondition.wakeAll();
wait();
m_terminate = false;
+ m_queue.clear();
}
#ifdef Q_OS_WIN
@@ -561,6 +582,13 @@ void WriterThread::queueTrkMessage(byte code, TrkCallback callback,
tryWrite();
}
+void WriterThread::clearWriteQueue()
+{
+ m_dataMutex.lock();
+ m_queue.clear();
+ m_dataMutex.unlock();
+}
+
void WriterThread::queueTrkInitialPing()
{
m_dataMutex.lock();
@@ -592,6 +620,8 @@ class ReaderThreadBase : public QThread
Q_DISABLE_COPY(ReaderThreadBase)
public:
+ int bytesPending() const { return m_trkReadBuffer.size(); }
+
signals:
void messageReceived(const trk::TrkResult &result, const QByteArray &rawData);
@@ -692,7 +722,7 @@ int WinReaderThread::tryRead()
if (!ClearCommError(m_context->device, NULL, &comStat)){
emit error(QString::fromLatin1("ClearCommError failed: %1").arg(winErrorMessage(GetLastError())));
return -7;
- }
+ }
const DWORD bytesToRead = qMax(DWORD(1), qMin(comStat.cbInQue, DWORD(BufSize)));
// Trigger read
DWORD bytesRead = 0;
@@ -708,7 +738,7 @@ int WinReaderThread::tryRead()
if (readError != ERROR_IO_PENDING) {
emit error(QString::fromLatin1("Read error: %1").arg(winErrorMessage(readError)));
return -1;
- }
+ }
// Wait for either termination or data
const DWORD wr = WaitForMultipleObjects(HandleCount, m_handles, false, INFINITE);
if (wr == WAIT_FAILED) {
@@ -783,7 +813,7 @@ private:
int m_terminatePipeFileDescriptors[2];
};
-UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) :
+UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) :
ReaderThreadBase(context)
{
m_terminatePipeFileDescriptors[0] = m_terminatePipeFileDescriptors[1] = -1;
@@ -877,8 +907,8 @@ struct TrkDevicePrivate
TrkDevicePrivate();
QSharedPointer<DeviceContext> deviceContext;
- QSharedPointer<WriterThread> writerThread;
- QSharedPointer<ReaderThread> readerThread;
+ QScopedPointer<WriterThread> writerThread;
+ QScopedPointer<ReaderThread> readerThread;
QByteArray trkReadBuffer;
int verbose;
@@ -917,14 +947,14 @@ TrkDevice::~TrkDevice()
bool TrkDevice::open(QString *errorMessage)
{
- if (d->verbose)
+ if (d->verbose || verboseTrk)
qDebug() << "Opening" << port() << "is open: " << isOpen() << " serialFrame=" << serialFrame();
+ if (isOpen())
+ return true;
if (d->port.isEmpty()) {
*errorMessage = QLatin1String("Internal error: No port set on TrkDevice");
return false;
}
-
- close();
#ifdef Q_OS_WIN
const QString fullPort = QLatin1String("\\\\.\\") + d->port;
d->deviceContext->device = CreateFile(reinterpret_cast<const WCHAR*>(fullPort.utf16()),
@@ -975,7 +1005,7 @@ bool TrkDevice::open(QString *errorMessage)
return false;
}
#endif
- d->readerThread = QSharedPointer<ReaderThread>(new ReaderThread(d->deviceContext));
+ d->readerThread.reset(new ReaderThread(d->deviceContext));
connect(d->readerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)),
Qt::QueuedConnection);
connect(d->readerThread.data(), SIGNAL(messageReceived(trk::TrkResult,QByteArray)),
@@ -983,18 +1013,22 @@ bool TrkDevice::open(QString *errorMessage)
Qt::QueuedConnection);
d->readerThread->start();
- d->writerThread = QSharedPointer<WriterThread>(new WriterThread(d->deviceContext));
+ d->writerThread.reset(new WriterThread(d->deviceContext));
connect(d->writerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)),
- Qt::QueuedConnection);
- d->writerThread->start();
+ Qt::QueuedConnection);
+ d->writerThread->start();
- if (d->verbose)
- qDebug() << "Opened" << d->port;
+ if (d->verbose || verboseTrk)
+ qDebug() << "Opened" << d->port << d->readerThread.data() << d->writerThread.data();
return true;
}
void TrkDevice::close()
{
+ if (verboseTrk)
+ qDebug() << "close" << d->port << " is open: " << isOpen()
+ << " read pending " << (d->readerThread.isNull() ? 0 : d->readerThread->bytesPending())
+ << sender();
if (!isOpen())
return;
if (d->readerThread)
@@ -1010,6 +1044,7 @@ void TrkDevice::close()
#else
d->deviceContext->file.close();
#endif
+
if (d->verbose)
emitLogMessage("Close");
}
@@ -1030,6 +1065,8 @@ QString TrkDevice::port() const
void TrkDevice::setPort(const QString &p)
{
+ if (verboseTrk)
+ qDebug() << "setPort" << p;
d->port = p;
}
@@ -1045,6 +1082,8 @@ bool TrkDevice::serialFrame() const
void TrkDevice::setSerialFrame(bool f)
{
+ if (verboseTrk)
+ qDebug() << "setSerialFrame" << f;
d->deviceContext->serialFrame = f;
}
@@ -1060,12 +1099,14 @@ void TrkDevice::setVerbose(int b)
void TrkDevice::slotMessageReceived(const trk::TrkResult &result, const QByteArray &rawData)
{
- d->writerThread->slotHandleResult(result);
- if (d->verbose > 1)
- qDebug() << "Received: " << result.toString();
- emit messageReceived(result);
- if (!rawData.isEmpty())
- emit rawDataReceived(rawData);
+ if (isOpen()) { // Might receive bytes after closing due to queued connections.
+ d->writerThread->slotHandleResult(result);
+ if (d->verbose > 1)
+ qDebug() << "Received: " << result.toString();
+ emit messageReceived(result);
+ if (!rawData.isEmpty())
+ emit rawDataReceived(rawData);
+ }
}
void TrkDevice::emitError(const QString &s)
@@ -1075,15 +1116,27 @@ void TrkDevice::emitError(const QString &s)
emit error(s);
}
+void TrkDevice::clearWriteQueue()
+{
+ if (isOpen())
+ d->writerThread->clearWriteQueue();
+}
+
void TrkDevice::sendTrkMessage(byte code, TrkCallback callback,
const QByteArray &data, const QVariant &cookie)
{
+ if (!isOpen()) {
+ emitError(msgAccessingClosedDevice(d->port));
+ return;
+ }
if (!d->writerThread.isNull()) {
if (d->verbose > 1) {
- QByteArray msg = "Sending: ";
+ QByteArray msg = "Sending: 0x";
msg += QByteArray::number(code, 16);
msg += ": ";
msg += stringFromArray(data).toLatin1();
+ if (cookie.isValid())
+ msg += " Cookie: " + cookie.toString().toLatin1();
qDebug("%s", msg.data());
}
d->writerThread->queueTrkMessage(code, callback, data, cookie);
@@ -1092,12 +1145,20 @@ void TrkDevice::sendTrkMessage(byte code, TrkCallback callback,
void TrkDevice::sendTrkInitialPing()
{
+ if (!isOpen()) {
+ emitError(msgAccessingClosedDevice(d->port));
+ return;
+ }
if (!d->writerThread.isNull())
d->writerThread->queueTrkInitialPing();
}
bool TrkDevice::sendTrkAck(byte token)
{
+ if (!isOpen()) {
+ emitError(msgAccessingClosedDevice(d->port));
+ return false;
+ }
if (d->writerThread.isNull())
return false;
// The acknowledgement must not be queued!
diff --git a/tools/runonphone/symbianutils/trkdevice.h b/tools/runonphone/symbianutils/trkdevice.h
index 78012fd..1021a7d 100644
--- a/tools/runonphone/symbianutils/trkdevice.h
+++ b/tools/runonphone/symbianutils/trkdevice.h
@@ -64,12 +64,14 @@ struct TrkDevicePrivate;
* Trk communications. Provides synchronous write and asynchronous
* read operation.
* The serialFrames property specifies whether packets are encapsulated in
- * "0x90 <length>" frames, which is currently the case for serial ports.
+ * "0x90 <length>" frames, which is currently the case for serial ports.
* Contains a write message queue allowing
* for queueing messages with a notification callback. If the message receives
* an ACK, the callback is invoked.
- * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronisation.
- * The respective message will not be sent, the callback is just invoked. */
+ * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronization.
+ * The respective message will not be sent, the callback is just invoked.
+ * Note that calling open/close in quick succession can cause crashes
+ * due to the use of queused signals. */
enum { TRK_WRITE_QUEUE_NOOP_CODE = 0x7f };
@@ -111,6 +113,9 @@ public:
// Send an Ack synchronously, bypassing the queue
bool sendTrkAck(unsigned char token);
+public slots:
+ void clearWriteQueue();
+
signals:
void messageReceived(const trk::TrkResult &result);
// Emitted with the contents of messages enclosed in 07e, not for log output
diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp
index 18a2c0c..2abf91f 100644
--- a/tools/runonphone/trksignalhandler.cpp
+++ b/tools/runonphone/trksignalhandler.cpp
@@ -54,6 +54,7 @@ private:
QTextStream out;
QTextStream err;
int loglevel;
+ int lastpercent;
};
void TrkSignalHandler::copyingStarted()
@@ -131,7 +132,12 @@ void TrkSignalHandler::applicationOutputReceived(const QString &output)
void TrkSignalHandler::copyProgress(int percent)
{
if (d->loglevel > 0) {
- d->out << percent << "% ";
+ if (d->lastpercent == 0)
+ d->out << "[ ]\r[" << flush;
+ while (percent > d->lastpercent) {
+ d->out << QLatin1Char('#');
+ d->lastpercent+=2; //because typical console is 80 chars wide
+ }
d->out.flush();
if (percent==100)
d->out << endl;
@@ -167,7 +173,8 @@ void TrkSignalHandler::timeout()
TrkSignalHandlerPrivate::TrkSignalHandlerPrivate()
: out(stdout),
err(stderr),
- loglevel(0)
+ loglevel(0),
+ lastpercent(0)
{
}
diff --git a/tools/shared/windows/registry.cpp b/tools/shared/windows/registry.cpp
index d342d78..67d9b56 100644
--- a/tools/shared/windows/registry.cpp
+++ b/tools/shared/windows/registry.cpp
@@ -148,7 +148,7 @@ QString readRegistryKey(HKEY parentHandle, const QString &rSubkey)
}
default:
- qWarning("QSettings: unknown data %d type in windows registry", dataType);
+ qWarning("QSettings: unknown data %u type in windows registry", quint32(dataType));
break;
}