summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dist/changes-4.6.38
-rw-r--r--doc/src/development/qmake-manual.qdoc18
-rw-r--r--doc/src/snippets/code/doc_src_deployment.qdoc7
-rw-r--r--doc/src/snippets/code/doc_src_qmake-manual.qdoc4
-rw-r--r--examples/multimedia/audioinput/audioinput.pro1
-rw-r--r--mkspecs/common/symbian/symbian.conf1
-rw-r--r--mkspecs/features/symbian/qt.prf10
-rw-r--r--src/3rdparty/webkit/.gitattributes4
-rw-r--r--src/3rdparty/webkit/ChangeLog8
-rw-r--r--src/3rdparty/webkit/VERSION2
-rw-r--r--src/3rdparty/webkit/WebCore/ChangeLog58
-rw-r--r--src/3rdparty/webkit/WebCore/WebCore.pro13
-rw-r--r--src/3rdparty/webkit/WebCore/page/FrameView.cpp75
-rw-r--r--src/3rdparty/webkit/WebCore/page/FrameView.h7
-rw-r--r--src/3rdparty/webkit/WebCore/platform/ScrollView.cpp7
-rw-r--r--src/3rdparty/webkit/WebCore/platform/ScrollView.h3
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/RenderBlock.h1
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp10
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/RenderBoxModelObject.cpp11
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp15
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h2
-rw-r--r--src/corelib/corelib.pro1
-rw-r--r--src/corelib/io/qfile.cpp46
-rw-r--r--src/corelib/io/qfile_p.h2
-rw-r--r--src/corelib/io/qfsfileengine_p.h4
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp40
-rw-r--r--src/corelib/io/qiodevice.cpp163
-rw-r--r--src/corelib/io/qiodevice_p.h127
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp11
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h2
-rw-r--r--src/declarative/QmlChanges.txt2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable.cpp21
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable_p.h12
-rw-r--r--src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp188
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h8
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h31
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp641
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h25
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p_p.h25
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings.cpp88
-rw-r--r--src/declarative/qml/qdeclarativelist.h4
-rw-r--r--src/declarative/qml/qml.pri2
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp474
-rw-r--r--src/declarative/util/qdeclarativestateoperations_p.h123
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp1
-rw-r--r--src/declarative/util/qdeclarativeview.cpp4
-rw-r--r--src/gui/dialogs/qdialog.cpp14
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp114
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h7
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h67
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp14
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp51
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.h9
-rw-r--r--src/gui/gui.pro1
-rw-r--r--src/gui/kernel/qapplication_s60.cpp45
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp60
-rw-r--r--src/gui/kernel/qsoftkeymanager_p.h5
-rw-r--r--src/gui/kernel/qsoftkeymanager_s60.cpp7
-rw-r--r--src/gui/kernel/qsound.cpp3
-rw-r--r--src/gui/kernel/qt_s60_p.h1
-rw-r--r--src/gui/kernel/qwidget_s60.cpp8
-rw-r--r--src/gui/styles/qs60style.cpp90
-rw-r--r--src/gui/styles/qs60style.h9
-rw-r--r--src/gui/styles/qs60style_p.h9
-rw-r--r--src/gui/styles/qs60style_s60.cpp10
-rw-r--r--src/gui/text/qfontengine.cpp15
-rw-r--r--src/gui/text/qfontengine_p.h3
-rw-r--r--src/gui/text/qfontengine_win.cpp24
-rw-r--r--src/gui/text/qfontengine_win_p.h2
-rw-r--r--src/gui/text/qfontmetrics.cpp21
-rw-r--r--src/gui/text/qtextlayout.cpp6
-rw-r--r--src/gui/widgets/qmenu.cpp4
-rw-r--r--src/gui/widgets/qmenubar.cpp1
-rw-r--r--src/gui/widgets/qspinbox.cpp15
-rw-r--r--src/multimedia/audio/qaudioinput_mac_p.cpp4
-rw-r--r--src/multimedia/audio/qaudiooutput_symbian_p.cpp3
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp9
-rw-r--r--src/network/kernel/qhostinfo.cpp1
-rw-r--r--src/network/kernel/qhostinfo_p.h3
-rw-r--r--src/openvg/qpixmapdata_vg.cpp13
-rw-r--r--src/s60installs/s60installs.pro5
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview0.qml5
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview3.qml2
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp22
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml4
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml4
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml8
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml4
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml4
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp38
-rw-r--r--tests/auto/declarative/visual/animation/reanchor/reanchor.qml15
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp44
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp34
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp28
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp59
-rw-r--r--tests/benchmarks/declarative/declarative.pro2
-rw-r--r--tests/benchmarks/declarative/qmltime/example.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/example.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/qmltime.cpp (renamed from tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp)4
-rw-r--r--tests/benchmarks/declarative/qmltime/qmltime.pro (renamed from tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/anchors/null.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/animation/large.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml)0
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml)4
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml (renamed from tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml)4
126 files changed, 2352 insertions, 1003 deletions
diff --git a/dist/changes-4.6.3 b/dist/changes-4.6.3
index 57cc453..d8e9fb4 100644
--- a/dist/changes-4.6.3
+++ b/dist/changes-4.6.3
@@ -138,6 +138,14 @@ Qt for Windows CE
-
+Qt for Symbian
+--------------
+
+ - [QT-567] Implementation of QtMultimedia QAudio* APIs
+ - [QTBUG-8919] Modified Phonon MMF backend to support video playback on
+ platforms which use graphics surfaces (i.e. platforms using the
+ New Graphics Architecture a.k.a. ScreenPlay)
+
****************************************************************************
* Tools *
****************************************************************************
diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc
index 8cb8705..688122b 100644
--- a/doc/src/development/qmake-manual.qdoc
+++ b/doc/src/development/qmake-manual.qdoc
@@ -1425,12 +1425,20 @@ is the application private directory on the drive it is installed to.
attention that also other statements stay valid. For example if you
override languages statement, you must override also package-header
statement and all other statements which are language specific.
+
+ On the Symbian platform, the \c default_deployment item specifies
+ default platform and package dependencies. Those dependencies can be
+ selectively disabled if alternative dependencies need to be defined
+ - e.g. if a specific device is required to run the application or
+ more languages need to be supported by the package file. The supported
+ \c default_deployment rules that can be disabled are:
- On the Symbian platform, the \c default_deployment item specifies
- default platform dependencies. It can be overwritten if a more
- restrictive set is needed - e.g. if a specific
- device is required to run the application.
-
+ \list
+ \o pkg_depends_qt
+ \o pkg_depends_webkit
+ \o pkg_platform_dependencies
+ \endlist
+
For example:
\snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 141
diff --git a/doc/src/snippets/code/doc_src_deployment.qdoc b/doc/src/snippets/code/doc_src_deployment.qdoc
index 3b0cda1..48e9ac6 100644
--- a/doc/src/snippets/code/doc_src_deployment.qdoc
+++ b/doc/src/snippets/code/doc_src_deployment.qdoc
@@ -463,7 +463,8 @@ vendorinfo = \
"%{\"Example Localized Vendor\"}" \
":\"Example Vendor\""
-default_deployment.pkg_prerules = vendorinfo
+my_deployment.pkg_prerules = vendorinfo
+DEPLOYMENT += my_deployment
//! [56]
//! [57]
@@ -471,7 +472,9 @@ supported_platforms = \
"; This demo only supports S60 5.0" \
"[0x1028315F],0,0,0,{\"S60ProductID\"}"
-default_deployment.pkg_prerules += supported_platforms
+default_deployment.pkg_prerules -= pkg_platform_dependencies
+my_deployment.pkg_prerules += supported_platforms
+DEPLOYMENT += my_deployment
//! [57]
//! [58]
diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.qdoc
index 36676ae..d9e5d3c 100644
--- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc
+++ b/doc/src/snippets/code/doc_src_qmake-manual.qdoc
@@ -933,7 +933,9 @@ DEPLOYMENT += somelib justdep
//! [140]
//! [141]
-default_deployment.pkg_prerules = "[0x11223344],0,0,0,{\"SomeSpecificDeviceID\"}"
+default_deployment.pkg_prerules -= pkg_platform_dependencies
+my_deployment.pkg_prerules = "[0x11223344],0,0,0,{\"SomeSpecificDeviceID\"}"
+DEPLOYMENT += my_deployment
//! [141]
//! [142]
diff --git a/examples/multimedia/audioinput/audioinput.pro b/examples/multimedia/audioinput/audioinput.pro
index a54d452..6a1c79d 100644
--- a/examples/multimedia/audioinput/audioinput.pro
+++ b/examples/multimedia/audioinput/audioinput.pro
@@ -12,5 +12,6 @@ INSTALLS += target sources
symbian {
TARGET.UID3 = 0xA000D7BF
+ TARGET.CAPABILITY += UserEnvironment
include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
}
diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf
index 090f3b6..0b6de5e 100644
--- a/mkspecs/common/symbian/symbian.conf
+++ b/mkspecs/common/symbian/symbian.conf
@@ -113,3 +113,4 @@ QT_ARCH = symbian
load(qt_config)
load(symbian/platform_paths)
+
diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf
index 0d2e6eb..bcb2867 100644
--- a/mkspecs/features/symbian/qt.prf
+++ b/mkspecs/features/symbian/qt.prf
@@ -22,19 +22,23 @@ load(qt)
INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH
# Add dependency to Qt package to all other projects besides Qt libs.
-# Note: Qt libs with full capabilities has UID3 of 0x2001E61C,
+# Note: Qt libs package with full capabilities has UID3 of 0x2001E61C,
# while self-signed version typically has temporary UID3 of 0xE001E61C.
contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C):isEmpty(QT_LIBINFIX) {
- default_deployment.pkg_prerules += \
+ pkg_depends_qt += \
"; Default dependency to Qt libraries" \
"(0x2001E61C), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"Qt\"}"
# Projects linking to webkit need dependency to webkit
contains(QT, webkit): {
- default_deployment.pkg_prerules += \
+ pkg_depends_webkit += \
"; Dependency to Qt Webkit" \
"(0x200267C2), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"QtWebKit\"}"
+ } else {
+ default_deployment.pkg_prerules -= pkg_depends_webkit
}
+} else {
+ default_deployment.pkg_prerules -= pkg_depends_webkit pkg_depends_qt
}
isEmpty(TARGET.EPOCSTACKSIZE):TARGET.EPOCSTACKSIZE = 0x14000
diff --git a/src/3rdparty/webkit/.gitattributes b/src/3rdparty/webkit/.gitattributes
new file mode 100644
index 0000000..5b43bd0
--- /dev/null
+++ b/src/3rdparty/webkit/.gitattributes
@@ -0,0 +1,4 @@
+# To enable automatic merging of ChangeLog files, use the following command:
+# git config merge.changelog.driver "resolve-ChangeLogs --merge-driver %O %A %B"
+ChangeLog* merge=changelog
+
diff --git a/src/3rdparty/webkit/ChangeLog b/src/3rdparty/webkit/ChangeLog
index 1e89d1e..57cb0de 100644
--- a/src/3rdparty/webkit/ChangeLog
+++ b/src/3rdparty/webkit/ChangeLog
@@ -1,3 +1,11 @@
+2010-02-18 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
+
+ Reviewed by Eric Seidel.
+
+ Add .gitattributes file for custom ChangeLog merge-driver
+
+ * .gitattributes: Added.
+
2009-11-30 Jan-Arve Sæther <jan-arve.saether@nokia.com>
Reviewed by Simon Hausmann.
diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION
index a2d5f37..9dac2f8 100644
--- a/src/3rdparty/webkit/VERSION
+++ b/src/3rdparty/webkit/VERSION
@@ -8,4 +8,4 @@ The commit imported was from the
and has the sha1 checksum
- 266a6c4f1938dd9edf4a8125faf91c62495e3ce2
+ aa40cdb9595eb15a68e7be03322f973aa613a8f9
diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog
index a3f70d3..0a444bc 100644
--- a/src/3rdparty/webkit/WebCore/ChangeLog
+++ b/src/3rdparty/webkit/WebCore/ChangeLog
@@ -1,3 +1,61 @@
+2010-03-19 Miikka Heikkinen <miikka.heikkinen@digia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Support for QT_LIBINFIX in Symbian builds
+
+ Configuring Qt with -qtlibinfix parameter will enable installing
+ an alternate version of Qt on devices that already have it on ROM.
+ This patch provides support for infixed builds of Webkit.
+
+ * WebCore.pro:
+
+2010-01-31 Benjamin Poulain <benjamin.poulain@nokia.com>
+
+ Reviewed by Eric Seidel.
+
+ [Qt] Enable FAST_MOBILE_SCROLLING on Qt embedded platforms
+ https://bugs.webkit.org/show_bug.cgi?id=34168
+
+ Enable FAST_MOBILE_SCROLLING for Qt on Maemo 5, Linux embedded
+ and Symbian
+
+ * WebCore.pro:
+
+2010-01-19 Daniel Bates <dbates@rim.com>
+
+ Reviewed by Adam Treat.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33408
+
+ Implements an optimization to ignore fixed background images
+ (i.e. background-attachment: fixed) when a page does not contain
+ any fixed position elements so as to allow fast repaints (via bit
+ blit) when scrolling a page.
+
+ Currently, if a page has elements that specify either a fixed
+ background or a fixed position then we perform a slow repaint
+ (i.e disable blitting) so as to avoid rendering artifacts.
+ However, on low-powered/mobile devices slow repaints can cause
+ noticeable delays when scrolling a page with a fixed background
+ image. By sacrificing support for fixed background images when
+ there are no fixed elements on the page and with come care, we
+ don't need to force slow repaints and can avoid rendering artifacts.
+ Hence, on such devices we can improve the responsiveness of
+ scrolling a page with a fixed background image.
+
+ Note, this optimization is only enabled if the WebKit is built
+ with FAST_MOBILE_SCROLLING enabled.
+
+ Tests: fast/fast-mobile-scrolling/fixed-position-element.html
+ fast/fast-mobile-scrolling/no-fixed-position-elements.html
+
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
+ Disable fixed background attachment if we can blit on scroll.
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::styleWillChange):
+
2010-03-11 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Tor Arne Vestbø.
diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro
index a80eed4..3a50b1a 100644
--- a/src/3rdparty/webkit/WebCore/WebCore.pro
+++ b/src/3rdparty/webkit/WebCore/WebCore.pro
@@ -6,9 +6,12 @@ symbian: {
TARGET.EPOCALLOWDLLDATA=1
TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 // Min 128kB, Max 32MB
TARGET.CAPABILITY = All -Tcb
- TARGET.UID3 = 0x200267C2
-
- webkitlibs.sources = $$QMAKE_LIBDIR_QT/QtWebKit.dll
+ isEmpty(QT_LIBINFIX) {
+ TARGET.UID3 = 0x200267C2
+ } else {
+ TARGET.UID3 = 0xE00267C2
+ }
+ webkitlibs.sources = QtWebKit$${QT_LIBINFIX}.dll
webkitlibs.path = /sys/bin
vendorinfo = \
"; Localised Vendor name" \
@@ -165,6 +168,10 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
DEFINES += ENABLE_SVG_FONTS=0 ENABLE_SVG_FOREIGN_OBJECT=0 ENABLE_SVG_ANIMATION=0 ENABLE_SVG_AS_IMAGE=0 ENABLE_SVG_USE=0
}
+mameo5|symbian|embedded {
+ DEFINES += ENABLE_FAST_MOBILE_SCROLLING=1
+}
+
# HTML5 ruby support
!contains(DEFINES, ENABLE_RUBY=.): DEFINES += ENABLE_RUBY=1
diff --git a/src/3rdparty/webkit/WebCore/page/FrameView.cpp b/src/3rdparty/webkit/WebCore/page/FrameView.cpp
index bc4e4f2..4c3a0ab 100644
--- a/src/3rdparty/webkit/WebCore/page/FrameView.cpp
+++ b/src/3rdparty/webkit/WebCore/page/FrameView.cpp
@@ -106,6 +106,7 @@ struct ScheduledEvent {
FrameView::FrameView(Frame* frame)
: m_frame(frame)
, m_slowRepaintObjectCount(0)
+ , m_fixedObjectCount(0)
, m_layoutTimer(this, &FrameView::layoutTimerFired)
, m_layoutRoot(0)
, m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired)
@@ -735,7 +736,7 @@ String FrameView::mediaType() const
bool FrameView::useSlowRepaints() const
{
- return m_useSlowRepaints || m_slowRepaintObjectCount > 0 || m_isOverlapped || !m_contentIsOpaque;
+ return m_useSlowRepaints || m_slowRepaintObjectCount > 0 || (platformWidget() && m_fixedObjectCount > 0) || m_isOverlapped || !m_contentIsOpaque;
}
void FrameView::setUseSlowRepaints()
@@ -759,6 +760,78 @@ void FrameView::removeSlowRepaintObject()
setCanBlitOnScroll(!useSlowRepaints());
}
+void FrameView::addFixedObject()
+{
+ if (!m_fixedObjectCount && platformWidget())
+ setCanBlitOnScroll(false);
+ ++m_fixedObjectCount;
+}
+
+void FrameView::removeFixedObject()
+{
+ ASSERT(m_fixedObjectCount > 0);
+ m_fixedObjectCount--;
+ if (!m_fixedObjectCount)
+ setCanBlitOnScroll(!useSlowRepaints());
+}
+
+void FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
+{
+ const size_t fixedObjectThreshold = 5;
+
+ ListHashSet<RenderBox*>* positionedObjects = 0;
+ if (RenderView* root = m_frame->contentRenderer())
+ positionedObjects = root->positionedObjects();
+
+ if (!positionedObjects || positionedObjects->isEmpty()) {
+ hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
+ return;
+ }
+
+ // Get the rects of the fixed objects visible in the rectToScroll
+ Vector<IntRect, fixedObjectThreshold> subRectToUpdate;
+ bool updateInvalidatedSubRect = true;
+ ListHashSet<RenderBox*>::const_iterator end = positionedObjects->end();
+ for (ListHashSet<RenderBox*>::const_iterator it = positionedObjects->begin(); it != end; ++it) {
+ RenderBox* renderBox = *it;
+ if (renderBox->style()->position() != FixedPosition)
+ continue;
+ IntRect topLevelRect;
+ IntRect updateRect = renderBox->paintingRootRect(topLevelRect);
+ updateRect.move(-scrollX(), -scrollY());
+ updateRect.intersect(rectToScroll);
+ if (!updateRect.isEmpty()) {
+ if (subRectToUpdate.size() >= fixedObjectThreshold) {
+ updateInvalidatedSubRect = false;
+ break;
+ }
+ subRectToUpdate.append(updateRect);
+ }
+ }
+
+ // Scroll the view
+ if (updateInvalidatedSubRect) {
+ // 1) scroll
+ hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
+
+ // 2) update the area of fixed objets that has been invalidated
+ size_t fixObjectsCount = subRectToUpdate.size();
+ for (size_t i = 0; i < fixObjectsCount; ++i) {
+ IntRect updateRect = subRectToUpdate[i];
+ IntRect scrolledRect = updateRect;
+ scrolledRect.move(scrollDelta);
+ updateRect.unite(scrolledRect);
+ updateRect.intersect(rectToScroll);
+ hostWindow()->repaint(updateRect, true, false, true);
+ }
+ } else {
+ // the number of fixed objects exceed the threshold, so we repaint everything.
+ IntRect updateRect = clipRect;
+ updateRect.intersect(rectToScroll);
+ hostWindow()->repaint(updateRect, true, false, true);
+ }
+}
+
void FrameView::setIsOverlapped(bool isOverlapped)
{
if (isOverlapped == m_isOverlapped)
diff --git a/src/3rdparty/webkit/WebCore/page/FrameView.h b/src/3rdparty/webkit/WebCore/page/FrameView.h
index 3d17d2c..5243c02 100644
--- a/src/3rdparty/webkit/WebCore/page/FrameView.h
+++ b/src/3rdparty/webkit/WebCore/page/FrameView.h
@@ -143,6 +143,9 @@ public:
void addSlowRepaintObject();
void removeSlowRepaintObject();
+ void addFixedObject();
+ void removeFixedObject();
+
void beginDeferredRepaints();
void endDeferredRepaints();
void checkStopDelayingDeferredRepaints();
@@ -196,6 +199,9 @@ public:
bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; }
void invalidateScrollCorner();
+protected:
+ virtual void scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
+
private:
FrameView(Frame*);
@@ -261,6 +267,7 @@ private:
bool m_isOverlapped;
bool m_contentIsOpaque;
unsigned m_slowRepaintObjectCount;
+ unsigned m_fixedObjectCount;
int m_borderX, m_borderY;
diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp
index e67daf9..9e15c43 100644
--- a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp
@@ -509,7 +509,7 @@ void ScrollView::scrollContents(const IntSize& scrollDelta)
if (canBlitOnScroll()) { // The main frame can just blit the WebView window
// FIXME: Find a way to blit subframes without blitting overlapping content
- hostWindow()->scroll(-scrollDelta, scrollViewRect, clipRect);
+ scrollContentsFastPath(-scrollDelta, scrollViewRect, clipRect);
} else {
// We need to go ahead and repaint the entire backing store. Do it now before moving the
// windowed plugins.
@@ -524,6 +524,11 @@ void ScrollView::scrollContents(const IntSize& scrollDelta)
hostWindow()->paint();
}
+void ScrollView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
+{
+ hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
+}
+
IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const
{
IntPoint viewPoint = convertFromContainingWindow(windowPoint);
diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.h b/src/3rdparty/webkit/WebCore/platform/ScrollView.h
index 5dacff5..7060d07 100644
--- a/src/3rdparty/webkit/WebCore/platform/ScrollView.h
+++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.h
@@ -244,6 +244,9 @@ protected:
IntRect scrollCornerRect() const;
virtual void updateScrollCorner();
virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect);
+
+ // Scroll the content by blitting the pixels
+ virtual void scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
private:
RefPtr<Scrollbar> m_horizontalScrollbar;
diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h
index 7ba5fce..3300d01 100644
--- a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h
+++ b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h
@@ -75,6 +75,7 @@ public:
void insertPositionedObject(RenderBox*);
void removePositionedObject(RenderBox*);
void removePositionedObjects(RenderBlock*);
+ ListHashSet<RenderBox*>* positionedObjects() const { return m_positionedObjects; }
void addPercentHeightDescendant(RenderBox*);
static void removePercentHeightDescendant(RenderBox*);
diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp
index 1df82a4..7ca2ff8 100644
--- a/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp
+++ b/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp
@@ -145,6 +145,16 @@ void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyl
removeFloatingOrPositionedChildFromBlockLists();
}
}
+ if (FrameView *frameView = view()->frameView()) {
+ bool newStyleIsFixed = newStyle && newStyle->position() == FixedPosition;
+ bool oldStyleIsFixed = style() && style()->position() == FixedPosition;
+ if (newStyleIsFixed != oldStyleIsFixed) {
+ if (newStyleIsFixed)
+ frameView->addFixedObject();
+ else
+ frameView->removeFixedObject();
+ }
+ }
RenderBoxModelObject::styleWillChange(diff, newStyle);
}
diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBoxModelObject.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBoxModelObject.cpp
index 23dad2d..9d0f1ed 100644
--- a/src/3rdparty/webkit/WebCore/rendering/RenderBoxModelObject.cpp
+++ b/src/3rdparty/webkit/WebCore/rendering/RenderBoxModelObject.cpp
@@ -557,6 +557,17 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil
// Determine the background positioning area and set destRect to the background painting area.
// destRect will be adjusted later if the background is non-repeating.
bool fixedAttachment = fillLayer->attachment() == FixedBackgroundAttachment;
+
+#if ENABLE(FAST_MOBILE_SCROLLING)
+ if (view()->frameView() && view()->frameView()->canBlitOnScroll()) {
+ // As a side effect of an optimization to blit on scroll, we do not honor the CSS
+ // property "background-attachment: fixed" because it may result in rendering
+ // artifacts. Note, these artifacts only appear if we are blitting on scroll of
+ // a page that has fixed background images.
+ fixedAttachment = false;
+ }
+#endif
+
if (!fixedAttachment) {
destRect = IntRect(tx, ty, w, h);
diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp
index a10ffd9..199de4a 100644
--- a/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp
+++ b/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp
@@ -1591,10 +1591,17 @@ void RenderObject::styleWillChange(StyleDifference diff, const RenderStyle* newS
s_affectsParentBlock = false;
if (view()->frameView()) {
- // FIXME: A better solution would be to only invalidate the fixed regions when scrolling. It's overkill to
- // prevent the entire view from blitting on a scroll.
- bool newStyleSlowScroll = newStyle && (newStyle->position() == FixedPosition || newStyle->hasFixedBackgroundImage());
- bool oldStyleSlowScroll = m_style && (m_style->position() == FixedPosition || m_style->hasFixedBackgroundImage());
+ bool shouldBlitOnFixedBackgroundImage = false;
+#if ENABLE(FAST_MOBILE_SCROLLING)
+ // On low-powered/mobile devices, preventing blitting on a scroll can cause noticeable delays
+ // when scrolling a page with a fixed background image. As an optimization, assuming there are
+ // no fixed positoned elements on the page, we can acclerate scrolling (via blitting) if we
+ // ignore the CSS property "background-attachment: fixed".
+ shouldBlitOnFixedBackgroundImage = true;
+#endif
+
+ bool newStyleSlowScroll = newStyle && !shouldBlitOnFixedBackgroundImage && newStyle->hasFixedBackgroundImage();
+ bool oldStyleSlowScroll = m_style && !shouldBlitOnFixedBackgroundImage && m_style->hasFixedBackgroundImage();
if (oldStyleSlowScroll != newStyleSlowScroll) {
if (oldStyleSlowScroll)
view()->frameView()->removeSlowRepaintObject();
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h
index 68379a2..f983ae4 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h
@@ -134,10 +134,10 @@ protected:
private:
Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success))
+ Q_PRIVATE_SLOT(d, void _q_updateMicroFocus())
QGraphicsWebViewPrivate* const d;
friend class QGraphicsWebViewPrivate;
};
#endif // QGraphicsWebView_h
- Q_PRIVATE_SLOT(d, void _q_updateMicroFocus())
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 500cde6..83fa044 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -38,7 +38,6 @@ symbian: {
# Partial upgrade SIS file
vendorinfo = \
- "&EN" \
"; Localised Vendor name" \
"%{\"Nokia, Qt\"}" \
" " \
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index aa1c7d9..50e9a8f 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -90,7 +90,8 @@ QFile::DecoderFn QFilePrivate::decoder = locale_decode;
QFilePrivate::QFilePrivate()
: fileEngine(0), lastWasWrite(false),
- writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError)
+ writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError),
+ cachedSize(0)
{
}
@@ -1257,8 +1258,10 @@ QFile::resize(qint64 sz)
seek(sz);
if(d->fileEngine->setSize(sz)) {
unsetError();
+ d->cachedSize = sz;
return true;
}
+ d->cachedSize = 0;
d->setError(QFile::ResizeError, d->fileEngine->errorString());
return false;
}
@@ -1420,7 +1423,8 @@ qint64 QFile::size() const
Q_D(const QFile);
if (!d->ensureFlushed())
return 0;
- return fileEngine()->size();
+ d->cachedSize = fileEngine()->size();
+ return d->cachedSize;
}
/*!
@@ -1446,16 +1450,16 @@ bool QFile::atEnd() const
{
Q_D(const QFile);
+ // If there's buffered data left, we're not at the end.
+ if (!d->buffer.isEmpty())
+ return false;
+
if (!isOpen())
return true;
if (!d->ensureFlushed())
return false;
- // If there's buffered data left, we're not at the end.
- if (!d->buffer.isEmpty())
- return false;
-
// If the file engine knows best, say what it says.
if (d->fileEngine->supportsExtension(QAbstractFileEngine::AtEndExtension)) {
// Check if the file engine supports AtEndExtension, and if it does,
@@ -1463,6 +1467,11 @@ bool QFile::atEnd() const
return d->fileEngine->atEnd();
}
+ // if it looks like we are at the end, or if size is not cached,
+ // fall through to bytesAvailable() to make sure.
+ if (pos() < d->cachedSize)
+ return false;
+
// Fall back to checking how much is available (will stat files).
return bytesAvailable() == 0;
}
@@ -1502,12 +1511,21 @@ qint64 QFile::readLineData(char *data, qint64 maxlen)
if (!d->ensureFlushed())
return -1;
- if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension))
- return d->fileEngine->readLine(data, maxlen);
+ qint64 read;
+ if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension)) {
+ read = d->fileEngine->readLine(data, maxlen);
+ } else {
+ // Fall back to QIODevice's readLine implementation if the engine
+ // cannot do it faster.
+ read = QIODevice::readLineData(data, maxlen);
+ }
+
+ if (read < maxlen) {
+ // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked
+ d->cachedSize = 0;
+ }
- // Fall back to QIODevice's readLine implementation if the engine
- // cannot do it faster.
- return QIODevice::readLineData(data, maxlen);
+ return read;
}
/*!
@@ -1528,6 +1546,12 @@ qint64 QFile::readData(char *data, qint64 len)
err = QFile::ReadError;
d->setError(err, d->fileEngine->errorString());
}
+
+ if (read < len) {
+ // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked
+ d->cachedSize = 0;
+ }
+
return read;
}
diff --git a/src/corelib/io/qfile_p.h b/src/corelib/io/qfile_p.h
index f8f5f5c..cf76c09 100644
--- a/src/corelib/io/qfile_p.h
+++ b/src/corelib/io/qfile_p.h
@@ -84,6 +84,8 @@ protected:
void setError(QFile::FileError err, const QString &errorString);
void setError(QFile::FileError err, int errNum);
+ mutable qint64 cachedSize;
+
private:
static QFile::EncoderFn encoder;
static QFile::DecoderFn decoder;
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index d07c3a0..365652a 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -151,6 +151,10 @@ public:
static bool uncListSharesOnServer(const QString &server, QStringList *list);
#endif
+#ifdef Q_OS_SYMBIAN
+ void setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString);
+#endif
+
protected:
QFSFileEnginePrivate();
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 3dcc1ad..1415e44 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -81,6 +81,40 @@ static bool isRelativePathSymbian(const QString& fileName)
&& ((fileName.at(0).isLetter() && fileName.at(1) == QLatin1Char(':'))
|| (fileName.at(0) == QLatin1Char('/') && fileName.at(1) == QLatin1Char('/')))));
}
+
+/*!
+ \internal
+ convert symbian error code to the one suitable for setError.
+ example usage: setSymbianError(err, QFile::CopyError, QLatin1String("copy error"))
+*/
+void QFSFileEnginePrivate::setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString)
+{
+ Q_Q(QFSFileEngine);
+ switch (symbianError) {
+ case KErrNone:
+ q->setError(QFile::NoError, QLatin1String(""));
+ break;
+ case KErrAccessDenied:
+ q->setError(QFile::PermissionsError, QLatin1String("access denied"));
+ break;
+ case KErrPermissionDenied:
+ q->setError(QFile::PermissionsError, QLatin1String("permission denied"));
+ break;
+ case KErrAbort:
+ q->setError(QFile::AbortError, QLatin1String("aborted"));
+ break;
+ case KErrCancel:
+ q->setError(QFile::AbortError, QLatin1String("cancelled"));
+ break;
+ case KErrTimedOut:
+ q->setError(QFile::TimeOutError, QLatin1String("timed out"));
+ break;
+ default:
+ q->setError(defaultError, defaultString);
+ break;
+ }
+}
+
#endif
/*!
@@ -427,8 +461,10 @@ bool QFSFileEngine::copy(const QString &newName)
}
) // End TRAP
delete fm;
- // ### Add error reporting on failure
- return (err == KErrNone);
+ if (err == KErrNone)
+ return true;
+ d->setSymbianError(err, QFile::CopyError, QLatin1String("copy error"));
+ return false;
#else
Q_UNUSED(newName);
// ### Add copy code for Unix here
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index c93f0c3..f83c142 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -84,10 +84,6 @@ void debugBinaryString(const char *data, qint64 maxlen)
}
#endif
-#ifndef QIODEVICE_BUFFERSIZE
-#define QIODEVICE_BUFFERSIZE Q_INT64_C(16384)
-#endif
-
#define Q_VOID
#define CHECK_MAXLEN(function, returnType) \
@@ -123,7 +119,9 @@ void debugBinaryString(const char *data, qint64 maxlen)
QIODevicePrivate::QIODevicePrivate()
: openMode(QIODevice::NotOpen), buffer(QIODEVICE_BUFFERSIZE),
pos(0), devicePos(0)
+ , pPos(&pos), pDevicePos(&devicePos)
, baseReadLineDataCalled(false)
+ , firstRead(true)
, accessMode(Unset)
#ifdef QT_NO_QOBJECT
, q_ptr(0)
@@ -449,11 +447,15 @@ QIODevice::OpenMode QIODevice::openMode() const
*/
void QIODevice::setOpenMode(OpenMode openMode)
{
+ Q_D(QIODevice);
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::setOpenMode(0x%x)\n", this, int(openMode));
#endif
- d_func()->openMode = openMode;
- d_func()->accessMode = QIODevicePrivate::Unset;
+ d->openMode = openMode;
+ d->accessMode = QIODevicePrivate::Unset;
+ d->firstRead = true;
+ if (!isReadable())
+ d->buffer.clear();
}
/*!
@@ -537,6 +539,7 @@ bool QIODevice::open(OpenMode mode)
d->pos = (mode & Append) ? size() : qint64(0);
d->buffer.clear();
d->accessMode = QIODevicePrivate::Unset;
+ d->firstRead = true;
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::open(0x%x)\n", this, quint32(mode));
#endif
@@ -566,6 +569,7 @@ void QIODevice::close()
d->errorString.clear();
d->pos = 0;
d->buffer.clear();
+ d->firstRead = true;
}
/*!
@@ -729,6 +733,12 @@ qint64 QIODevice::bytesToWrite() const
return qint64(0);
}
+#ifdef Q_CC_RVCT
+// arm mode makes the 64-bit integer operations much faster in RVCT 2.2
+#pragma push
+#pragma arm
+#endif
+
/*!
Reads at most \a maxSize bytes from the device into \a data, and
returns the number of bytes read. If an error occurs, such as when
@@ -745,21 +755,17 @@ qint64 QIODevice::bytesToWrite() const
qint64 QIODevice::read(char *data, qint64 maxSize)
{
Q_D(QIODevice);
- CHECK_READABLE(read, qint64(-1));
- CHECK_MAXLEN(read, qint64(-1));
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::read(%p, %d), d->pos = %d, d->buffer.size() = %d\n",
this, data, int(maxSize), int(d->pos), int(d->buffer.size()));
#endif
- const bool sequential = d->isSequential();
// Short circuit for getChar()
if (maxSize == 1) {
int chint;
while ((chint = d->buffer.getChar()) != -1) {
- if (!sequential)
- ++d->pos;
+ ++(*d->pPos);
char c = char(uchar(chint));
if (c == '\r' && (d->openMode & Text))
@@ -773,61 +779,77 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
}
}
+ CHECK_MAXLEN(read, qint64(-1));
qint64 readSoFar = 0;
bool moreToRead = true;
do {
- int lastReadChunkSize = 0;
-
// Try reading from the buffer.
- if (!d->buffer.isEmpty()) {
- lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar);
- readSoFar += lastReadChunkSize;
- if (!sequential)
- d->pos += lastReadChunkSize;
+ int lastReadChunkSize = d->buffer.read(data, maxSize);
+ *d->pPos += lastReadChunkSize;
+ readSoFar += lastReadChunkSize;
+ // fast exit when satisfied by buffer
+ if (lastReadChunkSize == maxSize && !(d->openMode & Text))
+ return readSoFar;
+
+ if (lastReadChunkSize > 0) {
+ data += lastReadChunkSize;
+ maxSize -= lastReadChunkSize;
#if defined QIODEVICE_DEBUG
printf("%p \treading %d bytes from buffer into position %d\n", this, lastReadChunkSize,
int(readSoFar) - lastReadChunkSize);
#endif
- } else if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) {
- // In buffered mode, we try to fill up the QIODevice buffer before
- // we do anything else.
- int bytesToBuffer = qMax(maxSize - readSoFar, QIODEVICE_BUFFERSIZE);
- char *writePointer = d->buffer.reserve(bytesToBuffer);
-
- // Make sure the device is positioned correctly.
- if (d->pos != d->devicePos && !sequential && !seek(d->pos))
- return qint64(-1);
- qint64 readFromDevice = readData(writePointer, bytesToBuffer);
- d->buffer.chop(bytesToBuffer - (readFromDevice < 0 ? 0 : int(readFromDevice)));
+ } else {
+ if (d->firstRead) {
+ // this is the first time the file has been read, check it's valid and set up pos pointers
+ // for fast pos updates.
+ CHECK_READABLE(read, qint64(-1));
+ d->firstRead = false;
+ if (d->isSequential()) {
+ d->pPos = &d->seqDumpPos;
+ d->pDevicePos = &d->seqDumpPos;
+ }
+ }
- if (readFromDevice > 0) {
- if (!sequential)
- d->devicePos += readFromDevice;
+ if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) {
+ // In buffered mode, we try to fill up the QIODevice buffer before
+ // we do anything else.
+ // buffer is empty at this point, try to fill it
+ int bytesToBuffer = QIODEVICE_BUFFERSIZE;
+ char *writePointer = d->buffer.reserve(bytesToBuffer);
+
+ // Make sure the device is positioned correctly.
+ if (d->pos != d->devicePos && !d->isSequential() && !seek(d->pos))
+ return readSoFar ? readSoFar : qint64(-1);
+ qint64 readFromDevice = readData(writePointer, bytesToBuffer);
+ d->buffer.chop(bytesToBuffer - (readFromDevice < 0 ? 0 : int(readFromDevice)));
+
+ if (readFromDevice > 0) {
+ *d->pDevicePos += readFromDevice;
#if defined QIODEVICE_DEBUG
- printf("%p \treading %d from device into buffer\n", this, int(readFromDevice));
+ printf("%p \treading %d from device into buffer\n", this, int(readFromDevice));
#endif
- if (readFromDevice < bytesToBuffer)
- d->buffer.truncate(int(readFromDevice));
- if (!d->buffer.isEmpty()) {
- lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar);
- readSoFar += lastReadChunkSize;
- if (!sequential)
- d->pos += lastReadChunkSize;
+ if (!d->buffer.isEmpty()) {
+ lastReadChunkSize = d->buffer.read(data, maxSize);
+ readSoFar += lastReadChunkSize;
+ data += lastReadChunkSize;
+ maxSize -= lastReadChunkSize;
+ *d->pPos += lastReadChunkSize;
#if defined QIODEVICE_DEBUG
- printf("%p \treading %d bytes from buffer at position %d\n", this,
- lastReadChunkSize, int(readSoFar));
+ printf("%p \treading %d bytes from buffer at position %d\n", this,
+ lastReadChunkSize, int(readSoFar));
#endif
+ }
}
}
}
// If we need more, try reading from the device.
- if (readSoFar < maxSize) {
+ if (maxSize > 0) {
// Make sure the device is positioned correctly.
- if (d->pos != d->devicePos && !sequential && !seek(d->pos))
- return qint64(-1);
- qint64 readFromDevice = readData(data + readSoFar, maxSize - readSoFar);
+ if (d->pos != d->devicePos && !d->isSequential() && !seek(d->pos))
+ return readSoFar ? readSoFar : qint64(-1);
+ qint64 readFromDevice = readData(data, maxSize);
#if defined QIODEVICE_DEBUG
printf("%p \treading %d bytes from device (total %d)\n", this, int(readFromDevice), int(readSoFar));
#endif
@@ -835,27 +857,21 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
// error and we haven't read anything: return immediately
return -1;
}
- if (readFromDevice <= 0) {
- moreToRead = false;
- } else {
- // see if we read as much data as we asked for
- if (readFromDevice < maxSize - readSoFar)
- moreToRead = false;
-
+ if (readFromDevice > 0) {
lastReadChunkSize += int(readFromDevice);
readSoFar += readFromDevice;
- if (!sequential) {
- d->pos += readFromDevice;
- d->devicePos += readFromDevice;
- }
+ data += readFromDevice;
+ maxSize -= readFromDevice;
+ *d->pPos += readFromDevice;
+ *d->pDevicePos += readFromDevice;
}
- } else {
- moreToRead = false;
}
+ // Best attempt has been made to read data, don't try again except for text mode adjustment below
+ moreToRead = false;
if (readSoFar && d->openMode & Text) {
- char *readPtr = data + readSoFar - lastReadChunkSize;
- const char *endPtr = data + readSoFar;
+ char *readPtr = data - lastReadChunkSize;
+ const char *endPtr = data;
if (readPtr < endPtr) {
// optimization to avoid initial self-assignment
@@ -870,8 +886,11 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
char ch = *readPtr++;
if (ch != '\r')
*writePtr++ = ch;
- else
+ else {
--readSoFar;
+ --data;
+ ++maxSize;
+ }
}
// Make sure we get more data if there is room for more. This
@@ -885,11 +904,15 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
#if defined QIODEVICE_DEBUG
printf("%p \treturning %d, d->pos == %d, d->buffer.size() == %d\n", this,
int(readSoFar), int(d->pos), d->buffer.size());
- debugBinaryString(data, readSoFar);
+ debugBinaryString(data - readSoFar, readSoFar);
#endif
return readSoFar;
}
+#ifdef Q_CC_RVCT
+#pragma pop
+#endif
+
/*!
\overload
@@ -997,6 +1020,12 @@ QByteArray QIODevice::readAll()
return result;
}
+#ifdef Q_CC_RVCT
+// arm mode makes the 64-bit integer operations much faster in RVCT 2.2
+#pragma push
+#pragma arm
+#endif
+
/*!
This function reads a line of ASCII characters from the device, up
to a maximum of \a maxSize - 1 bytes, stores the characters in \a
@@ -1229,6 +1258,10 @@ qint64 QIODevice::readLineData(char *data, qint64 maxSize)
return readSoFar;
}
+#ifdef Q_CC_RVCT
+#pragma pop
+#endif
+
/*!
Returns true if a complete line of data can be read from the device;
otherwise returns false.
@@ -1416,9 +1449,7 @@ bool QIODevicePrivate::putCharHelper(char c)
*/
bool QIODevice::getChar(char *c)
{
- Q_D(QIODevice);
- CHECK_READABLE(getChar, false);
-
+ // readability checked in read()
char ch;
return (1 == read(c ? c : &ch, 1));
}
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index cc4a237..94dadca 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -64,6 +64,126 @@
QT_BEGIN_NAMESPACE
+#ifndef QIODEVICE_BUFFERSIZE
+#define QIODEVICE_BUFFERSIZE Q_INT64_C(16384)
+#endif
+
+// This is QIODevice's read buffer, optimised for read(), isEmpty() and getChar()
+class QIODevicePrivateLinearBuffer
+{
+public:
+ QIODevicePrivateLinearBuffer(int) : len(0), first(0), buf(0), capacity(0) {
+ }
+ ~QIODevicePrivateLinearBuffer() {
+ delete [] buf;
+ }
+ void clear() {
+ first = buf;
+ len = 0;
+ }
+ int size() const {
+ return len;
+ }
+ bool isEmpty() const {
+ return len == 0;
+ }
+ void skip(int n) {
+ if (n >= len) {
+ clear();
+ } else {
+ len -= n;
+ first += n;
+ }
+ }
+ int getChar() {
+ if (len == 0)
+ return -1;
+ int ch = uchar(*first);
+ len--;
+ first++;
+ return ch;
+ }
+ int read(char* target, int size) {
+ int r = qMin(size, len);
+ memcpy(target, first, r);
+ len -= r;
+ first += r;
+ return r;
+ }
+ char* reserve(int size) {
+ makeSpace(size + len, freeSpaceAtEnd);
+ char* writePtr = first + len;
+ len += size;
+ return writePtr;
+ }
+ void chop(int size) {
+ if (size >= len) {
+ clear();
+ } else {
+ len -= size;
+ }
+ }
+ QByteArray readAll() {
+ char* f = first;
+ int l = len;
+ clear();
+ return QByteArray(f, l);
+ }
+ int readLine(char* target, int size) {
+ int r = qMin(size, len);
+ char* eol = static_cast<char*>(memchr(first, '\n', r));
+ if (eol)
+ r = 1+(eol-first);
+ memcpy(target, first, r);
+ len -= r;
+ first += r;
+ return int(r);
+ }
+ bool canReadLine() const {
+ return memchr(first, '\n', len);
+ }
+ void ungetChar(char c) {
+ if (first == buf) {
+ // underflow, the existing valid data needs to move to the end of the (potentially bigger) buffer
+ makeSpace(len+1, freeSpaceAtStart);
+ }
+ first--;
+ len++;
+ *first = c;
+ }
+
+private:
+ enum FreeSpacePos {freeSpaceAtStart, freeSpaceAtEnd};
+ void makeSpace(size_t required, FreeSpacePos where) {
+ size_t newCapacity = qMax(capacity, size_t(QIODEVICE_BUFFERSIZE));
+ while (newCapacity < required)
+ newCapacity *= 2;
+ int moveOffset = (where == freeSpaceAtEnd) ? 0 : newCapacity - len;
+ if (newCapacity > capacity) {
+ // allocate more space
+ char* newBuf = new char[newCapacity];
+ memmove(newBuf + moveOffset, first, len);
+ delete [] buf;
+ buf = newBuf;
+ capacity = newCapacity;
+ } else {
+ // shift any existing data to make space
+ memmove(buf + moveOffset, first, len);
+ }
+ first = buf + moveOffset;
+ }
+
+private:
+ // length of the unread data
+ int len;
+ // start of the unread data
+ char* first;
+ // the allocated buffer
+ char* buf;
+ // allocated buffer size
+ size_t capacity;
+};
+
class Q_CORE_EXPORT QIODevicePrivate
#ifndef QT_NO_QOBJECT
: public QObjectPrivate
@@ -78,10 +198,15 @@ public:
QIODevice::OpenMode openMode;
QString errorString;
- QRingBuffer buffer;
+ QIODevicePrivateLinearBuffer buffer;
qint64 pos;
qint64 devicePos;
+ // these three are for fast position updates during read, avoiding isSequential test
+ qint64 seqDumpPos;
+ qint64 *pPos;
+ qint64 *pDevicePos;
bool baseReadLineDataCalled;
+ bool firstRead;
virtual bool putCharHelper(char c);
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index bd7e626..9d5c49f 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1175,6 +1175,16 @@ void QStateMachinePrivate::removeStartState()
_startState = 0;
}
+void QStateMachinePrivate::clearHistory()
+{
+ Q_Q(QStateMachine);
+ QList<QHistoryState*> historyStates = qFindChildren<QHistoryState*>(q);
+ for (int i = 0; i < historyStates.size(); ++i) {
+ QHistoryState *h = historyStates.at(i);
+ QHistoryStatePrivate::get(h)->configuration.clear();
+ }
+}
+
void QStateMachinePrivate::_q_start()
{
Q_Q(QStateMachine);
@@ -1186,6 +1196,7 @@ void QStateMachinePrivate::_q_start()
internalEventQueue.clear();
qDeleteAll(externalEventQueue);
externalEventQueue.clear();
+ clearHistory();
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": starting";
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index 0fead5d..5e1015f 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -126,6 +126,8 @@ public:
QState *startState();
void removeStartState();
+ void clearHistory();
+
void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList);
bool isPreempted(const QAbstractState *s, const QSet<QAbstractTransition*> &transitions) const;
QSet<QAbstractTransition*> selectTransitions(QEvent *event) const;
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 2a35dda..9a55bde 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -13,6 +13,8 @@ AnchorAnimation must now be used to animate anchor changes (and not NumberAnimat
Removed ParentAction (use ParentAnimation instead)
ScriptAction: renamed stateChangeScriptName -> scriptName
Animation: replace repeat with loops (loops: Animation.Infinite gives the old repeat behavior)
+AnchorChanges: use natural form to specify anchors (anchors.left instead of left)
+AnchorChanges: removed reset property. (reset: "left" should now be anchors.left: undefined)
C++ API
-------
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
index a7534b8..f92c207 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
@@ -444,7 +444,7 @@ void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem
const QDeclarativeScaleGrid *border = d->getScaleGrid();
QMargins margins(border->left(), border->top(), border->right(), border->bottom());
QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode);
- qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules);
+ qDrawBorderPixmap(p, QRect(0, 0, (int)d->width(), (int)d->height()), margins, d->pix, d->pix.rect(), margins, rules);
if (d->smooth) {
p->setRenderHint(QPainter::Antialiasing, oldAA);
p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 9ccb3b6..98502fd 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -990,10 +990,10 @@ QDeclarativeListProperty<QObject> QDeclarativeFlickable::flickableData()
return QDeclarativeListProperty<QObject>(this, (void *)d, QDeclarativeFlickablePrivate::data_append);
}
-QDeclarativeListProperty<QDeclarativeItem> QDeclarativeFlickable::flickableChildren()
+QDeclarativeListProperty<QGraphicsObject> QDeclarativeFlickable::flickableChildren()
{
Q_D(QDeclarativeFlickable);
- return d->viewport->fxChildren();
+ return QGraphicsItemPrivate::get(d->viewport)->childrenList();
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
index 7dcab98..1fa2c74 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
@@ -82,7 +82,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
Q_PROPERTY(QDeclarativeFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> flickableChildren READ flickableChildren)
+ Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> flickableChildren READ flickableChildren)
Q_CLASSINFO("DefaultProperty", "flickableData")
Q_ENUMS(FlickDirection)
@@ -92,7 +92,7 @@ public:
~QDeclarativeFlickable();
QDeclarativeListProperty<QObject> flickableData();
- QDeclarativeListProperty<QDeclarativeItem> flickableChildren();
+ QDeclarativeListProperty<QGraphicsObject> flickableChildren();
bool overShoot() const;
void setOverShoot(bool);
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
index 0e2ae63..cb4044f 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
@@ -59,8 +59,8 @@ public:
void updateSceneTransformFromParent();
QDeclarativeFlipable::Side current;
- QDeclarativeGuard<QDeclarativeItem> front;
- QDeclarativeGuard<QDeclarativeItem> back;
+ QDeclarativeGuard<QGraphicsObject> front;
+ QDeclarativeGuard<QGraphicsObject> back;
};
/*!
@@ -112,13 +112,13 @@ QDeclarativeFlipable::~QDeclarativeFlipable()
The front and back sides of the flipable.
*/
-QDeclarativeItem *QDeclarativeFlipable::front()
+QGraphicsObject *QDeclarativeFlipable::front()
{
Q_D(const QDeclarativeFlipable);
return d->front;
}
-void QDeclarativeFlipable::setFront(QDeclarativeItem *front)
+void QDeclarativeFlipable::setFront(QGraphicsObject *front)
{
Q_D(QDeclarativeFlipable);
if (d->front) {
@@ -131,13 +131,13 @@ void QDeclarativeFlipable::setFront(QDeclarativeItem *front)
d->front->setOpacity(0.);
}
-QDeclarativeItem *QDeclarativeFlipable::back()
+QGraphicsObject *QDeclarativeFlipable::back()
{
Q_D(const QDeclarativeFlipable);
return d->back;
}
-void QDeclarativeFlipable::setBack(QDeclarativeItem *back)
+void QDeclarativeFlipable::setBack(QGraphicsObject *back)
{
Q_D(QDeclarativeFlipable);
if (d->back) {
@@ -195,12 +195,13 @@ void QDeclarativeFlipablePrivate::updateSceneTransformFromParent()
current = newSide;
if (current == QDeclarativeFlipable::Back && back) {
QTransform mat;
- mat.translate(back->width()/2,back->height()/2);
- if (back->width() && p1.x() >= p2.x())
+ QGraphicsItemPrivate *dBack = QGraphicsItemPrivate::get(back);
+ mat.translate(dBack->width()/2,dBack->height()/2);
+ if (dBack->width() && p1.x() >= p2.x())
mat.rotate(180, Qt::YAxis);
- if (back->height() && p2.y() >= p3.y())
+ if (dBack->height() && p2.y() >= p3.y())
mat.rotate(180, Qt::XAxis);
- mat.translate(-back->width()/2,-back->height()/2);
+ mat.translate(-dBack->width()/2,-dBack->height()/2);
back->setTransform(mat);
}
if (front)
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable_p.h b/src/declarative/graphicsitems/qdeclarativeflipable_p.h
index 8b9c24c..302f083 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflipable_p.h
@@ -60,8 +60,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlipable : public QDeclarativeItem
Q_OBJECT
Q_ENUMS(Side)
- Q_PROPERTY(QDeclarativeItem *front READ front WRITE setFront)
- Q_PROPERTY(QDeclarativeItem *back READ back WRITE setBack)
+ Q_PROPERTY(QGraphicsObject *front READ front WRITE setFront)
+ Q_PROPERTY(QGraphicsObject *back READ back WRITE setBack)
Q_PROPERTY(Side side READ side NOTIFY sideChanged)
//### flipAxis
//### flipRotation
@@ -69,11 +69,11 @@ public:
QDeclarativeFlipable(QDeclarativeItem *parent=0);
~QDeclarativeFlipable();
- QDeclarativeItem *front();
- void setFront(QDeclarativeItem *);
+ QGraphicsObject *front();
+ void setFront(QGraphicsObject *);
- QDeclarativeItem *back();
- void setBack(QDeclarativeItem *);
+ QGraphicsObject *back();
+ void setBack(QGraphicsObject *);
enum Side { Front, Back };
Side side() const;
diff --git a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
index eb5b6ce..ff85bbd 100644
--- a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
@@ -65,12 +65,12 @@ public:
if (graphicsObject && graphicsObject->isWidget()) {
if (!on) {
graphicsObject->removeEventFilter(q);
- QObject::disconnect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize()));
- QObject::disconnect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize()));
+ QObject::disconnect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::disconnect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
} else {
graphicsObject->installEventFilter(q);
- QObject::connect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize()));
- QObject::connect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize()));
+ QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
}
}
}
@@ -251,7 +251,7 @@ void QDeclarativeGraphicsObjectContainerPrivate::_q_updateSize()
return;
QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(graphicsObject);
- const QSizeF newSize(width, height);
+ const QSizeF newSize(width(), height());
gw->resize(newSize);
//### will respecting the widgets min/max ever get us in trouble? (all other items always
diff --git a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h
index 95d7a4b..20c5bcf 100644
--- a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h
@@ -82,7 +82,6 @@ private:
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QGraphicsObject)
QML_DECLARE_TYPE(QDeclarativeGraphicsObjectContainer)
QT_END_HEADER
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 9b1bdba..ee0682a 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -312,9 +312,9 @@ void QDeclarativeContents::setItem(QDeclarativeItem *item)
QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
continue;
- connect(child, SIGNAL(heightChanged(qreal)), this, SLOT(calcHeight()));
+ connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight()));
connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight()));
- connect(child, SIGNAL(widthChanged(qreal)), this, SLOT(calcWidth()));
+ connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth()));
connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth()));
connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF)));
}
@@ -1273,16 +1273,6 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec
*/
/*!
- \fn void QDeclarativeItem::widthChanged()
- \internal
-*/
-
-/*!
- \fn void QDeclarativeItem::heightChanged()
- \internal
-*/
-
-/*!
\fn void QDeclarativeItem::stateChanged(const QString &state)
\internal
*/
@@ -1462,11 +1452,6 @@ QDeclarativeItem *QDeclarativeItem::parentItem() const
*/
/*!
- \property QDeclarativeItem::children
- \internal
-*/
-
-/*!
\property QDeclarativeItem::resources
\internal
*/
@@ -1500,11 +1485,12 @@ QDeclarativeAnchors *QDeclarativeItem::anchors()
void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
{
- QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o);
- if (i)
+ QGraphicsObject *i = qobject_cast<QGraphicsObject *>(o);
+ if (i) {
i->setParentItem(static_cast<QDeclarativeItem *>(prop->object));
- else
+ } else {
o->setParent(static_cast<QDeclarativeItem *>(prop->object));
+ }
}
QObject *QDeclarativeItemPrivate::resources_at(QDeclarativeListProperty<QObject> *prop, int index)
@@ -1526,27 +1512,6 @@ int QDeclarativeItemPrivate::resources_count(QDeclarativeListProperty<QObject> *
return prop->object->children().count();
}
-QDeclarativeItem *QDeclarativeItemPrivate::children_at(QDeclarativeListProperty<QDeclarativeItem> *prop, int index)
-{
- QList<QGraphicsItem *> children = static_cast<QDeclarativeItem*>(prop->object)->childItems();
-
- if (index < children.count())
- return qobject_cast<QDeclarativeItem *>(children.at(index));
- else
- return 0;
-}
-
-void QDeclarativeItemPrivate::children_append(QDeclarativeListProperty<QDeclarativeItem> *prop, QDeclarativeItem *i)
-{
- if (i)
- i->setParentItem(static_cast<QDeclarativeItem*>(prop->object));
-}
-
-int QDeclarativeItemPrivate::children_count(QDeclarativeListProperty<QDeclarativeItem> *prop)
-{
- return static_cast<QDeclarativeItem*>(prop->object)->childItems().count();
-}
-
int QDeclarativeItemPrivate::transform_count(QDeclarativeListProperty<QGraphicsTransform> *list)
{
QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
@@ -1589,6 +1554,14 @@ void QDeclarativeItemPrivate::transform_clear(QDeclarativeListProperty<QGraphics
}
}
+void QDeclarativeItemPrivate::parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e)
+{
+ QDeclarativeItem *item = static_cast<QDeclarativeItem*>(o);
+ if (e)
+ e->connect(&item->d_func()->parentNotifier);
+ *((QDeclarativeItem **)rv) = item->parentItem();
+}
+
/*!
\qmlproperty list<Object> Item::data
\default
@@ -1678,18 +1651,6 @@ void QDeclarativeItem::setClip(bool c)
*/
/*!
- \property QDeclarativeItem::width
-
- Defines the item's width relative to its parent.
- */
-
-/*!
- \property QDeclarativeItem::height
-
- Defines the item's height relative to its parent.
- */
-
-/*!
\qmlproperty real Item::z
Sets the stacking order of the item. By default the stacking order is 0.
@@ -1801,11 +1762,11 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry,
if (newGeometry.x() != oldGeometry.x())
emit xChanged();
if (newGeometry.width() != oldGeometry.width())
- emit widthChanged(newGeometry.width());
+ emit widthChanged();
if (newGeometry.y() != oldGeometry.y())
emit yChanged();
if (newGeometry.height() != oldGeometry.height())
- emit heightChanged(newGeometry.height());
+ emit heightChanged();
for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
@@ -2281,14 +2242,6 @@ void QDeclarativeItemPrivate::focusChanged(bool flag)
}
/*! \internal */
-QDeclarativeListProperty<QDeclarativeItem> QDeclarativeItem::fxChildren()
-{
- return QDeclarativeListProperty<QDeclarativeItem>(this, 0, QDeclarativeItemPrivate::children_append,
- QDeclarativeItemPrivate::children_count,
- QDeclarativeItemPrivate::children_at);
-}
-
-/*! \internal */
QDeclarativeListProperty<QObject> QDeclarativeItem::resources()
{
return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::resources_append,
@@ -2594,10 +2547,11 @@ bool QDeclarativeItem::sceneEvent(QEvent *event)
QVariant QDeclarativeItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
- Q_D(const QDeclarativeItem);
+ Q_D(QDeclarativeItem);
switch (change) {
case ItemParentHasChanged:
emit parentChanged(parentItem());
+ d->parentNotifier.notify();
break;
case ItemChildAddedChange:
case ItemChildRemovedChange:
@@ -2632,7 +2586,7 @@ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change,
QRectF QDeclarativeItem::boundingRect() const
{
Q_D(const QDeclarativeItem);
- return QRectF(0, 0, d->width, d->height);
+ return QRectF(0, 0, d->mWidth, d->mHeight);
}
/*!
@@ -2717,33 +2671,50 @@ void QDeclarativeItem::setSmooth(bool smooth)
qreal QDeclarativeItem::width() const
{
Q_D(const QDeclarativeItem);
- return d->width;
+ return d->width();
}
void QDeclarativeItem::setWidth(qreal w)
{
Q_D(QDeclarativeItem);
+ d->setWidth(w);
+}
+
+void QDeclarativeItem::resetWidth()
+{
+ Q_D(QDeclarativeItem);
+ d->resetWidth();
+}
+
+qreal QDeclarativeItemPrivate::width() const
+{
+ return mWidth;
+}
+
+void QDeclarativeItemPrivate::setWidth(qreal w)
+{
+ Q_Q(QDeclarativeItem);
if (qIsNaN(w))
return;
- d->widthValid = true;
- if (d->width == w)
+ widthValid = true;
+ if (mWidth == w)
return;
- qreal oldWidth = d->width;
+ qreal oldWidth = mWidth;
- prepareGeometryChange();
- d->width = w;
+ q->prepareGeometryChange();
+ mWidth = w;
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), oldWidth, height()));
+ q->geometryChanged(QRectF(q->x(), q->y(), width(), height()),
+ QRectF(q->x(), q->y(), oldWidth, height()));
}
-void QDeclarativeItem::resetWidth()
+void QDeclarativeItemPrivate ::resetWidth()
{
- Q_D(QDeclarativeItem);
- d->widthValid = false;
- setImplicitWidth(implicitWidth());
+ Q_Q(QDeclarativeItem);
+ widthValid = false;
+ q->setImplicitWidth(q->implicitWidth());
}
/*!
@@ -2763,13 +2734,13 @@ void QDeclarativeItem::setImplicitWidth(qreal w)
{
Q_D(QDeclarativeItem);
d->implicitWidth = w;
- if (d->width == w || widthValid())
+ if (d->mWidth == w || widthValid())
return;
- qreal oldWidth = d->width;
+ qreal oldWidth = d->mWidth;
prepareGeometryChange();
- d->width = w;
+ d->mWidth = w;
geometryChanged(QRectF(x(), y(), width(), height()),
QRectF(x(), y(), oldWidth, height()));
@@ -2787,33 +2758,50 @@ bool QDeclarativeItem::widthValid() const
qreal QDeclarativeItem::height() const
{
Q_D(const QDeclarativeItem);
- return d->height;
+ return d->height();
}
void QDeclarativeItem::setHeight(qreal h)
{
Q_D(QDeclarativeItem);
+ d->setHeight(h);
+}
+
+void QDeclarativeItem::resetHeight()
+{
+ Q_D(QDeclarativeItem);
+ d->resetHeight();
+}
+
+qreal QDeclarativeItemPrivate::height() const
+{
+ return mHeight;
+}
+
+void QDeclarativeItemPrivate::setHeight(qreal h)
+{
+ Q_Q(QDeclarativeItem);
if (qIsNaN(h))
return;
- d->heightValid = true;
- if (d->height == h)
+ heightValid = true;
+ if (mHeight == h)
return;
- qreal oldHeight = d->height;
+ qreal oldHeight = mHeight;
- prepareGeometryChange();
- d->height = h;
+ q->prepareGeometryChange();
+ mHeight = h;
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), width(), oldHeight));
+ q->geometryChanged(QRectF(q->x(), q->y(), width(), height()),
+ QRectF(q->x(), q->y(), width(), oldHeight));
}
-void QDeclarativeItem::resetHeight()
+void QDeclarativeItemPrivate::resetHeight()
{
- Q_D(QDeclarativeItem);
- d->heightValid = false;
- setImplicitHeight(implicitHeight());
+ Q_Q(QDeclarativeItem);
+ heightValid = false;
+ q->setImplicitHeight(q->implicitHeight());
}
/*!
@@ -2833,13 +2821,13 @@ void QDeclarativeItem::setImplicitHeight(qreal h)
{
Q_D(QDeclarativeItem);
d->implicitHeight = h;
- if (d->height == h || heightValid())
+ if (d->mHeight == h || heightValid())
return;
- qreal oldHeight = d->height;
+ qreal oldHeight = d->mHeight;
prepareGeometryChange();
- d->height = h;
+ d->mHeight = h;
geometryChanged(QRectF(x(), y(), width(), height()),
QRectF(x(), y(), width(), oldHeight));
@@ -2861,15 +2849,15 @@ void QDeclarativeItem::setSize(const QSizeF &size)
d->heightValid = true;
d->widthValid = true;
- if (d->height == size.height() && d->width == size.width())
+ if (d->height() == size.height() && d->width() == size.width())
return;
- qreal oldHeight = d->height;
- qreal oldWidth = d->width;
+ qreal oldHeight = d->height();
+ qreal oldWidth = d->width();
prepareGeometryChange();
- d->height = size.height();
- d->width = size.width();
+ d->setHeight(size.height());
+ d->setWidth(size.width());
geometryChanged(QRectF(x(), y(), width(), height()),
QRectF(x(), y(), oldWidth, oldHeight));
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index c88b1db..712e854 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -71,13 +71,10 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDe
Q_PROPERTY(QDeclarativeItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL)
Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data DESIGNABLE false)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> children READ fxChildren DESIGNABLE false NOTIFY childrenChanged)
Q_PROPERTY(QDeclarativeListProperty<QObject> resources READ resources DESIGNABLE false)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeState> states READ states DESIGNABLE false)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeTransition> transitions READ transitions DESIGNABLE false)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL)
- Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL)
Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL)
Q_PROPERTY(QDeclarativeAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL)
Q_PROPERTY(QDeclarativeAnchorLine left READ left CONSTANT FINAL)
@@ -113,7 +110,6 @@ public:
void setParent(QDeclarativeItem *parent) { setParentItem(parent); }
QDeclarativeListProperty<QObject> data();
- QDeclarativeListProperty<QDeclarativeItem> fxChildren();
QDeclarativeListProperty<QObject> resources();
QDeclarativeAnchors *anchors();
@@ -173,8 +169,6 @@ public:
QDeclarativeAnchorLine baseline() const;
Q_SIGNALS:
- void widthChanged(qreal);
- void heightChanged(qreal);
void childrenChanged();
void childrenRectChanged(const QRectF &);
void baselineOffsetChanged(qreal);
@@ -235,9 +229,11 @@ QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, QDeclarativeItem *item);
QT_END_NAMESPACE
QML_DECLARE_TYPE(QDeclarativeItem)
+QML_DECLARE_TYPE(QGraphicsObject)
QML_DECLARE_TYPE(QGraphicsTransform)
QML_DECLARE_TYPE(QGraphicsScale)
QML_DECLARE_TYPE(QGraphicsRotation)
+QML_DECLARE_TYPE(QGraphicsWidget)
QML_DECLARE_TYPE(QAction)
QT_END_HEADER
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 55df063..4828f4e 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -62,6 +62,8 @@
#include <private/qdeclarativestate_p.h>
#include <private/qdeclarativenullablevalue_p_p.h>
+#include <private/qdeclarativenotifier_p.h>
+
#include <qdeclarative.h>
#include <qdeclarativecontext.h>
@@ -114,7 +116,7 @@ public:
widthValid(false), heightValid(false),
_componentComplete(true), _keepMouse(false),
smooth(false), keyHandler(0),
- width(0), height(0), implicitWidth(0), implicitHeight(0)
+ mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0)
{
QGraphicsItemPrivate::acceptedMouseButtons = 0;
QGraphicsItemPrivate::flags = QGraphicsItem::GraphicsItemFlags(
@@ -136,6 +138,16 @@ public:
QString _id;
+ // Private Properties
+ qreal width() const;
+ void setWidth(qreal);
+ void resetWidth();
+
+ qreal height() const;
+ void setHeight(qreal);
+ void resetHeight();
+
+
// data property
static void data_append(QDeclarativeListProperty<QObject> *, QObject *);
@@ -144,17 +156,16 @@ public:
static void resources_append(QDeclarativeListProperty<QObject> *, QObject *);
static int resources_count(QDeclarativeListProperty<QObject> *);
- // children property
- static QDeclarativeItem *children_at(QDeclarativeListProperty<QDeclarativeItem> *, int);
- static void children_append(QDeclarativeListProperty<QDeclarativeItem> *, QDeclarativeItem *);
- static int children_count(QDeclarativeListProperty<QDeclarativeItem> *);
-
// transform property
static int transform_count(QDeclarativeListProperty<QGraphicsTransform> *list);
static void transform_append(QDeclarativeListProperty<QGraphicsTransform> *list, QGraphicsTransform *);
static QGraphicsTransform *transform_at(QDeclarativeListProperty<QGraphicsTransform> *list, int);
static void transform_clear(QDeclarativeListProperty<QGraphicsTransform> *list);
+ // Accelerated property accessors
+ QDeclarativeNotifier parentNotifier;
+ static void parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e);
+
QDeclarativeAnchors *anchors() {
if (!_anchors) {
Q_Q(QDeclarativeItem);
@@ -222,8 +233,8 @@ public:
QDeclarativeItemKeyFilter *keyHandler;
- qreal width;
- qreal height;
+ qreal mWidth;
+ qreal mHeight;
qreal implicitWidth;
qreal implicitHeight;
@@ -232,9 +243,9 @@ public:
virtual void setPosHelper(const QPointF &pos)
{
Q_Q(QDeclarativeItem);
- QRectF oldGeometry(this->pos.x(), this->pos.y(), width, height);
+ QRectF oldGeometry(this->pos.x(), this->pos.y(), mWidth, mHeight);
QGraphicsItemPrivate::setPosHelper(pos);
- q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), width, height), oldGeometry);
+ q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), mWidth, mHeight), oldGeometry);
}
// Reimplemented from QGraphicsItemPrivate
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index 1a48cbd..07d7f4d 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -114,7 +114,6 @@ void QDeclarativeItemModule::defineModule()
qmlRegisterType<QDeclarativePathPercent>("Qt",4,6,"PathPercent");
qmlRegisterType<QDeclarativePathQuad>("Qt",4,6,"PathQuad");
qmlRegisterType<QDeclarativePathView>("Qt",4,6,"PathView");
- qmlRegisterType<QDeclarativePen>("Qt",4,6,"Pen");
qmlRegisterType<QIntValidator>("Qt",4,6,"QIntValidator");
#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
qmlRegisterType<QDoubleValidator>("Qt",4,7,"QDoubleValidator");
@@ -146,6 +145,7 @@ void QDeclarativeItemModule::defineModule()
qmlRegisterType<QValidator>();
qmlRegisterType<QDeclarativeVisualModel>();
qmlRegisterType<QAction>();
+ qmlRegisterType<QDeclarativePen>();
#ifdef QT_WEBKIT_LIB
qmlRegisterType<QDeclarativeWebSettings>();
#endif
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 320a2f0..8a70c07 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -562,7 +562,7 @@ void QDeclarativeListViewPrivate::releaseItem(FxListItem *item)
return;
if (trackedItem == item) {
const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal));
+ const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
trackedItem = 0;
@@ -763,7 +763,7 @@ void QDeclarativeListViewPrivate::updateTrackedItem()
FxListItem *oldTracked = trackedItem;
const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal));
+ const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
if (trackedItem && item != trackedItem) {
QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
index 28a93d2..ab6007a 100644
--- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
@@ -211,8 +211,8 @@ QDeclarativePaintedItem::~QDeclarativePaintedItem()
*/
void QDeclarativePaintedItem::init()
{
- connect(this,SIGNAL(widthChanged(qreal)),this,SLOT(clearCache()));
- connect(this,SIGNAL(heightChanged(qreal)),this,SLOT(clearCache()));
+ connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache()));
+ connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache()));
connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache()));
}
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index b9c8971..f3d6137 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -138,6 +138,103 @@ void QDeclarativePathViewPrivate::clear()
items.clear();
}
+void QDeclarativePathViewPrivate::updateMappedRange()
+{
+ if (model && pathItems != -1 && pathItems < model->count())
+ mappedRange = qreal(pathItems)/model->count();
+ else
+ mappedRange = 1.0;
+}
+
+qreal QDeclarativePathViewPrivate::positionOfIndex(int index) const
+{
+ qreal pos = -1.0;
+
+ if (model && index >= 0 && index < model->count()) {
+ qreal globalPos = qreal(index) + offset;
+ globalPos = qmlMod(globalPos, qreal(model->count())) / model->count();
+ if (pathItems != -1 && pathItems < model->count()) {
+ globalPos += snapPos * mappedRange;
+ globalPos = qmlMod(globalPos, 1.0);
+ if (globalPos < mappedRange)
+ pos = globalPos / mappedRange;
+ } else {
+ pos = qmlMod(globalPos + snapPos, 1.0);
+ }
+ }
+
+ return pos;
+}
+
+void QDeclarativePathViewPrivate::createHighlight()
+{
+ Q_Q(QDeclarativePathView);
+ bool changed = false;
+ if (highlightItem) {
+ delete highlightItem;
+ highlightItem = 0;
+ changed = true;
+ }
+
+ QDeclarativeItem *item = 0;
+ if (highlightComponent) {
+ QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q));
+ QObject *nobj = highlightComponent->create(highlightContext);
+ if (nobj) {
+ highlightContext->setParent(nobj);
+ item = qobject_cast<QDeclarativeItem *>(nobj);
+ if (!item)
+ delete nobj;
+ } else {
+ delete highlightContext;
+ }
+ } else {
+ item = new QDeclarativeItem;
+ }
+ if (item) {
+ item->setParent(q);
+ highlightItem = item;
+ changed = true;
+ }
+ if (changed)
+ emit q->highlightItemChanged();
+}
+
+void QDeclarativePathViewPrivate::updateHighlight()
+{
+ Q_Q(QDeclarativePathView);
+ if (!q->isComponentComplete())
+ return;
+ if (highlightItem)
+ updateItem(highlightItem, snapPos);
+}
+
+void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent)
+{
+ if (QDeclarativePathViewAttached *att = attached(item)) {
+ foreach(const QString &attr, path->attributes())
+ att->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
+ }
+ QPointF pf = path->pointAt(percent);
+ item->setX(pf.x() - item->width()*item->scale()/2);
+ item->setY(pf.y() - item->height()*item->scale()/2);
+}
+
+void QDeclarativePathViewPrivate::regenerate()
+{
+ Q_Q(QDeclarativePathView);
+ if (!q->isComponentComplete())
+ return;
+
+ clear();
+
+ if (!isValid())
+ return;
+
+ firstIndex = -1;
+ updateMappedRange();
+ q->refill();
+}
/*!
\qmlclass PathView QDeclarativePathView
@@ -232,6 +329,7 @@ void QDeclarativePathView::setModel(const QVariant &model)
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset()));
disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
for (int i=0; i<d->items.count(); i++){
@@ -261,13 +359,16 @@ void QDeclarativePathView::setModel(const QVariant &model)
if (d->model) {
connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset()));
connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
}
- d->firstIndex = 0;
- d->pathOffset = 0;
+ d->offset = qmlMod(d->offset, qreal(d->model->count()));
+ if (d->offset < 0)
+ d->offset = d->model->count() + d->offset;
d->regenerate();
d->fixOffset();
+ emit countChanged();
emit modelChanged();
}
@@ -330,7 +431,7 @@ void QDeclarativePathView::setCurrentIndex(int idx)
if (d->model->count()) {
int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count();
if (itemIndex < d->items.count()) {
- if (QDeclarativeItem *item = d->items.at(d->currentIndex)) {
+ if (QDeclarativeItem *item = d->items.at(itemIndex)) {
if (QDeclarativePathViewAttached *att = d->attached(item))
att->setIsCurrentItem(false);
}
@@ -354,12 +455,13 @@ void QDeclarativePathView::setCurrentIndex(int idx)
/*!
\qmlproperty real PathView::offset
- The offset specifies how far along the path (0.0-1.0) the items are from their initial positions.
+ The offset specifies how far along the path the items are from their initial positions.
+ This is a real number that ranges from 0.0 to the count of items in the model.
*/
qreal QDeclarativePathView::offset() const
{
Q_D(const QDeclarativePathView);
- return d->_offset;
+ return d->offset;
}
void QDeclarativePathView::setOffset(qreal offset)
@@ -372,18 +474,25 @@ void QDeclarativePathView::setOffset(qreal offset)
void QDeclarativePathViewPrivate::setOffset(qreal o)
{
Q_Q(QDeclarativePathView);
- if (_offset != o) {
- _offset = qmlMod(o, qreal(1.0));
- if (_offset < 0)
- _offset = 1.0 + _offset;
- q->refill();
+ if (offset != o) {
+ if (isValid() && q->isComponentComplete()) {
+ offset = qmlMod(o, qreal(model->count()));
+ if (offset < 0)
+ offset = model->count() + offset;
+ q->refill();
+ } else {
+ offset = o;
+ }
+ emit q->offsetChanged();
}
}
/*!
\qmlproperty real PathView::snapPosition
- This property determines the position (0.0-1.0) the nearest item will snap to.
+ This property determines the position on the path (0.0-1.0) the nearest item will snap to.
+ The item nearest this position will set currentIndex, for example when offset is 0.0 the
+ first item will be placed at this position and currentIndex will be 0.
*/
qreal QDeclarativePathView::snapPosition() const
{
@@ -398,10 +507,34 @@ void QDeclarativePathView::setSnapPosition(qreal pos)
if (qFuzzyCompare(normalizedPos, d->snapPos))
return;
d->snapPos = normalizedPos;
+ d->updateHighlight();
d->fixOffset();
emit snapPositionChanged();
}
+QDeclarativeComponent *QDeclarativePathView::highlight() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->highlightComponent;
+}
+
+void QDeclarativePathView::setHighlight(QDeclarativeComponent *highlight)
+{
+ Q_D(QDeclarativePathView);
+ if (highlight != d->highlightComponent) {
+ d->highlightComponent = highlight;
+ d->createHighlight();
+ d->updateHighlight();
+ emit highlightChanged();
+ }
+}
+
+QDeclarativeItem *QDeclarativePathView::highlightItem()
+{
+ Q_D(const QDeclarativePathView);
+ return d->highlightItem;
+}
+
/*!
\qmlproperty real PathView::dragMargin
This property holds the maximum distance from the path that initiate mouse dragging.
@@ -426,6 +559,52 @@ void QDeclarativePathView::setDragMargin(qreal dragMargin)
}
/*!
+ \qmlproperty real PathView::flickDeceleration
+ This property holds the rate at which a flick will decelerate.
+
+ The default is 100.
+*/
+qreal QDeclarativePathView::flickDeceleration() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->deceleration;
+}
+
+void QDeclarativePathView::setFlickDeceleration(qreal dec)
+{
+ Q_D(QDeclarativePathView);
+ if (d->deceleration == dec)
+ return;
+ d->deceleration = dec;
+ emit flickDecelerationChanged();
+}
+
+/*!
+ \qmlproperty bool PathView::interactive
+
+ A user cannot drag or flick a PathView that is not interactive.
+
+ This property is useful for temporarily disabling flicking. This allows
+ special interaction with PathView's children.
+*/
+bool QDeclarativePathView::isInteractive() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->interactive;
+}
+
+void QDeclarativePathView::setInteractive(bool interactive)
+{
+ Q_D(QDeclarativePathView);
+ if (interactive != d->interactive) {
+ d->interactive = interactive;
+ if (!interactive)
+ d->tl.clear();
+ emit interactiveChanged();
+ }
+}
+
+/*!
\qmlproperty component PathView::delegate
The delegate provides a template defining each item instantiated by the view.
@@ -467,7 +646,7 @@ void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate)
/*!
\qmlproperty int PathView::pathItemCount
- This property holds the number of items visible on the path at any one time
+ This property holds the number of items visible on the path at any one time.
*/
int QDeclarativePathView::pathItemCount() const
{
@@ -480,9 +659,13 @@ void QDeclarativePathView::setPathItemCount(int i)
Q_D(QDeclarativePathView);
if (i == d->pathItems)
return;
+ if (i < 1)
+ i = 1;
d->pathItems = i;
- d->regenerate();
- pathItemCountChanged();
+ if (d->isValid() && isComponentComplete()) {
+ d->regenerate();
+ }
+ emit pathItemCountChanged();
}
QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
@@ -512,7 +695,7 @@ QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *near
void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativePathView);
- if (!d->items.count())
+ if (!d->interactive || !d->items.count())
return;
QPointF scenePoint = mapToScene(event->pos());
int idx = 0;
@@ -542,7 +725,7 @@ void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event)
void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativePathView);
- if (d->lastPosTime.isNull())
+ if (!d->interactive || d->lastPosTime.isNull())
return;
if (!d->stealMouse) {
@@ -555,14 +738,14 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
d->moveReason = QDeclarativePathViewPrivate::Mouse;
qreal newPc;
d->pointNear(event->pos(), &newPc);
- qreal diff = newPc - d->startPc;
+ qreal diff = (newPc - d->startPc)*d->model->count()*d->mappedRange;
if (diff) {
- setOffset(d->_offset + diff);
+ setOffset(d->offset + diff);
- if (diff > 0.5)
- diff -= 1.0;
- else if (diff < -0.5)
- diff += 1.0;
+ if (diff > d->model->count()/2)
+ diff -= d->model->count();
+ else if (diff < -d->model->count()/2)
+ diff += d->model->count();
d->lastElapsed = QDeclarativeItemPrivate::restart(d->lastPosTime);
d->lastDist = diff;
@@ -574,27 +757,37 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
{
Q_D(QDeclarativePathView);
- if (d->lastPosTime.isNull())
+ d->stealMouse = false;
+ setKeepMouseGrab(false);
+ if (!d->interactive || d->lastPosTime.isNull())
return;
qreal elapsed = qreal(d->lastElapsed + QDeclarativeItemPrivate::elapsed(d->lastPosTime)) / 1000.;
qreal velocity = elapsed > 0. ? d->lastDist / elapsed : 0;
- if (d->model && d->model->count() && qAbs(velocity) > 0.05) {
- if (velocity > 1.5)
- velocity = 1.5;
- else if (velocity < -1.5)
- velocity = -1.5;
- qreal inc = qmlMod(d->_offset - d->snapPos, qreal(1.0 / d->model->count()));
- qreal dist = qAbs(velocity/2 - qmlMod(velocity/2, qreal(1.0 / d->model->count()) - inc));
- d->moveOffset.setValue(d->_offset);
- d->tl.accel(d->moveOffset, velocity, 0.1, dist);
+ if (d->model && d->model->count() && qAbs(velocity) > 1.) {
+ qreal count = d->pathItems == -1 ? d->model->count() : d->pathItems;
+ if (qAbs(velocity) > count * 2) // limit velocity
+ velocity = (velocity > 0 ? count : -count) * 2;
+ // Calculate the distance to be travelled
+ qreal v2 = velocity*velocity;
+ qreal accel = d->deceleration;
+ // + 0.25 to encourage moving at least one item in the flick direction
+ qreal dist = qMin(qreal(d->model->count()-1), d->model->count() * v2 / (accel * 2.0) + 0.25);
+ // round to nearest item.
+ if (velocity > 0.)
+ dist = qRound(dist + d->offset) - d->offset;
+ else
+ dist = qRound(dist - d->offset) + d->offset;
+ // Calculate accel required to stop on item boundary
+ accel = v2 / (2.0f * qAbs(dist));
+ d->moveOffset.setValue(d->offset);
+ d->tl.accel(d->moveOffset, velocity, accel, dist);
d->tl.callback(QDeclarativeTimeLineCallback(&d->moveOffset, d->fixOffsetCallback, d));
} else {
d->fixOffset();
}
d->lastPosTime = QTime();
- d->stealMouse = false;
ungrabMouse();
}
@@ -644,7 +837,8 @@ bool QDeclarativePathView::sendMouseEvent(QGraphicsSceneMouseEvent *event)
bool QDeclarativePathView::sceneEventFilter(QGraphicsItem *i, QEvent *e)
{
- if (!isVisible())
+ Q_D(QDeclarativePathView);
+ if (!isVisible() || !d->interactive)
return QDeclarativeItem::sceneEventFilter(i, e);
switch (e->type()) {
@@ -669,72 +863,7 @@ void QDeclarativePathView::componentComplete()
Q_D(QDeclarativePathView);
QDeclarativeItem::componentComplete();
d->regenerate();
-
- // move to correct offset
- if (d->items.count()) {
- int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count();
-
- itemIndex += d->pathOffset;
- itemIndex %= d->items.count();
- qreal targetOffset = qmlMod(1.0 + d->snapPos - qreal(itemIndex) / d->items.count(), qreal(1.0));
-
- if (targetOffset < 0)
- targetOffset = 1.0 + targetOffset;
- if (targetOffset != d->_offset) {
- d->moveOffset.setValue(targetOffset);
- }
- }
-}
-
-void QDeclarativePathViewPrivate::regenerate()
-{
- Q_Q(QDeclarativePathView);
- if (!q->isComponentComplete())
- return;
-
- clear();
-
- if (!isValid())
- return;
-
- if (firstIndex >= model->count())
- firstIndex = model->count()-1;
- if (pathOffset >= model->count())
- pathOffset = model->count()-1;
-
- int numItems = pathItems >= 0 ? pathItems : model->count();
- for (int i=0; i < numItems && i < model->count(); ++i){
- int index = (i + firstIndex) % model->count();
- QDeclarativeItem *item = getItem(index);
- if (!item) {
- qWarning() << "PathView: Cannot create item, index" << (i + firstIndex) % model->count();
- return;
- }
- items.append(item);
- item->setZValue(i);
- qreal percent = qreal(i) / numItems + _offset;
- percent = qAbs(qmlMod(percent, qreal(1.0)));
- updateItem(item, percent);
- model->completeItem();
- if (currentIndex == index) {
- item->setFocus(true);
- if (QDeclarativePathViewAttached *att = attached(item))
- att->setIsCurrentItem(true);
- }
- }
- if (pathItems != -1)
- q->refill();
-}
-
-void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent)
-{
- if (QDeclarativePathViewAttached *att = attached(item)) {
- foreach(const QString &attr, path->attributes())
- att->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
- }
- QPointF pf = path->pointAt(percent);
- item->setX(pf.x() - item->width()*item->scale()/2);
- item->setY(pf.y() - item->height()*item->scale()/2);
+ d->updateHighlight();
}
void QDeclarativePathView::refill()
@@ -743,81 +872,85 @@ void QDeclarativePathView::refill()
if (!d->isValid() || !isComponentComplete())
return;
- QList<qreal> positions;
- for (int i=0; i<d->items.count(); i++){
- qreal percent = qreal(i) / d->items.count();
- percent = percent + d->_offset;
- percent = qmlMod(percent, qreal(1.0));
- positions << qAbs(percent);
- }
-
- if (d->pathItems==-1) {
- for (int i=0; i<positions.count(); i++)
- d->updateItem(d->items.at(i), positions[i]);
- return;
+// qDebug() << "offset" << d->_offset;
+
+ // first move existing items and remove items off path
+ int idx = d->firstIndex;
+ QList<QDeclarativeItem*>::iterator it = d->items.begin();
+ while (it != d->items.end()) {
+ qreal pos = d->positionOfIndex(idx);
+ QDeclarativeItem *item = *it;
+ if (pos >= 0.0) {
+ d->updateItem(item, pos);
+ ++it;
+ } else {
+// qDebug() << "release";
+ d->updateItem(item, 1.0);
+ d->releaseItem(item);
+ if (it == d->items.begin()) {
+ if (++d->firstIndex >= d->model->count())
+ d->firstIndex = 0;
+ }
+ it = d->items.erase(it);
+ }
+ ++idx;
+ if (idx >= d->model->count())
+ idx = 0;
}
- QList<qreal> rotatedPositions;
- for (int i=0; i<d->items.count(); i++)
- rotatedPositions << positions[(i + d->pathOffset + d->items.count()) % d->items.count()];
-
- int wrapIndex= -1;
- for (int i=0; i<d->items.count()-1; i++) {
- if (rotatedPositions[i] > rotatedPositions[i+1]){
- wrapIndex = i;
- break;
+ // add items to beginning and end
+ int count = d->pathItems == -1 ? d->model->count() : qMin(d->pathItems, d->model->count());
+ if (d->items.count() < count) {
+ int idx = qRound(d->model->count() - d->offset) % d->model->count();
+ qreal startPos = d->snapPos;
+ if (d->firstIndex >= 0) {
+ startPos = d->positionOfIndex(d->firstIndex);
+ idx = (d->firstIndex + d->items.count()) % d->model->count();
}
- }
- if (wrapIndex != -1 ){
- //A wraparound has occured
- if (wrapIndex < d->items.count()/2){
- while(wrapIndex-- >= 0){
- QDeclarativeItem* p = d->items.takeFirst();
- d->updateItem(p, 0.0);
- d->releaseItem(p);
- d->firstIndex++;
- d->firstIndex %= d->model->count();
- int index = (d->firstIndex + d->items.count())%d->model->count();
- QDeclarativeItem *item = d->getItem(index);
- item->setZValue(wrapIndex);
- d->model->completeItem();
- if (d->currentIndex == index) {
- item->setFocus(true);
- if (QDeclarativePathViewAttached *att = d->attached(item))
- att->setIsCurrentItem(true);
- }
- d->items << item;
- d->pathOffset++;
- d->pathOffset=d->pathOffset % d->items.count();
+ qreal pos = d->positionOfIndex(idx);
+ while ((pos > startPos || !d->items.count()) && d->items.count() < count) {
+// qDebug() << "append" << idx;
+ QDeclarativeItem *item = d->getItem(idx);
+ item->setZValue(idx+1);
+ d->model->completeItem();
+ if (d->currentIndex == idx) {
+ item->setFocus(true);
+ if (QDeclarativePathViewAttached *att = d->attached(item))
+ att->setIsCurrentItem(true);
}
- } else {
- while(wrapIndex++ < d->items.count()-1){
- QDeclarativeItem* p = d->items.takeLast();
- d->updateItem(p, 1.0);
- d->releaseItem(p);
- d->firstIndex--;
- if (d->firstIndex < 0)
- d->firstIndex = d->model->count() - 1;
- QDeclarativeItem *item = d->getItem(d->firstIndex);
- item->setZValue(d->firstIndex);
- d->model->completeItem();
- if (d->currentIndex == d->firstIndex) {
- item->setFocus(true);
- if (QDeclarativePathViewAttached *att = d->attached(item))
- att->setIsCurrentItem(true);
- }
- d->items.prepend(item);
- d->pathOffset--;
- if (d->pathOffset < 0)
- d->pathOffset = d->items.count() - 1;
+ if (d->items.count() == 0)
+ d->firstIndex = idx;
+ d->items.append(item);
+ d->updateItem(item, pos);
+ ++idx;
+ if (idx >= d->model->count())
+ idx = 0;
+ pos = d->positionOfIndex(idx);
+ }
+
+ idx = d->firstIndex - 1;
+ if (idx < 0)
+ idx = d->model->count() - 1;
+ pos = d->positionOfIndex(idx);
+ while (pos >= 0.0 && pos < startPos) {
+// qDebug() << "prepend" << idx;
+ QDeclarativeItem *item = d->getItem(idx);
+ item->setZValue(idx+1);
+ d->model->completeItem();
+ if (d->currentIndex == idx) {
+ item->setFocus(true);
+ if (QDeclarativePathViewAttached *att = d->attached(item))
+ att->setIsCurrentItem(true);
}
+ d->items.prepend(item);
+ d->updateItem(item, pos);
+ d->firstIndex = idx;
+ idx = d->firstIndex - 1;
+ if (idx < 0)
+ idx = d->model->count() - 1;
+ pos = d->positionOfIndex(idx);
}
- for (int i=0; i<d->items.count(); i++)
- rotatedPositions[i] = positions[(i + d->pathOffset + d->items.count())
- % d->items.count()];
}
- for (int i=0; i<d->items.count(); i++)
- d->updateItem(d->items.at(i), rotatedPositions[i]);
}
void QDeclarativePathView::itemsInserted(int modelIndex, int count)
@@ -826,29 +959,14 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count)
Q_D(QDeclarativePathView);
if (!d->isValid() || !isComponentComplete())
return;
- if (d->pathItems == -1) {
- for (int i = 0; i < count; ++i) {
- QDeclarativeItem *item = d->getItem(modelIndex + i);
- item->setZValue(modelIndex + i);
- d->model->completeItem();
- d->items.insert(modelIndex + i, item);
- }
- refill();
- } else {
- //XXX This is pretty heavy handed until we reference count items.
- d->regenerate();
- }
- // make sure the current item is still at the snap position
- int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count();
- itemIndex += d->pathOffset;
- itemIndex %= d->items.count();
- qreal targetOffset = qmlMod(1.0 + d->snapPos - qreal(itemIndex) / d->items.count(), qreal(1.0));
-
- if (targetOffset < 0)
- targetOffset = 1.0 + targetOffset;
- if (targetOffset != d->_offset)
- d->moveOffset.setValue(targetOffset);
+ QList<QDeclarativeItem *> removedItems = d->items;
+ d->items.clear();
+ d->regenerate();
+ while (removedItems.count())
+ d->releaseItem(removedItems.takeLast());
+ d->updateCurrent();
+ emit countChanged();
}
void QDeclarativePathView::itemsRemoved(int modelIndex, int count)
@@ -857,41 +975,37 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count)
Q_D(QDeclarativePathView);
if (!d->isValid() || !isComponentComplete())
return;
- if (d->pathItems == -1) {
- for (int i = 0; i < count && d->items.count() > modelIndex; ++i) {
- QDeclarativeItem* p = d->items.takeAt(modelIndex);
- d->model->release(p);
- }
- d->snapToCurrent();
- refill();
- } else {
- d->regenerate();
- }
- if (d->model->count() == 0) {
- d->currentIndex = -1;
- d->moveOffset.setValue(0);
+ QList<QDeclarativeItem *> removedItems = d->items;
+ d->items.clear();
+ if (d->offset >= d->model->count())
+ d->offset = d->model->count() - 1;
+ d->regenerate();
+ while (removedItems.count())
+ d->releaseItem(removedItems.takeLast());
+ d->updateCurrent();
+ emit countChanged();
+}
+
+void QDeclarativePathView::itemsMoved(int from, int to, int count)
+{
+ Q_D(QDeclarativePathView);
+ if (!d->isValid() || !isComponentComplete())
return;
- }
- // make sure the current item is still at the snap position
- if (d->currentIndex >= d->model->count())
- d->currentIndex = d->model->count() - 1;
- int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count();
- itemIndex += d->pathOffset;
- itemIndex %= d->items.count();
- qreal targetOffset = qmlMod(1.0 + d->snapPos - qreal(itemIndex) / d->items.count(), qreal(1.0));
-
- if (targetOffset < 0)
- targetOffset = 1.0 + targetOffset;
- if (targetOffset != d->_offset)
- d->moveOffset.setValue(targetOffset);
+ QList<QDeclarativeItem *> removedItems = d->items;
+ d->items.clear();
+ d->regenerate();
+ while (removedItems.count())
+ d->releaseItem(removedItems.takeLast());
+ d->updateCurrent();
}
void QDeclarativePathView::modelReset()
{
Q_D(QDeclarativePathView);
d->regenerate();
+ emit countChanged();
}
void QDeclarativePathView::createdItem(int index, QDeclarativeItem *item)
@@ -919,36 +1033,10 @@ int QDeclarativePathViewPrivate::calcCurrentIndex()
{
int current = -1;
if (model && items.count()) {
- _offset = qmlMod(_offset, qreal(1.0));
- if (_offset < 0)
- _offset += 1.0;
-
- if (pathItems == -1) {
- qreal delta = qmlMod(_offset - snapPos, qreal(1.0));
- if (delta < 0)
- delta = 1.0 + delta;
- int ii = model->count() - qRound(delta * model->count());
- if (ii < 0)
- ii = 0;
- current = ii;
- } else {
- qreal bestDiff=1e9;
- int bestI=-1;
- for (int i=0; i<items.count(); i++){
- qreal percent = qreal(i) / items.count();
- percent = percent + _offset;
- percent = qmlMod(percent, qreal(1.0));
- qreal diff = qAbs(snapPos - percent);
- if (diff < bestDiff){
- bestDiff = diff;
- bestI = i;
- }
- }
- int modelIndex = (bestI - pathOffset + items.count())%items.count();
- modelIndex += firstIndex;
- current = modelIndex;
- }
- current = qAbs(current % model->count());
+ offset = qmlMod(offset, model->count());
+ if (offset < 0)
+ offset += model->count();
+ current = qRound(qAbs(qmlMod(model->count() - offset, model->count())));
}
return current;
@@ -1002,57 +1090,26 @@ void QDeclarativePathViewPrivate::snapToCurrent()
if (!model || model->count() <= 0)
return;
- int itemIndex = (currentIndex - firstIndex + model->count()) % model->count();
-
- //Rounds is the number of times round to make the current item visible
- int rounds = itemIndex / items.count();
- int otherWayRounds = (model->count() - (itemIndex)) / items.count();
- if (otherWayRounds < rounds)
- rounds = -otherWayRounds;
-
- itemIndex += pathOffset;
- if(model->count() % items.count() && itemIndex - model->count() + items.count() > 0){
- //When model.count() is not a multiple of pathItemCount we need to manually
- //fix the index so that going backwards one step works correctly.
- itemIndex = itemIndex - model->count() + items.count();
- }
- itemIndex %= items.count();
- qreal targetOffset = qmlMod(1.0 + snapPos - qreal(itemIndex) / items.count(), qreal(1.0));
-
- if (targetOffset < 0)
- targetOffset = 1.0 + targetOffset;
- if (targetOffset == _offset && rounds == 0)
- return;
+ qreal targetOffset = model->count() - currentIndex;
moveReason = Other;
tl.clear();
- moveOffset.setValue(_offset);
-
- if (rounds!=0){
- //Compensate if the targetOffset would bring the target in from off the screen
- qreal distance = targetOffset - _offset;
- if (distance <= -0.5)
- rounds--;
- if (distance > 0.5)
- rounds++;
- tl.move(moveOffset, targetOffset -rounds, QEasingCurve(QEasingCurve::InOutQuad),
- int(items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds))));
- tl.callback(QDeclarativeTimeLineCallback(&moveOffset, fixOffsetCallback, this));
- return;
- }
-
- if (targetOffset - _offset > 0.5) {
- qreal distance = 1 - targetOffset + _offset;
- tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * _offset / distance));
- tl.set(moveOffset, 1.0);
- tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * (1.0-targetOffset) / distance));
- } else if (targetOffset - _offset <= -0.5) {
- qreal distance = 1 - _offset + targetOffset;
- tl.move(moveOffset, 1.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * (1.0-_offset) / distance));
+ moveOffset.setValue(offset);
+
+ const int duration = 300;
+
+ if (targetOffset - offset > model->count()/2) {
+ qreal distance = model->count() - targetOffset + offset;
+ tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance));
+ tl.set(moveOffset, model->count());
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * (model->count()-targetOffset) / distance));
+ } else if (targetOffset - offset <= -model->count()/2) {
+ qreal distance = model->count() - offset + targetOffset;
+ tl.move(moveOffset, model->count(), QEasingCurve(QEasingCurve::InQuad), int(duration * (model->count()-offset) / distance));
tl.set(moveOffset, 0.0);
- tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * targetOffset / distance));
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * targetOffset / distance));
} else {
- tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), 200);
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration);
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h
index 6dbd044..07b8f6f 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h
@@ -62,8 +62,15 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition NOTIFY snapPositionChanged)
+
+ Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
+ Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
+
Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged)
- Q_PROPERTY(int count READ count)
+ Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
+ Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
+
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged)
@@ -86,9 +93,19 @@ public:
qreal snapPosition() const;
void setSnapPosition(qreal pos);
+ QDeclarativeComponent *highlight() const;
+ void setHighlight(QDeclarativeComponent *highlight);
+ QDeclarativeItem *highlightItem();
+
qreal dragMargin() const;
void setDragMargin(qreal margin);
+ qreal flickDeceleration() const;
+ void setFlickDeceleration(qreal dec);
+
+ bool isInteractive() const;
+ void setInteractive(bool);
+
int count() const;
QDeclarativeComponent *delegate() const;
@@ -103,11 +120,16 @@ Q_SIGNALS:
void currentIndexChanged();
void offsetChanged();
void modelChanged();
+ void countChanged();
void pathChanged();
void dragMarginChanged();
void snapPositionChanged();
void delegateChanged();
void pathItemCountChanged();
+ void flickDecelerationChanged();
+ void interactiveChanged();
+ void highlightChanged();
+ void highlightItemChanged();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
@@ -122,6 +144,7 @@ private Q_SLOTS:
void ticked();
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
+ void itemsMoved(int,int,int);
void modelReset();
void createdItem(int index, QDeclarativeItem *item);
void destroyingItem(QDeclarativeItem *item);
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
index 62f7d95..1780869 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
@@ -75,17 +75,18 @@ class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate
public:
QDeclarativePathViewPrivate()
: path(0), currentIndex(0), startPc(0), lastDist(0)
- , lastElapsed(0), stealMouse(false), ownModel(false), activeItem(0)
- , snapPos(0), dragMargin(0), moveOffset(this, &QDeclarativePathViewPrivate::setOffset)
- , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1)
- , moveReason(Other), attType(0)
+ , lastElapsed(0), mappedRange(1.0), stealMouse(false), ownModel(false), interactive(true)
+ , snapPos(0), dragMargin(0), deceleration(100)
+ , moveOffset(this, &QDeclarativePathViewPrivate::setOffset)
+ , firstIndex(-1), pathItems(-1), requestedIndex(-1)
+ , moveReason(Other), attType(0), highlightComponent(0), highlightItem(0)
{
}
void init()
{
Q_Q(QDeclarativePathView);
- _offset = 0;
+ offset = 0;
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setFlag(QGraphicsItem::ItemIsFocusScope);
q->setFiltersChildEvents(true);
@@ -96,7 +97,10 @@ public:
void releaseItem(QDeclarativeItem *item);
QDeclarativePathViewAttached *attached(QDeclarativeItem *item);
void clear();
-
+ void updateMappedRange();
+ qreal positionOfIndex(int index) const;
+ void createHighlight();
+ void updateHighlight();
bool isValid() const {
return model && model->count() > 0 && model->isValid() && path;
}
@@ -117,19 +121,20 @@ public:
QPointF startPoint;
qreal lastDist;
int lastElapsed;
- qreal _offset;
+ qreal offset;
+ qreal mappedRange;
bool stealMouse : 1;
bool ownModel : 1;
+ bool interactive : 1;
QTime lastPosTime;
QPointF lastPos;
- QDeclarativeItem *activeItem;
qreal snapPos;
qreal dragMargin;
+ qreal deceleration;
QDeclarativeTimeLine tl;
QDeclarativeTimeLineValueProxy<QDeclarativePathViewPrivate> moveOffset;
int firstIndex;
int pathItems;
- int pathOffset;
int requestedIndex;
QList<QDeclarativeItem *> items;
QDeclarativeGuard<QDeclarativeVisualModel> model;
@@ -137,6 +142,8 @@ public:
enum MovementReason { Other, Key, Mouse };
MovementReason moveReason;
QDeclarativeOpenMetaObjectType *attType;
+ QDeclarativeComponent *highlightComponent;
+ QDeclarativeItem *highlightItem;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index 207d05e..b82fb53 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -470,7 +470,7 @@ void QDeclarativeRectangle::drawRect(QPainter &p)
QRectF QDeclarativeRectangle::boundingRect() const
{
Q_D(const QDeclarativeRectangle);
- return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2);
+ return QRectF(-d->paintmargin, -d->paintmargin, d->width()+d->paintmargin*2, d->height()+d->paintmargin*2);
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp
index 1acca2f..67750a4 100644
--- a/src/declarative/qml/qdeclarativecompiledbindings.cpp
+++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp
@@ -53,11 +53,15 @@
#include <QtCore/qnumeric.h>
#include <private/qdeclarativeanchors_p_p.h>
#include <private/qdeclarativeglobal_p.h>
+#include <private/qdeclarativefastproperties_p.h>
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL);
DEFINE_BOOL_CONFIG_OPTION(qmlDisableOptimizer, QML_DISABLE_OPTIMIZER);
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableFastProperties, QML_DISABLE_FAST_PROPERTIES);
+
+Q_GLOBAL_STATIC(QDeclarativeFastProperties, fastProperties);
using namespace QDeclarativeJS;
@@ -334,6 +338,8 @@ struct Instr {
Subscribe, // subscribe
SubscribeId, // subscribe
+ FetchAndSubscribe, // fetchAndSubscribe
+
LoadId, // load
LoadScope, // load
LoadRoot, // load
@@ -433,6 +439,14 @@ struct Instr {
qint8 output;
qint8 objectReg;
quint8 exceptionId;
+ quint16 subscription;
+ quint16 function;
+ } fetchAndSubscribe;
+ struct {
+ quint8 type;
+ qint8 output;
+ qint8 objectReg;
+ quint8 exceptionId;
quint32 index;
} fetch;
struct {
@@ -937,6 +951,9 @@ static void dumpInstruction(const Instr *instr)
case Instr::SubscribeId:
qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index;
break;
+ case Instr::FetchAndSubscribe:
+ qWarning().nospace() << "FetchAndSubscribe" << "\t" << instr->fetchAndSubscribe.output << "\t" << instr->fetchAndSubscribe.objectReg << "\t" << instr->fetchAndSubscribe.subscription;
+ break;
case Instr::LoadId:
qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg;
break;
@@ -1070,6 +1087,8 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
QDeclarativeContextData *context, QDeclarativeDelayedError *error,
QObject *scope, QObject *output)
{
+ Q_Q(QDeclarativeCompiledBindings);
+
error->removeError();
Register registers[32];
@@ -1081,6 +1100,7 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
instr += instrIndex;
const char *data = program->data();
+ // return;
#ifdef COMPILEDBINDINGS_DEBUG
qWarning().nospace() << "Begin binding run";
#endif
@@ -1107,6 +1127,32 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
}
break;
+ case Instr::FetchAndSubscribe:
+ {
+ const Register &input = registers[instr->fetchAndSubscribe.objectReg];
+ Register &output = registers[instr->fetchAndSubscribe.output];
+
+ if (input.isUndefined()) {
+ throwException(instr->fetchAndSubscribe.exceptionId, error, program, context);
+ return;
+ }
+
+ QObject *object = input.getQObject();
+ if (!object) {
+ output.setUndefined();
+ } else {
+ int subIdx = instr->fetchAndSubscribe.subscription;
+ QDeclarativeCompiledBindingsPrivate::Subscription *sub = 0;
+ if (subIdx != -1) {
+ sub = (subscriptions + subIdx);
+ sub->target = q;
+ sub->targetMethod = methodCount + subIdx;
+ }
+ fastProperties()->accessor(instr->fetchAndSubscribe.function)(object, output.typeDataPtr(), sub);
+ }
+ }
+ break;
+
case Instr::LoadId:
registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
break;
@@ -2376,29 +2422,41 @@ bool QDeclarativeBindingCompilerPrivate::buildName(QStringList &name,
return true;
}
-
bool QDeclarativeBindingCompilerPrivate::fetch(Result &rv, const QMetaObject *mo, int reg,
- int idx, const QStringList &subName, QDeclarativeJS::AST::ExpressionNode *node)
+ int idx, const QStringList &subName,
+ QDeclarativeJS::AST::ExpressionNode *node)
{
QMetaProperty prop = mo->property(idx);
rv.metaObject = 0;
rv.type = 0;
- if (subscription(subName, &rv) && prop.hasNotifySignal() && prop.notifySignalIndex() != -1) {
- Instr sub;
- sub.common.type = Instr::Subscribe;
- sub.subscribe.offset = subscriptionIndex(subName);
- sub.subscribe.reg = reg;
- sub.subscribe.index = prop.notifySignalIndex();
- bytecode << sub;
- }
+ int fastFetchIndex = fastProperties()->accessorIndexForProperty(mo, idx);
Instr fetch;
- fetch.common.type = Instr::Fetch;
- fetch.fetch.objectReg = reg;
- fetch.fetch.index = idx;
- fetch.fetch.output = reg;
- fetch.fetch.exceptionId = exceptionId(node);
+
+ if (!qmlDisableFastProperties() && fastFetchIndex != -1) {
+ fetch.common.type = Instr::FetchAndSubscribe;
+ fetch.fetchAndSubscribe.objectReg = reg;
+ fetch.fetchAndSubscribe.output = reg;
+ fetch.fetchAndSubscribe.function = fastFetchIndex;
+ fetch.fetchAndSubscribe.subscription = subscriptionIndex(subName);
+ fetch.fetchAndSubscribe.exceptionId = exceptionId(node);
+ } else {
+ if (subscription(subName, &rv) && prop.hasNotifySignal() && prop.notifySignalIndex() != -1) {
+ Instr sub;
+ sub.common.type = Instr::Subscribe;
+ sub.subscribe.offset = subscriptionIndex(subName);
+ sub.subscribe.reg = reg;
+ sub.subscribe.index = prop.notifySignalIndex();
+ bytecode << sub;
+ }
+
+ fetch.common.type = Instr::Fetch;
+ fetch.fetch.objectReg = reg;
+ fetch.fetch.index = idx;
+ fetch.fetch.output = reg;
+ fetch.fetch.exceptionId = exceptionId(node);
+ }
rv.type = prop.userType();
rv.metaObject = engine->metaObjectForType(rv.type);
diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h
index ed402a8..bd87990 100644
--- a/src/declarative/qml/qdeclarativelist.h
+++ b/src/declarative/qml/qdeclarativelist.h
@@ -54,6 +54,9 @@ QT_MODULE(Declarative)
class QObject;
struct QMetaObject;
+
+#ifndef QDECLARATIVELISTPROPERTY
+#define QDECLARATIVELISTPROPERTY
template<typename T>
struct QDeclarativeListProperty {
typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*);
@@ -106,6 +109,7 @@ private:
return ((QList<T *> *)p->data)->clear();
}
};
+#endif
class QDeclarativeEngine;
class QDeclarativeListReferencePrivate;
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index 49888c3..fc8ba50 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -31,6 +31,7 @@ SOURCES += \
$$PWD/qdeclarativerewrite.cpp \
$$PWD/qdeclarativevaluetype.cpp \
$$PWD/qdeclarativecompiledbindings.cpp \
+ $$PWD/qdeclarativefastproperties.cpp \
$$PWD/qdeclarativexmlhttprequest.cpp \
$$PWD/qdeclarativesqldatabase.cpp \
$$PWD/qmetaobjectbuilder.cpp \
@@ -103,6 +104,7 @@ HEADERS += \
$$PWD/qbitfield_p.h \
$$PWD/qdeclarativevaluetype_p.h \
$$PWD/qdeclarativecompiledbindings_p.h \
+ $$PWD/qdeclarativefastproperties_p.h \
$$PWD/qdeclarativexmlhttprequest_p.h \
$$PWD/qdeclarativesqldatabase_p.h \
$$PWD/qmetaobjectbuilder_p.h \
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 0bc81ee..3469136 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -609,209 +609,343 @@ QString QDeclarativeStateChangeScript::typeName() const
For more information on anchors see \l {anchor-layout}{Anchor Layouts}.
*/
-
-
-class QDeclarativeAnchorChangesPrivate : public QObjectPrivate
+class QDeclarativeAnchorSetPrivate : public QObjectPrivate
{
+ Q_DECLARE_PUBLIC(QDeclarativeAnchorSet)
public:
- QDeclarativeAnchorChangesPrivate() : target(0) {}
+ QDeclarativeAnchorSetPrivate()
+ : usedAnchors(0), fill(0),
+ centerIn(0)/*, leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
+ margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)*/
+ {
+ }
- QDeclarativeItem *target;
- QString resetString;
+ QDeclarativeAnchors::UsedAnchors usedAnchors;
+ //### change to QDeclarativeAnchors::UsedAnchors resetAnchors
QStringList resetList;
+ QDeclarativeItem *fill;
+ QDeclarativeItem *centerIn;
+
QDeclarativeAnchorLine left;
QDeclarativeAnchorLine right;
- QDeclarativeAnchorLine horizontalCenter;
QDeclarativeAnchorLine top;
QDeclarativeAnchorLine bottom;
- QDeclarativeAnchorLine verticalCenter;
+ QDeclarativeAnchorLine vCenter;
+ QDeclarativeAnchorLine hCenter;
QDeclarativeAnchorLine baseline;
- QDeclarativeAnchorLine origLeft;
- QDeclarativeAnchorLine origRight;
- QDeclarativeAnchorLine origHCenter;
- QDeclarativeAnchorLine origTop;
- QDeclarativeAnchorLine origBottom;
- QDeclarativeAnchorLine origVCenter;
- QDeclarativeAnchorLine origBaseline;
-
- QDeclarativeAnchorLine rewindLeft;
- QDeclarativeAnchorLine rewindRight;
- QDeclarativeAnchorLine rewindHCenter;
- QDeclarativeAnchorLine rewindTop;
- QDeclarativeAnchorLine rewindBottom;
- QDeclarativeAnchorLine rewindVCenter;
- QDeclarativeAnchorLine rewindBaseline;
+ /*qreal leftMargin;
+ qreal rightMargin;
+ qreal topMargin;
+ qreal bottomMargin;
+ qreal margins;
+ qreal vCenterOffset;
+ qreal hCenterOffset;
+ qreal baselineOffset;*/
+};
- qreal fromX;
- qreal fromY;
- qreal fromWidth;
- qreal fromHeight;
+QDeclarativeAnchorSet::QDeclarativeAnchorSet(QObject *parent)
+ : QObject(*new QDeclarativeAnchorSetPrivate, parent)
+{
+}
- qreal toX;
- qreal toY;
- qreal toWidth;
- qreal toHeight;
+QDeclarativeAnchorSet::~QDeclarativeAnchorSet()
+{
+}
- qreal rewindX;
- qreal rewindY;
- qreal rewindWidth;
- qreal rewindHeight;
+QDeclarativeAnchorLine QDeclarativeAnchorSet::top() const
+{
+ Q_D(const QDeclarativeAnchorSet);
+ return d->top;
+}
- bool applyOrigLeft;
- bool applyOrigRight;
- bool applyOrigHCenter;
- bool applyOrigTop;
- bool applyOrigBottom;
- bool applyOrigVCenter;
- bool applyOrigBaseline;
-};
+void QDeclarativeAnchorSet::setTop(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors |= QDeclarativeAnchors::HasTopAnchor;
+ d->top = edge;
+}
-/*!
- \qmlproperty Item AnchorChanges::target
- This property holds the Item whose anchors will change
-*/
+void QDeclarativeAnchorSet::resetTop()
+{
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors &= ~QDeclarativeAnchors::HasTopAnchor;
+ d->top = QDeclarativeAnchorLine();
+ d->resetList << QLatin1String("top");
+}
-QDeclarativeAnchorChanges::QDeclarativeAnchorChanges(QObject *parent)
- : QDeclarativeStateOperation(*(new QDeclarativeAnchorChangesPrivate), parent)
+QDeclarativeAnchorLine QDeclarativeAnchorSet::bottom() const
{
+ Q_D(const QDeclarativeAnchorSet);
+ return d->bottom;
}
-QDeclarativeAnchorChanges::~QDeclarativeAnchorChanges()
+void QDeclarativeAnchorSet::setBottom(const QDeclarativeAnchorLine &edge)
{
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors |= QDeclarativeAnchors::HasBottomAnchor;
+ d->bottom = edge;
}
-QDeclarativeAnchorChanges::ActionList QDeclarativeAnchorChanges::actions()
+void QDeclarativeAnchorSet::resetBottom()
{
- QDeclarativeAction a;
- a.event = this;
- return ActionList() << a;
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors &= ~QDeclarativeAnchors::HasBottomAnchor;
+ d->bottom = QDeclarativeAnchorLine();
+ d->resetList << QLatin1String("bottom");
}
-QDeclarativeItem *QDeclarativeAnchorChanges::object() const
+QDeclarativeAnchorLine QDeclarativeAnchorSet::verticalCenter() const
{
- Q_D(const QDeclarativeAnchorChanges);
- return d->target;
+ Q_D(const QDeclarativeAnchorSet);
+ return d->vCenter;
}
-void QDeclarativeAnchorChanges::setObject(QDeclarativeItem *target)
+void QDeclarativeAnchorSet::setVerticalCenter(const QDeclarativeAnchorLine &edge)
{
- Q_D(QDeclarativeAnchorChanges);
- d->target = target;
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors |= QDeclarativeAnchors::HasVCenterAnchor;
+ d->vCenter = edge;
}
-QString QDeclarativeAnchorChanges::reset() const
+void QDeclarativeAnchorSet::resetVerticalCenter()
{
- Q_D(const QDeclarativeAnchorChanges);
- return d->resetString;
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors &= ~QDeclarativeAnchors::HasVCenterAnchor;
+ d->vCenter = QDeclarativeAnchorLine();
+ d->resetList << QLatin1String("verticalCenter");
}
-void QDeclarativeAnchorChanges::setReset(const QString &reset)
+QDeclarativeAnchorLine QDeclarativeAnchorSet::baseline() const
{
- Q_D(QDeclarativeAnchorChanges);
- d->resetString = reset;
- d->resetList = d->resetString.split(QLatin1Char(','));
- for (int i = 0; i < d->resetList.count(); ++i)
- d->resetList[i] = d->resetList.at(i).trimmed();
+ Q_D(const QDeclarativeAnchorSet);
+ return d->baseline;
}
-/*!
- \qmlproperty AnchorLine AnchorChanges::left
- \qmlproperty AnchorLine AnchorChanges::right
- \qmlproperty AnchorLine AnchorChanges::horizontalCenter
- \qmlproperty AnchorLine AnchorChanges::top
- \qmlproperty AnchorLine AnchorChanges::bottom
- \qmlproperty AnchorLine AnchorChanges::verticalCenter
- \qmlproperty AnchorLine AnchorChanges::baseline
+void QDeclarativeAnchorSet::setBaseline(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors |= QDeclarativeAnchors::HasBaselineAnchor;
+ d->baseline = edge;
+}
- These properties change the respective anchors of the item.
-*/
+void QDeclarativeAnchorSet::resetBaseline()
+{
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors &= ~QDeclarativeAnchors::HasBaselineAnchor;
+ d->baseline = QDeclarativeAnchorLine();
+ d->resetList << QLatin1String("baseline");
+}
-QDeclarativeAnchorLine QDeclarativeAnchorChanges::left() const
+QDeclarativeAnchorLine QDeclarativeAnchorSet::left() const
{
- Q_D(const QDeclarativeAnchorChanges);
+ Q_D(const QDeclarativeAnchorSet);
return d->left;
}
-void QDeclarativeAnchorChanges::setLeft(const QDeclarativeAnchorLine &edge)
+void QDeclarativeAnchorSet::setLeft(const QDeclarativeAnchorLine &edge)
{
- Q_D(QDeclarativeAnchorChanges);
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors |= QDeclarativeAnchors::HasLeftAnchor;
d->left = edge;
}
-QDeclarativeAnchorLine QDeclarativeAnchorChanges::right() const
+void QDeclarativeAnchorSet::resetLeft()
{
- Q_D(const QDeclarativeAnchorChanges);
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors &= ~QDeclarativeAnchors::HasLeftAnchor;
+ d->left = QDeclarativeAnchorLine();
+ d->resetList << QLatin1String("left");
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchorSet::right() const
+{
+ Q_D(const QDeclarativeAnchorSet);
return d->right;
}
-void QDeclarativeAnchorChanges::setRight(const QDeclarativeAnchorLine &edge)
+void QDeclarativeAnchorSet::setRight(const QDeclarativeAnchorLine &edge)
{
- Q_D(QDeclarativeAnchorChanges);
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors |= QDeclarativeAnchors::HasRightAnchor;
d->right = edge;
}
-QDeclarativeAnchorLine QDeclarativeAnchorChanges::horizontalCenter() const
+void QDeclarativeAnchorSet::resetRight()
{
- Q_D(const QDeclarativeAnchorChanges);
- return d->horizontalCenter;
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors &= ~QDeclarativeAnchors::HasRightAnchor;
+ d->right = QDeclarativeAnchorLine();
+ d->resetList << QLatin1String("right");
}
-void QDeclarativeAnchorChanges::setHorizontalCenter(const QDeclarativeAnchorLine &edge)
+QDeclarativeAnchorLine QDeclarativeAnchorSet::horizontalCenter() const
{
- Q_D(QDeclarativeAnchorChanges);
- d->horizontalCenter = edge;
+ Q_D(const QDeclarativeAnchorSet);
+ return d->hCenter;
}
-QDeclarativeAnchorLine QDeclarativeAnchorChanges::top() const
+void QDeclarativeAnchorSet::setHorizontalCenter(const QDeclarativeAnchorLine &edge)
{
- Q_D(const QDeclarativeAnchorChanges);
- return d->top;
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors |= QDeclarativeAnchors::HasHCenterAnchor;
+ d->hCenter = edge;
}
-void QDeclarativeAnchorChanges::setTop(const QDeclarativeAnchorLine &edge)
+void QDeclarativeAnchorSet::resetHorizontalCenter()
{
- Q_D(QDeclarativeAnchorChanges);
- d->top = edge;
+ Q_D(QDeclarativeAnchorSet);
+ d->usedAnchors &= ~QDeclarativeAnchors::HasHCenterAnchor;
+ d->hCenter = QDeclarativeAnchorLine();
+ d->resetList << QLatin1String("horizontalCenter");
}
-QDeclarativeAnchorLine QDeclarativeAnchorChanges::bottom() const
+QDeclarativeItem *QDeclarativeAnchorSet::fill() const
{
- Q_D(const QDeclarativeAnchorChanges);
- return d->bottom;
+ Q_D(const QDeclarativeAnchorSet);
+ return d->fill;
}
-void QDeclarativeAnchorChanges::setBottom(const QDeclarativeAnchorLine &edge)
+void QDeclarativeAnchorSet::setFill(QDeclarativeItem *f)
{
- Q_D(QDeclarativeAnchorChanges);
- d->bottom = edge;
+ Q_D(QDeclarativeAnchorSet);
+ d->fill = f;
}
-QDeclarativeAnchorLine QDeclarativeAnchorChanges::verticalCenter() const
+void QDeclarativeAnchorSet::resetFill()
{
- Q_D(const QDeclarativeAnchorChanges);
- return d->verticalCenter;
+ setFill(0);
+}
+
+QDeclarativeItem *QDeclarativeAnchorSet::centerIn() const
+{
+ Q_D(const QDeclarativeAnchorSet);
+ return d->centerIn;
}
-void QDeclarativeAnchorChanges::setVerticalCenter(const QDeclarativeAnchorLine &edge)
+void QDeclarativeAnchorSet::setCenterIn(QDeclarativeItem* c)
+{
+ Q_D(QDeclarativeAnchorSet);
+ d->centerIn = c;
+}
+
+void QDeclarativeAnchorSet::resetCenterIn()
+{
+ setCenterIn(0);
+}
+
+
+class QDeclarativeAnchorChangesPrivate : public QObjectPrivate
+{
+public:
+ QDeclarativeAnchorChangesPrivate()
+ : target(0), anchorSet(new QDeclarativeAnchorSet) {}
+ ~QDeclarativeAnchorChangesPrivate() { delete anchorSet; }
+
+ QDeclarativeItem *target;
+ QDeclarativeAnchorSet *anchorSet;
+
+ QDeclarativeAnchorLine origLeft;
+ QDeclarativeAnchorLine origRight;
+ QDeclarativeAnchorLine origHCenter;
+ QDeclarativeAnchorLine origTop;
+ QDeclarativeAnchorLine origBottom;
+ QDeclarativeAnchorLine origVCenter;
+ QDeclarativeAnchorLine origBaseline;
+
+ QDeclarativeAnchorLine rewindLeft;
+ QDeclarativeAnchorLine rewindRight;
+ QDeclarativeAnchorLine rewindHCenter;
+ QDeclarativeAnchorLine rewindTop;
+ QDeclarativeAnchorLine rewindBottom;
+ QDeclarativeAnchorLine rewindVCenter;
+ QDeclarativeAnchorLine rewindBaseline;
+
+ qreal fromX;
+ qreal fromY;
+ qreal fromWidth;
+ qreal fromHeight;
+
+ qreal toX;
+ qreal toY;
+ qreal toWidth;
+ qreal toHeight;
+
+ qreal rewindX;
+ qreal rewindY;
+ qreal rewindWidth;
+ qreal rewindHeight;
+
+ bool applyOrigLeft;
+ bool applyOrigRight;
+ bool applyOrigHCenter;
+ bool applyOrigTop;
+ bool applyOrigBottom;
+ bool applyOrigVCenter;
+ bool applyOrigBaseline;
+};
+
+/*!
+ \qmlproperty Item AnchorChanges::target
+ This property holds the Item whose anchors will change
+*/
+
+QDeclarativeAnchorChanges::QDeclarativeAnchorChanges(QObject *parent)
+ : QDeclarativeStateOperation(*(new QDeclarativeAnchorChangesPrivate), parent)
+{
+}
+
+QDeclarativeAnchorChanges::~QDeclarativeAnchorChanges()
+{
+}
+
+QDeclarativeAnchorChanges::ActionList QDeclarativeAnchorChanges::actions()
+{
+ QDeclarativeAction a;
+ a.event = this;
+ return ActionList() << a;
+}
+
+QDeclarativeAnchorSet *QDeclarativeAnchorChanges::anchors()
{
Q_D(QDeclarativeAnchorChanges);
- d->verticalCenter = edge;
+ return d->anchorSet;
}
-QDeclarativeAnchorLine QDeclarativeAnchorChanges::baseline() const
+QDeclarativeItem *QDeclarativeAnchorChanges::object() const
{
Q_D(const QDeclarativeAnchorChanges);
- return d->baseline;
+ return d->target;
}
-void QDeclarativeAnchorChanges::setBaseline(const QDeclarativeAnchorLine &edge)
+void QDeclarativeAnchorChanges::setObject(QDeclarativeItem *target)
{
Q_D(QDeclarativeAnchorChanges);
- d->baseline = edge;
+ d->target = target;
}
+/*!
+ \qmlproperty AnchorLine AnchorChanges::anchors.left
+ \qmlproperty AnchorLine AnchorChanges::anchors.right
+ \qmlproperty AnchorLine AnchorChanges::anchors.horizontalCenter
+ \qmlproperty AnchorLine AnchorChanges::anchors.top
+ \qmlproperty AnchorLine AnchorChanges::anchors.bottom
+ \qmlproperty AnchorLine AnchorChanges::anchors.verticalCenter
+ \qmlproperty AnchorLine AnchorChanges::anchors.baseline
+
+ These properties change the respective anchors of the item.
+
+ To reset an anchor you can assign \c undefined:
+ \qml
+ AnchorChanges {
+ target: myItem
+ left: undefined //remove myItem's left anchor
+ right: otherItem.right
+ }
+ \endqml
+*/
+
void QDeclarativeAnchorChanges::execute()
{
Q_D(QDeclarativeAnchorChanges);
@@ -835,36 +969,36 @@ void QDeclarativeAnchorChanges::execute()
d->target->anchors()->setBaseline(d->origBaseline);
//reset any anchors that have been specified
- if (d->resetList.contains(QLatin1String("left")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("left")))
d->target->anchors()->resetLeft();
- if (d->resetList.contains(QLatin1String("right")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("right")))
d->target->anchors()->resetRight();
- if (d->resetList.contains(QLatin1String("horizontalCenter")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("horizontalCenter")))
d->target->anchors()->resetHorizontalCenter();
- if (d->resetList.contains(QLatin1String("top")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("top")))
d->target->anchors()->resetTop();
- if (d->resetList.contains(QLatin1String("bottom")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("bottom")))
d->target->anchors()->resetBottom();
- if (d->resetList.contains(QLatin1String("verticalCenter")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("verticalCenter")))
d->target->anchors()->resetVerticalCenter();
- if (d->resetList.contains(QLatin1String("baseline")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("baseline")))
d->target->anchors()->resetBaseline();
//set any anchors that have been specified
- if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid)
- d->target->anchors()->setLeft(d->left);
- if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid)
- d->target->anchors()->setRight(d->right);
- if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
- d->target->anchors()->setHorizontalCenter(d->horizontalCenter);
- if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid)
- d->target->anchors()->setTop(d->top);
- if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid)
- d->target->anchors()->setBottom(d->bottom);
- if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
- d->target->anchors()->setVerticalCenter(d->verticalCenter);
- if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid)
- d->target->anchors()->setBaseline(d->baseline);
+ if (d->anchorSet->d_func()->left.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setLeft(d->anchorSet->d_func()->left);
+ if (d->anchorSet->d_func()->right.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setRight(d->anchorSet->d_func()->right);
+ if (d->anchorSet->d_func()->hCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setHorizontalCenter(d->anchorSet->d_func()->hCenter);
+ if (d->anchorSet->d_func()->top.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setTop(d->anchorSet->d_func()->top);
+ if (d->anchorSet->d_func()->bottom.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setBottom(d->anchorSet->d_func()->bottom);
+ if (d->anchorSet->d_func()->vCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setVerticalCenter(d->anchorSet->d_func()->vCenter);
+ if (d->anchorSet->d_func()->baseline.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setBaseline(d->anchorSet->d_func()->baseline);
}
bool QDeclarativeAnchorChanges::isReversable()
@@ -879,19 +1013,19 @@ void QDeclarativeAnchorChanges::reverse()
return;
//reset any anchors set by the state
- if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->left.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetLeft();
- if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->right.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetRight();
- if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->hCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetHorizontalCenter();
- if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->top.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetTop();
- if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->bottom.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetBottom();
- if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->vCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetVerticalCenter();
- if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->baseline.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetBaseline();
//restore previous anchors
@@ -977,26 +1111,26 @@ void QDeclarativeAnchorChanges::copyOriginals(QDeclarativeActionEvent *other)
QDeclarativeAnchorChangesPrivate *acp = ac->d_func();
//probably also need to revert some things
- d->applyOrigLeft = (acp->left.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->resetList.contains(QLatin1String("left")));
+ d->applyOrigLeft = (acp->anchorSet->d_func()->left.anchorLine != QDeclarativeAnchorLine::Invalid ||
+ acp->anchorSet->d_func()->resetList.contains(QLatin1String("left")));
- d->applyOrigRight = (acp->right.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->resetList.contains(QLatin1String("right")));
+ d->applyOrigRight = (acp->anchorSet->d_func()->right.anchorLine != QDeclarativeAnchorLine::Invalid ||
+ acp->anchorSet->d_func()->resetList.contains(QLatin1String("right")));
- d->applyOrigHCenter = (acp->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->resetList.contains(QLatin1String("horizontalCenter")));
+ d->applyOrigHCenter = (acp->anchorSet->d_func()->hCenter.anchorLine != QDeclarativeAnchorLine::Invalid ||
+ acp->anchorSet->d_func()->resetList.contains(QLatin1String("horizontalCenter")));
- d->applyOrigTop = (acp->top.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->resetList.contains(QLatin1String("top")));
+ d->applyOrigTop = (acp->anchorSet->d_func()->top.anchorLine != QDeclarativeAnchorLine::Invalid ||
+ acp->anchorSet->d_func()->resetList.contains(QLatin1String("top")));
- d->applyOrigBottom = (acp->bottom.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->resetList.contains(QLatin1String("bottom")));
+ d->applyOrigBottom = (acp->anchorSet->d_func()->bottom.anchorLine != QDeclarativeAnchorLine::Invalid ||
+ acp->anchorSet->d_func()->resetList.contains(QLatin1String("bottom")));
- d->applyOrigVCenter = (acp->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->resetList.contains(QLatin1String("verticalCenter")));
+ d->applyOrigVCenter = (acp->anchorSet->d_func()->vCenter.anchorLine != QDeclarativeAnchorLine::Invalid ||
+ acp->anchorSet->d_func()->resetList.contains(QLatin1String("verticalCenter")));
- d->applyOrigBaseline = (acp->baseline.anchorLine != QDeclarativeAnchorLine::Invalid ||
- acp->resetList.contains(QLatin1String("baseline")));
+ d->applyOrigBaseline = (acp->anchorSet->d_func()->baseline.anchorLine != QDeclarativeAnchorLine::Invalid ||
+ acp->anchorSet->d_func()->resetList.contains(QLatin1String("baseline")));
d->origLeft = ac->d_func()->origLeft;
d->origRight = ac->d_func()->origRight;
@@ -1034,35 +1168,35 @@ void QDeclarativeAnchorChanges::clearBindings()
d->target->anchors()->resetBaseline();
//reset any anchors that have been specified
- if (d->resetList.contains(QLatin1String("left")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("left")))
d->target->anchors()->resetLeft();
- if (d->resetList.contains(QLatin1String("right")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("right")))
d->target->anchors()->resetRight();
- if (d->resetList.contains(QLatin1String("horizontalCenter")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("horizontalCenter")))
d->target->anchors()->resetHorizontalCenter();
- if (d->resetList.contains(QLatin1String("top")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("top")))
d->target->anchors()->resetTop();
- if (d->resetList.contains(QLatin1String("bottom")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("bottom")))
d->target->anchors()->resetBottom();
- if (d->resetList.contains(QLatin1String("verticalCenter")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("verticalCenter")))
d->target->anchors()->resetVerticalCenter();
- if (d->resetList.contains(QLatin1String("baseline")))
+ if (d->anchorSet->d_func()->resetList .contains(QLatin1String("baseline")))
d->target->anchors()->resetBaseline();
//reset any anchors that we'll be setting in the state
- if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->left.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetLeft();
- if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->right.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetRight();
- if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->hCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetHorizontalCenter();
- if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->top.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetTop();
- if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->bottom.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetBottom();
- if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->vCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetVerticalCenter();
- if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid)
+ if (d->anchorSet->d_func()->baseline.anchorLine != QDeclarativeAnchorLine::Invalid)
d->target->anchors()->resetBaseline();
}
diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h
index 66a8717..c97b2da 100644
--- a/src/declarative/util/qdeclarativestateoperations_p.h
+++ b/src/declarative/util/qdeclarativestateoperations_p.h
@@ -143,54 +143,132 @@ public:
virtual void execute();
};
-class QDeclarativeAnchorChangesPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeAnchorChanges : public QDeclarativeStateOperation, public QDeclarativeActionEvent
+class QDeclarativeAnchorChanges;
+class QDeclarativeAnchorSetPrivate;
+class Q_AUTOTEST_EXPORT QDeclarativeAnchorSet : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeAnchorChanges)
- Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
- Q_PROPERTY(QString reset READ reset WRITE setReset)
- Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft)
- Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight)
- Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter)
- Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop)
- Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom)
- Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter)
- Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline)
+ Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft RESET resetLeft)
+ Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight RESET resetRight)
+ Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter)
+ Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop RESET resetTop)
+ Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom)
+ Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter)
+ Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline)
+ //Q_PROPERTY(QDeclarativeItem *fill READ fill WRITE setFill RESET resetFill)
+ //Q_PROPERTY(QDeclarativeItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn)
+
+ /*Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged)
+ Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
+ Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
+ Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged())
+ Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
+ Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
+ Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged())
+ Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())*/
public:
- QDeclarativeAnchorChanges(QObject *parent=0);
- ~QDeclarativeAnchorChanges();
-
- virtual ActionList actions();
-
- QDeclarativeItem *object() const;
- void setObject(QDeclarativeItem *);
-
- QString reset() const;
- void setReset(const QString &);
+ QDeclarativeAnchorSet(QObject *parent=0);
+ virtual ~QDeclarativeAnchorSet();
QDeclarativeAnchorLine left() const;
void setLeft(const QDeclarativeAnchorLine &edge);
+ void resetLeft();
QDeclarativeAnchorLine right() const;
void setRight(const QDeclarativeAnchorLine &edge);
+ void resetRight();
QDeclarativeAnchorLine horizontalCenter() const;
void setHorizontalCenter(const QDeclarativeAnchorLine &edge);
+ void resetHorizontalCenter();
QDeclarativeAnchorLine top() const;
void setTop(const QDeclarativeAnchorLine &edge);
+ void resetTop();
QDeclarativeAnchorLine bottom() const;
void setBottom(const QDeclarativeAnchorLine &edge);
+ void resetBottom();
QDeclarativeAnchorLine verticalCenter() const;
void setVerticalCenter(const QDeclarativeAnchorLine &edge);
+ void resetVerticalCenter();
QDeclarativeAnchorLine baseline() const;
void setBaseline(const QDeclarativeAnchorLine &edge);
+ void resetBaseline();
+
+ QDeclarativeItem *fill() const;
+ void setFill(QDeclarativeItem *);
+ void resetFill();
+
+ QDeclarativeItem *centerIn() const;
+ void setCenterIn(QDeclarativeItem *);
+ void resetCenterIn();
+
+ /*qreal leftMargin() const;
+ void setLeftMargin(qreal);
+
+ qreal rightMargin() const;
+ void setRightMargin(qreal);
+
+ qreal horizontalCenterOffset() const;
+ void setHorizontalCenterOffset(qreal);
+
+ qreal topMargin() const;
+ void setTopMargin(qreal);
+
+ qreal bottomMargin() const;
+ void setBottomMargin(qreal);
+
+ qreal margins() const;
+ void setMargins(qreal);
+
+ qreal verticalCenterOffset() const;
+ void setVerticalCenterOffset(qreal);
+
+ qreal baselineOffset() const;
+ void setBaselineOffset(qreal);*/
+
+ QDeclarativeAnchors::UsedAnchors usedAnchors() const;
+
+/*Q_SIGNALS:
+ void leftMarginChanged();
+ void rightMarginChanged();
+ void topMarginChanged();
+ void bottomMarginChanged();
+ void marginsChanged();
+ void verticalCenterOffsetChanged();
+ void horizontalCenterOffsetChanged();
+ void baselineOffsetChanged();*/
+
+private:
+ friend class QDeclarativeAnchorChanges;
+ Q_DISABLE_COPY(QDeclarativeAnchorSet)
+ Q_DECLARE_PRIVATE(QDeclarativeAnchorSet)
+};
+
+class QDeclarativeAnchorChangesPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeAnchorChanges : public QDeclarativeStateOperation, public QDeclarativeActionEvent
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeAnchorChanges)
+
+ Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
+ Q_PROPERTY(QDeclarativeAnchorSet *anchors READ anchors CONSTANT)
+
+public:
+ QDeclarativeAnchorChanges(QObject *parent=0);
+ ~QDeclarativeAnchorChanges();
+
+ virtual ActionList actions();
+
+ QDeclarativeAnchorSet *anchors();
+
+ QDeclarativeItem *object() const;
+ void setObject(QDeclarativeItem *);
virtual void execute();
virtual bool isReversable();
@@ -212,6 +290,7 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QDeclarativeParentChange)
QML_DECLARE_TYPE(QDeclarativeStateChangeScript)
+QML_DECLARE_TYPE(QDeclarativeAnchorSet)
QML_DECLARE_TYPE(QDeclarativeAnchorChanges)
QT_END_HEADER
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index d79c6ba..2a02ffe 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -140,6 +140,7 @@ void QDeclarativeUtilModule::defineModule()
qmlRegisterType<QDeclarativeAnchors>();
qmlRegisterType<QDeclarativeStateOperation>();
+ qmlRegisterType<QDeclarativeAnchorSet>();
qmlRegisterTypeEnums<QDeclarativeAbstractAnimation>("Animation");
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index d97fb5f..8e65151 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -448,8 +448,8 @@ void QDeclarativeView::setRootObject(QObject *obj)
d->root = item;
d->qmlRoot = item;
- connect(item, SIGNAL(widthChanged(qreal)), this, SLOT(sizeChanged()));
- connect(item, SIGNAL(heightChanged(qreal)), this, SLOT(sizeChanged()));
+ connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged()));
+ connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged()));
if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0)
d->initialSize.setWidth(d->qmlRoot->width());
if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0)
diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp
index 4faa193..3f8cc72 100644
--- a/src/gui/dialogs/qdialog.cpp
+++ b/src/gui/dialogs/qdialog.cpp
@@ -69,7 +69,6 @@ extern bool qt_wince_is_smartphone(); //is defined in qguifunctions_wce.cpp
# include "qfontdialog.h"
# include "qcolordialog.h"
# include "qwizard.h"
-# include "qmenubar.h"
#endif
#if defined(Q_WS_S60)
@@ -529,12 +528,6 @@ int QDialog::exec()
#endif //Q_WS_WINCE_WM
#ifdef Q_OS_SYMBIAN
-#ifndef QT_NO_MENUBAR
- QMenuBar *menuBar = 0;
- if (!findChild<QMenuBar *>())
- menuBar = new QMenuBar(this);
-#endif
-
if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) ||
qobject_cast<QColorDialog *>(this) || qobject_cast<QWizard *>(this))
showMaximized();
@@ -566,13 +559,6 @@ int QDialog::exec()
delete menuBar;
#endif //QT_NO_MENUBAR
#endif //Q_WS_WINCE_WM
-#ifdef Q_OS_SYMBIAN
-#ifndef QT_NO_MENUBAR
- else if (menuBar)
- delete menuBar;
-#endif //QT_NO_MENUBAR
-#endif //Q_OS_SYMBIAN
-
return res;
}
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 948ff28..b407eef 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1131,6 +1131,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
}
}
+ // Resolve depth.
+ invalidateDepthRecursively();
+
if ((parent = newParent)) {
if (parent->d_func()->scene && parent->d_func()->scene != scene) {
// Move this item to its new parent's scene
@@ -1181,8 +1184,6 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
}
}
- // Resolve depth.
- invalidateDepthRecursively();
dirtySceneTransform = 1;
// Restore the sub focus chain.
@@ -2177,8 +2178,12 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData));
if (c)
c->purge();
- if (scene)
+ if (scene) {
+#ifndef QT_NO_GRAPHICSEFFECT
+ invalidateParentGraphicsEffectsRecursively();
+#endif //QT_NO_GRAPHICSEFFECT
scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true);
+ }
}
// Certain properties are dropped as an item becomes invisible.
@@ -5226,6 +5231,8 @@ void QGraphicsItemPrivate::addChild(QGraphicsItem *child)
needSortChildren = 1; // ### maybe 0
child->d_ptr->siblingIndex = children.size();
children.append(child);
+ if (isObject)
+ emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
}
/*!
@@ -5248,6 +5255,8 @@ void QGraphicsItemPrivate::removeChild(QGraphicsItem *child)
// the child is not guaranteed to be at the index after the list is sorted.
// (see ensureSortedChildren()).
child->d_ptr->siblingIndex = -1;
+ if (isObject)
+ emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
}
/*!
@@ -7455,6 +7464,88 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture)
}
}
+void QGraphicsItemPrivate::append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item)
+{
+ QGraphicsItemPrivate::get(item)->setParentItemHelper(static_cast<QGraphicsObject *>(list->object), /*newParentVariant=*/0, /*thisPointerVariant=*/0);
+}
+
+/*!
+ Returns a list of this item's children.
+
+ The items are sorted by stacking order. This takes into account both the
+ items' insertion order and their Z-values.
+
+*/
+QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList()
+{
+ Q_Q(QGraphicsItem);
+ if (isObject) {
+ QGraphicsObject *that = static_cast<QGraphicsObject *>(q);
+ return QDeclarativeListProperty<QGraphicsObject>(that, &children, QGraphicsItemPrivate::append);
+ } else {
+ //QGraphicsItem is not supported for this property
+ return QDeclarativeListProperty<QGraphicsObject>();
+ }
+}
+
+/*!
+ \internal
+ Returns the width of the item
+ Reimplemented by QGraphicsWidget
+*/
+qreal QGraphicsItemPrivate::width() const
+{
+ return 0;
+}
+
+/*!
+ \internal
+ Set the width of the item
+ Reimplemented by QGraphicsWidget
+*/
+void QGraphicsItemPrivate::setWidth(qreal w)
+{
+ Q_UNUSED(w);
+}
+
+/*!
+ \internal
+ Reset the width of the item
+ Reimplemented by QGraphicsWidget
+*/
+void QGraphicsItemPrivate::resetWidth()
+{
+}
+
+/*!
+ \internal
+ Returns the height of the item
+ Reimplemented by QGraphicsWidget
+*/
+qreal QGraphicsItemPrivate::height() const
+{
+ return 0;
+}
+
+/*!
+ \internal
+ Set the height of the item
+ Reimplemented by QGraphicsWidget
+*/
+void QGraphicsItemPrivate::setHeight(qreal h)
+{
+ Q_UNUSED(h);
+}
+
+/*!
+ \internal
+ Reset the height of the item
+ Reimplemented by QGraphicsWidget
+*/
+void QGraphicsItemPrivate::resetHeight()
+{
+}
+
/*!
\property QGraphicsObject::parent
\brief the parent of the item
@@ -7641,6 +7732,23 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture)
\sa scale, rotation, QGraphicsItem::transformOriginPoint()
*/
+/*!
+ \fn void QGraphicsObject::widthChanged()
+ \internal
+*/
+
+/*!
+ \fn void QGraphicsObject::heightChanged()
+ \internal
+*/
+
+/*!
+
+ \fn QGraphicsObject::childrenChanged()
+
+ This signal gets emitted whenever the children list changes
+ \internal
+*/
/*!
\class QAbstractGraphicsShapeItem
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index 56f94a2..22be64c 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -547,6 +547,10 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint)
+ Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), QDeclarativeListProperty<QGraphicsObject> children READ childrenList DESIGNABLE false NOTIFY childrenChanged)
+ Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL)
+ Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL)
+ Q_CLASSINFO("DefaultProperty", "children")
Q_INTERFACES(QGraphicsItem)
public:
QGraphicsObject(QGraphicsItem *parent = 0);
@@ -571,6 +575,9 @@ Q_SIGNALS:
void zChanged();
void rotationChanged();
void scaleChanged();
+ void childrenChanged();
+ void widthChanged();
+ void heightChanged();
protected:
QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene);
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index de8cf56..b53c545 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -71,6 +71,62 @@ QT_BEGIN_NAMESPACE
class QGraphicsItemPrivate;
+#ifndef QDECLARATIVELISTPROPERTY
+#define QDECLARATIVELISTPROPERTY
+template<typename T>
+struct QDeclarativeListProperty {
+ typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*);
+ typedef int (*CountFunction)(QDeclarativeListProperty<T> *);
+ typedef T *(*AtFunction)(QDeclarativeListProperty<T> *, int);
+ typedef void (*ClearFunction)(QDeclarativeListProperty<T> *);
+
+ QDeclarativeListProperty()
+ : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {}
+ QDeclarativeListProperty(QObject *o, QList<T *> &list)
+ : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at),
+ clear(qlist_clear), dummy1(0), dummy2(0) {}
+ QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0,
+ ClearFunction r = 0)
+ : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {}
+
+ bool operator==(const QDeclarativeListProperty &o) const {
+ return object == o.object &&
+ data == o.data &&
+ append == o.append &&
+ count == o.count &&
+ at == o.at &&
+ clear == o.clear;
+ }
+
+ QObject *object;
+ void *data;
+
+ AppendFunction append;
+
+ CountFunction count;
+ AtFunction at;
+
+ ClearFunction clear;
+
+ void *dummy1;
+ void *dummy2;
+
+private:
+ static void qlist_append(QDeclarativeListProperty *p, T *v) {
+ ((QList<T *> *)p->data)->append(v);
+ }
+ static int qlist_count(QDeclarativeListProperty *p) {
+ return ((QList<T *> *)p->data)->count();
+ }
+ static T *qlist_at(QDeclarativeListProperty *p, int idx) {
+ return ((QList<T *> *)p->data)->at(idx);
+ }
+ static void qlist_clear(QDeclarativeListProperty *p) {
+ return ((QList<T *> *)p->data)->clear();
+ }
+};
+#endif
+
class QGraphicsItemCache
{
public:
@@ -237,6 +293,7 @@ public:
void resolveDepth();
void addChild(QGraphicsItem *child);
void removeChild(QGraphicsItem *child);
+ QDeclarativeListProperty<QGraphicsObject> childrenList();
void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant,
const QVariant *thisPointerVariant);
void childrenBoundingRectHelper(QTransform *x, QRectF *rect);
@@ -423,11 +480,21 @@ public:
inline QTransform transformToParent() const;
inline void ensureSortedChildren();
+ static void append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item);
static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b);
void ensureSequentialSiblingIndex();
inline void sendScenePosChange();
virtual void siblingOrderChange();
+ // Private Properties
+ virtual qreal width() const;
+ virtual void setWidth(qreal);
+ virtual void resetWidth();
+
+ virtual qreal height() const;
+ virtual void setHeight(qreal);
+ virtual void resetHeight();
+
QRectF childrenBoundingRect;
QRectF needsRepaint;
QMap<QWidget *, QRect> paintedViewBoundingRects;
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 669dd61..ccfd87c 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -324,6 +324,14 @@ void QGraphicsWidget::resize(const QSizeF &size)
*/
/*!
+
+ \fn QGraphicsWidget::geometryChanged()
+
+ This signal gets emitted whenever the geometry of the item changes
+ \internal
+*/
+
+/*!
\property QGraphicsWidget::geometry
\brief the geometry of the widget
@@ -391,6 +399,10 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
QGraphicsSceneResizeEvent re;
re.setOldSize(oldSize);
re.setNewSize(newGeom.size());
+ if (oldSize.width() != newGeom.size().width())
+ emit widthChanged();
+ if (oldSize.height() != newGeom.size().height())
+ emit heightChanged();
QApplication::sendEvent(this, &re);
}
}
@@ -2352,5 +2364,7 @@ void QGraphicsWidget::dumpFocusChain()
#endif
QT_END_NAMESPACE
+
+#include "moc_qgraphicswidget.cpp"
#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
index 1835c74..6e397b6 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ b/src/gui/graphicsview/qgraphicswidget_p.cpp
@@ -44,6 +44,7 @@
#ifndef QT_NO_GRAPHICSVIEW
#include <QtCore/qdebug.h>
+#include <QtCore/qnumeric.h>
#include "qgraphicswidget_p.h"
#include "qgraphicslayout.h"
#include "qgraphicsscene_p.h"
@@ -825,6 +826,56 @@ void QGraphicsWidgetPrivate::setLayout_helper(QGraphicsLayout *l)
}
}
+qreal QGraphicsWidgetPrivate::width() const
+{
+ Q_Q(const QGraphicsWidget);
+ return q->geometry().width();
+}
+
+void QGraphicsWidgetPrivate::setWidth(qreal w)
+{
+ if (qIsNaN(w))
+ return;
+ Q_Q(QGraphicsWidget);
+ if (q->geometry().width() == w)
+ return;
+
+ QRectF oldGeom = q->geometry();
+
+ q->setGeometry(QRectF(q->x(), q->y(), w, height()));
+}
+
+void QGraphicsWidgetPrivate::resetWidth()
+{
+ Q_Q(QGraphicsWidget);
+ q->setGeometry(QRectF(q->x(), q->y(), 0, height()));
+}
+
+qreal QGraphicsWidgetPrivate::height() const
+{
+ Q_Q(const QGraphicsWidget);
+ return q->geometry().height();
+}
+
+void QGraphicsWidgetPrivate::setHeight(qreal h)
+{
+ if (qIsNaN(h))
+ return;
+ Q_Q(QGraphicsWidget);
+ if (q->geometry().height() == h)
+ return;
+
+ QRectF oldGeom = q->geometry();
+
+ q->setGeometry(QRectF(q->x(), q->y(), width(), h));
+}
+
+void QGraphicsWidgetPrivate::resetHeight()
+{
+ Q_Q(QGraphicsWidget);
+ q->setGeometry(QRectF(q->x(), q->y(), width(), 0));
+}
+
QT_END_NAMESPACE
#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h
index 3ab8737..7116a23 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.h
+++ b/src/gui/graphicsview/qgraphicswidget_p.h
@@ -131,6 +131,15 @@ public:
void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event);
bool hasDecoration() const;
+ // Private Properties
+ qreal width() const;
+ void setWidth(qreal);
+ void resetWidth();
+
+ qreal height() const;
+ void setHeight(qreal);
+ void resetHeight();
+
// State
inline int attributeToBitIndex(Qt::WidgetAttribute att) const
{
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index 52531a3..cbdbb5c 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -62,7 +62,6 @@ symbian {
# Partial upgrade SIS file
vendorinfo = \
- "&EN" \
"; Localised Vendor name" \
"%{\"Nokia, Qt\"}" \
" " \
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 27b490b..25a7bbe 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -1004,16 +1004,32 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
// else { We don't touch the active window unless we were explicitly activated or deactivated }
}
+void QSymbianControl::handleClientAreaChange()
+{
+ const bool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint;
+ if (qwidget->isFullScreen() && !cbaVisibilityHint) {
+ SetExtentToWholeScreen();
+ } else if (qwidget->isMaximized() || (qwidget->isFullScreen() && cbaVisibilityHint)) {
+ TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
+ SetExtent(r.iTl, r.Size());
+ } else if (!qwidget->isMinimized()) { // Normal geometry
+ if (!qwidget->testAttribute(Qt::WA_Resized)) {
+ qwidget->adjustSize();
+ qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize
+ }
+ if (!qwidget->testAttribute(Qt::WA_Moved) && qwidget->windowType() != Qt::Dialog) {
+ TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
+ SetPosition(r.iTl);
+ qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position
+ }
+ }
+}
+
void QSymbianControl::HandleResourceChange(int resourceType)
{
switch (resourceType) {
case KInternalStatusPaneChange:
- if (qwidget->isFullScreen()) {
- SetExtentToWholeScreen();
- } else if (qwidget->isMaximized()) {
- TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
- SetExtent(r.iTl, r.Size());
- }
+ handleClientAreaChange();
if (IsFocused() && IsVisible()) {
qwidget->d_func()->setWindowIcon_sys(true);
qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle());
@@ -1025,22 +1041,7 @@ void QSymbianControl::HandleResourceChange(int resourceType)
#ifdef Q_WS_S60
case KEikDynamicLayoutVariantSwitch:
{
- if (qwidget->isFullScreen()) {
- SetExtentToWholeScreen();
- } else if (qwidget->isMaximized()) {
- TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
- SetExtent(r.iTl, r.Size());
- } else if (!qwidget->isMinimized()){ // Normal geometry
- if (!qwidget->testAttribute(Qt::WA_Resized)) {
- qwidget->adjustSize();
- qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize
- }
- if (!qwidget->testAttribute(Qt::WA_Moved) && qwidget->windowType() != Qt::Dialog) {
- TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
- SetPosition(r.iTl);
- qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position
- }
- }
+ handleClientAreaChange();
break;
}
#endif
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index c9a94ee..923144a 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -115,6 +115,8 @@ QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *act
break;
}
action->setSoftKeyRole(softKeyRole);
+ action->setVisible(false);
+ setForceEnabledInSoftkeys(action);
return action;
}
@@ -168,25 +170,55 @@ bool QSoftKeyManager::appendSoftkeys(const QWidget &source, int level)
{
Q_D(QSoftKeyManager);
bool ret = false;
- QList<QAction*> actions = source.actions();
- for (int i = 0; i < actions.count(); ++i) {
- if (actions.at(i)->softKeyRole() != QAction::NoSoftKey) {
- d->requestedSoftKeyActions.insert(level, actions.at(i));
+ foreach(QAction *action, source.actions()) {
+ if (action->softKeyRole() != QAction::NoSoftKey
+ && (action->isVisible() || isForceEnabledInSofkeys(action))) {
+ d->requestedSoftKeyActions.insert(level, action);
ret = true;
}
}
return ret;
}
+
+static bool isChildOf(const QWidget *c, const QWidget *p)
+{
+ while (c) {
+ if (c == p)
+ return true;
+ c = c->parentWidget();
+ }
+ return false;
+}
+
QWidget *QSoftKeyManager::softkeySource(QWidget *previousSource, bool& recursiveMerging)
{
Q_D(QSoftKeyManager);
QWidget *source = NULL;
if (!previousSource) {
// Initial source is primarily focuswidget and secondarily activeWindow
- source = QApplication::focusWidget();
- if (!source)
- source = QApplication::activeWindow();
+ QWidget *focus = QApplication::focusWidget();
+ QWidget *popup = QApplication::activePopupWidget();
+ if (popup) {
+ if (isChildOf(focus, popup))
+ source = focus;
+ else
+ source = popup;
+ }
+ if (!source) {
+ QWidget *modal = QApplication::activeModalWidget();
+ if (modal) {
+ if (isChildOf(focus, modal))
+ source = focus;
+ else
+ source = modal;
+ }
+ }
+ if (!source) {
+ source = focus;
+ if (!source)
+ source = QApplication::activeWindow();
+ }
} else {
// Softkey merging is based on four criterias
// 1. Implicit merging is used whenever focus widget does not specify any softkeys
@@ -220,6 +252,20 @@ bool QSoftKeyManager::handleUpdateSoftKeys()
return true;
}
+void QSoftKeyManager::setForceEnabledInSoftkeys(QAction *action)
+{
+ action->setProperty(FORCE_ENABLED_PROPERTY, QVariant(true));
+}
+
+bool QSoftKeyManager::isForceEnabledInSofkeys(QAction *action)
+{
+ bool ret = false;
+ QVariant property = action->property(FORCE_ENABLED_PROPERTY);
+ if (property.isValid() && property.toBool())
+ ret = true;
+ return ret;
+}
+
bool QSoftKeyManager::event(QEvent *e)
{
#ifndef QT_NO_ACTION
diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h
index a6fe17e..a5b258b 100644
--- a/src/gui/kernel/qsoftkeymanager_p.h
+++ b/src/gui/kernel/qsoftkeymanager_p.h
@@ -63,7 +63,8 @@ QT_BEGIN_NAMESPACE
class QSoftKeyManagerPrivate;
-const char MENU_ACTION_PROPERTY[] = "_q_menuaction";
+const char MENU_ACTION_PROPERTY[] = "_q_menuAction";
+const char FORCE_ENABLED_PROPERTY[] = "_q_forceEnabledInSoftkeys";
class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject
{
@@ -88,6 +89,8 @@ public:
static QAction *createAction(StandardSoftKey standardKey, QWidget *actionWidget);
static QAction *createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget);
static QString standardSoftKeyText(StandardSoftKey standardKey);
+ static void setForceEnabledInSoftkeys(QAction *action);
+ static bool isForceEnabledInSofkeys(QAction *action);
protected:
bool event(QEvent *e);
diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp
index 3a0304c..9812d72 100644
--- a/src/gui/kernel/qsoftkeymanager_s60.cpp
+++ b/src/gui/kernel/qsoftkeymanager_s60.cpp
@@ -288,11 +288,7 @@ bool QSoftKeyManagerPrivateS60::setSoftkey(CEikButtonGroupContainer &cba,
TPtrC nativeText = qt_QString2TPtrC(text);
int command = S60_COMMAND_START + position;
setNativeSoftkey(cba, position, command, nativeText);
- // QMainWindow "Options" action is set to invisible in order it does not appear in context menu
- // and all invisible actions are by default disabled.
- // However we never want to dim options softkey, even it is set to invisible
- QVariant property = action->property(MENU_ACTION_PROPERTY);
- const bool dimmed = (property.isValid() && property.toBool()) ? false : !action->isEnabled();
+ const bool dimmed = !action->isEnabled() && !QSoftKeyManager::isForceEnabledInSofkeys(action);
cba.DimCommand(command, dimmed);
realSoftKeyActions.insert(command, action);
return true;
@@ -335,6 +331,7 @@ bool QSoftKeyManagerPrivateS60::setRightSoftkey(CEikButtonGroupContainer &cba)
cbaHasImage[RSK_POSITION] = false;
}
setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText);
+ cba.DimCommand(EAknSoftkeyExit, false);
return true;
}
}
diff --git a/src/gui/kernel/qsound.cpp b/src/gui/kernel/qsound.cpp
index 165e6ce..9d8ffa5 100644
--- a/src/gui/kernel/qsound.cpp
+++ b/src/gui/kernel/qsound.cpp
@@ -147,12 +147,13 @@ public:
supports WAVE and AU files.
\row
\o Mac OS X
- \o NSSound is used. All formats that NSSound supports, including QuickTime formats,
+ \o NSSound is used. All formats that NSSound supports, including QuickTime formats,
are supported by Qt for Mac OS X.
\row
\o Qt for Embedded Linux
\o A built-in mixing sound server is used, accessing \c /dev/dsp
directly. Only the WAVE format is supported.
+ \row
\o Symbian
\o CMdaAudioPlayerUtility is used. All formats that Symbian OS or devices support
are supported also by Qt.
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index cedede1..7c6b754 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -212,6 +212,7 @@ private:
#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event);
#endif
+ void handleClientAreaChange();
private:
static QSymbianControl *lastFocusedControl;
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index 79702af..bfa7050 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -1109,9 +1109,11 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
QTLWExtra *top = d->topData();
const QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry;
- if (newstate & Qt::WindowFullScreen)
- setGeometry(qApp->desktop()->availableGeometry(this));
- else if (newstate & Qt::WindowMaximized)
+
+ const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint;
+ if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint)
+ setGeometry(qApp->desktop()->screenGeometry(this));
+ else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint))
setGeometry(qApp->desktop()->availableGeometry(this));
else
setGeometry(normalGeometry);
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 750e19f..af37e6e 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -61,7 +61,6 @@
#include "qscrollarea.h"
#include "qscrollbar.h"
#include "qtabbar.h"
-#include "qtablewidget.h"
#include "qtableview.h"
#include "qtextedit.h"
#include "qtoolbar.h"
@@ -307,6 +306,13 @@ void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part,
short QS60StylePrivate::pixelMetric(int metric)
{
+ //If it is a custom value, need to strip away the base to map to internal
+ //pixel metric value table
+ if (metric & QStyle::PM_CustomBase) {
+ metric -= QStyle::PM_CustomBase;
+ metric += MAX_NON_CUSTOM_PIXELMETRICS - 1;
+ }
+
Q_ASSERT(metric < MAX_PIXELMETRICS);
const short returnValue = m_pmPointer[metric];
return returnValue;
@@ -407,8 +413,8 @@ QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const
{
const bool cachedColorExists = m_colorCache.contains(frame);
if (!cachedColorExists) {
- const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth);
- const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight);
+ const int frameCornerWidth = pixelMetric(PM_FrameCornerWidth);
+ const int frameCornerHeight = pixelMetric(PM_FrameCornerHeight);
Q_ASSERT(2 * frameCornerWidth < 32);
Q_ASSERT(2 * frameCornerHeight < 32);
@@ -868,7 +874,7 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag
case QS60StyleEnums::SP_QgnGrafBarFrameSideL:
case QS60StyleEnums::SP_QgnGrafBarFrameSideR:
- result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
+ result.setWidth(pixelMetric(PM_FrameCornerWidth));
break;
case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed:
@@ -895,15 +901,15 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag
case 7: /* CornerTr */
case 6: /* CornerBl */
case 5: /* CornerBr */
- result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
+ result.setWidth(pixelMetric(PM_FrameCornerWidth));
// Falltrough intended...
case 4: /* SideT */
case 3: /* SideB */
- result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight));
+ result.setHeight(pixelMetric(PM_FrameCornerHeight));
break;
case 2: /* SideL */
case 1: /* SideR */
- result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
+ result.setWidth(pixelMetric(PM_FrameCornerWidth));
break;
case 0: /* center */
default:
@@ -1002,7 +1008,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
QS60StylePrivate::SE_SliderGrooveVertical;
QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags);
} else {
- const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget);
const QPoint sliderGrooveCenter = sliderGroove.center();
const bool horizontal = optionSlider->orientation == Qt::Horizontal;
painter->save();
@@ -1129,7 +1134,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
drawPrimitive(pe, &toolButton, painter, widget);
}
- if (toolBtn->text.length()>0 ||
+ if (toolBtn->text.length() > 0 ||
!toolBtn->icon.isNull()) {
const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget);
toolButton.rect = button.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth);
@@ -1371,7 +1376,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
if (!comboBox->currentText.isEmpty() && !comboBox->editable) {
QCommonStyle::drawItemText(painter,
- editRect.adjusted(QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth), 0, -1, 0),
+ editRect.adjusted(QS60StylePrivate::pixelMetric(PM_FrameCornerWidth), 0, -1, 0),
visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter),
comboBox->palette, comboBox->state & State_Enabled, comboBox->currentText);
}
@@ -1836,8 +1841,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
painter->save();
QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header));
const int penWidth = (header->orientation == Qt::Horizontal) ?
- linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth)
- : linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth);
+ linePen.width() + QS60StylePrivate::pixelMetric(PM_BoldLineWidth)
+ : linePen.width() + QS60StylePrivate::pixelMetric(PM_ThinLineWidth);
linePen.setWidth(penWidth);
painter->setPen(linePen);
if (header->orientation == Qt::Horizontal){
@@ -1856,7 +1861,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
//Make cornerButton slightly smaller so that it is not on top of table border graphic.
QStyleOptionHeader subopt = *header;
const int borderTweak =
- QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1;
+ QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1;
if (subopt.direction == Qt::LeftToRight)
subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak);
else
@@ -1964,40 +1969,37 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
case CE_MenuScroller:
break;
case CE_FocusFrame: {
- // The pen width should nearly fill the layoutspacings around the widget
- const int penWidth =
- qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing))
- - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets
-
#ifdef QT_KEYPAD_NAVIGATION
bool editFocus = false;
if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) {
if (focusFrame->widget() && focusFrame->widget()->hasEditFocus())
editFocus = true;
}
- const qreal opacity = editFocus ? 0.65 : 0.45; // Trial and error factors. Feel free to improve.
+ const qreal opacity = editFocus ? 1 : 0.75; // Trial and error factors. Feel free to improve.
#else
- const qreal opacity = 0.5;
+ const qreal opacity = 0.85;
#endif
- // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred.
- const qreal rectAdjustment = (penWidth % 2) ? -.5 : 0;
-
- // Make sure that the pen stroke is inside the rect
- const QRectF adjustedRect =
- QRectF(option->rect).adjusted(
- rectAdjustment + penWidth,
- rectAdjustment + penWidth,
- -rectAdjustment - penWidth,
- -rectAdjustment - penWidth
- );
-
- const qreal roundRectRadius = penWidth * goldenRatio;
+ // We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin
+ // Otherwise, we would overlay adjacent widgets.
+ const int frameHeightReduction =
+ qMin(0, pixelMetric(QStyle::PM_LayoutVerticalSpacing)
+ - pixelMetric(QStyle::PM_FocusFrameVMargin));
+ const int frameWidthReduction =
+ qMin(0, pixelMetric(QStyle::PM_LayoutHorizontalSpacing)
+ - pixelMetric(QStyle::PM_FocusFrameHMargin));
+ const int rounding =
+ qMin(pixelMetric(QStyle::PM_FocusFrameVMargin),
+ pixelMetric(QStyle::PM_LayoutVerticalSpacing));
+ const QRect frameRect =
+ option->rect.adjusted(-frameWidthReduction, -frameHeightReduction,
+ frameWidthReduction, frameHeightReduction);
+ QPainterPath framePath;
+ framePath.addRoundedRect(frameRect, rounding, rounding);
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
painter->setOpacity(opacity);
- painter->setPen(QPen(option->palette.color(QPalette::Text), penWidth));
- painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius);
+ painter->fillPath(framePath, option->palette.color(QPalette::Text));
painter->restore();
}
break;
@@ -2080,7 +2082,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
// ... or normal "tick" selection at the end.
} else if (option->state & State_Selected) {
QRect tickRect = option->rect;
- const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
+ const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth);
// adjust tickmark rect to exclude frame border
tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth);
QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd;
@@ -2161,7 +2163,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
QS60StyleEnums::SP_QgnGrafScrollArrowUp :
QS60StyleEnums::SP_QgnGrafScrollArrowDown;
- const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1;
+ const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1;
optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin );
QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags);
} else {
@@ -2175,7 +2177,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
// We want to draw down arrow here for comboboxes as well.
QStyleOptionFrame optionsComboBox = *cmb;
const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
- const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1;
+ const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1;
optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin );
QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags);
} else {
@@ -2309,7 +2311,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
(option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper;
int minDimension = qMin(option->rect.width(), option->rect.height());
QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension));
- const int magicTweak = 3;
+ const int magicTweak = 3;
int resizeValue = minDimension >> 1;
if (!QS60StylePrivate::isTouchSupported()) {
minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon.
@@ -2454,9 +2456,9 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
#ifndef QT_NO_COMBOBOX
case CT_ComboBox: {
// Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints
- // Make sure, that the combobox says within the screen.
+ // Make sure, that the combobox stays within the screen.
const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size()
- -QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0);
+ - QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0);
sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget).
boundedTo(desktopContentSize);
}
@@ -2929,9 +2931,9 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
// Subtract area needed for line
if (opt->state & State_Horizontal)
- ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth));
+ ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_BoldLineWidth));
else
- ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth));
+ ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_ThinLineWidth));
}
ret = visualRect(opt->direction, opt->rect, ret);
break;
@@ -3242,7 +3244,7 @@ bool QS60Style::eventFilter(QObject *object, QEvent *event)
/*!
\internal
- Handle the timer \a event.
+ Handle the timer \a event.
*/
void QS60Style::timerEvent(QTimerEvent *event)
{
diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h
index 82cc21c..af17843 100644
--- a/src/gui/styles/qs60style.h
+++ b/src/gui/styles/qs60style.h
@@ -52,6 +52,15 @@ QT_MODULE(Gui)
#if !defined(QT_NO_STYLE_S60)
+//Public custom pixel metrics values.
+//These can be used to fetch custom pixel metric value from outside QS60Style.
+enum {
+ PM_FrameCornerWidth = QStyle::PM_CustomBase + 1,
+ PM_FrameCornerHeight,
+ PM_BoldLineWidth,
+ PM_ThinLineWidth
+ };
+
class QS60StylePrivate;
class Q_GUI_EXPORT QS60Style : public QCommonStyle
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index 16d82e7..8bb2f7b 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -61,12 +61,7 @@ QT_BEGIN_NAMESPACE
const int MAX_NON_CUSTOM_PIXELMETRICS = 92;
const int CUSTOMVALUESCOUNT = 4;
-enum {
- PM_Custom_FrameCornerWidth = MAX_NON_CUSTOM_PIXELMETRICS,
- PM_Custom_FrameCornerHeight,
- PM_Custom_BoldLineWidth,
- PM_Custom_ThinLineWidth
- };
+
const int MAX_PIXELMETRICS = MAX_NON_CUSTOM_PIXELMETRICS + CUSTOMVALUESCOUNT;
typedef struct {
@@ -425,7 +420,7 @@ public:
SE_ToolBarButton,
SE_ToolBarButtonPressed,
SE_PanelBackground,
- SE_ScrollBarHandlePressedHorizontal, //only for 5.0+
+ SE_ScrollBarHandlePressedHorizontal,
SE_ScrollBarHandlePressedVertical,
SE_ButtonInactive,
SE_Editor,
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index 4a279a7..2ea0ccd 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -755,7 +755,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(
if (drawn)
result = fromFbsBitmap(background, NULL, flags, targetSize);
- // if drawing fails in skin server, just ignore the background (probably OOM occured)
+ // if drawing fails in skin server, just ignore the background (probably OOM case)
CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext
// QS60WindowSurface::lockBitmapHeap();
@@ -787,7 +787,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(
const int currentFrame = QS60StylePrivate::currentAnimationFrame(part);
if (constructedFromTheme && aknAnimation && aknAnimation->BitmapAnimData()->FrameArray().Count() > 0) {
- //Animation was created succesfully and contains frames, just fetch current frame
+ //Animation was created successfully and contains frames, just fetch current frame
if(currentFrame >= aknAnimation->BitmapAnimData()->FrameArray().Count())
User::Leave(KErrOverflow);
const CBitmapFrameData* frameData = aknAnimation->BitmapAnimData()->FrameArray().At(currentFrame);
@@ -978,8 +978,8 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme
TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect)
{
- TInt widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
- TInt heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight);
+ TInt widthShrink = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth);
+ TInt heightShrink = QS60StylePrivate::pixelMetric(PM_FrameCornerHeight);
switch(frameElement) {
case QS60StylePrivate::SF_PanelBackground:
// panel should have slightly slimmer border to enable thin line of background graphics between closest component
@@ -1096,7 +1096,7 @@ void QS60StylePrivate::setActiveLayout()
activeLayoutIndex += (!landscape) ? 1 : 0;
}
- m_pmPointer = data[activeLayoutIndex];
+ setCurrentLayout(activeLayoutIndex);
}
Q_GLOBAL_STATIC(QList<QS60StyleAnimation *>, m_animations)
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index e5975d2..194c5f3 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -379,6 +379,15 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform
Q_ASSERT(positions.size() == glyphs_out.size());
}
+void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
+{
+ glyph_metrics_t gi = boundingBox(glyph);
+ bool isValid = gi.isValid();
+ if (leftBearing != 0)
+ *leftBearing = isValid ? gi.x.toReal() : 0.0;
+ if (rightBearing != 0)
+ *rightBearing = isValid ? (gi.xoff - gi.x - gi.width).toReal() : 0.0;
+}
glyph_metrics_t QFontEngine::tightBoundingBox(const QGlyphLayout &glyphs)
{
@@ -1389,6 +1398,12 @@ glyph_metrics_t QFontEngineMulti::boundingBox(const QGlyphLayout &glyphs)
return overall;
}
+void QFontEngineMulti::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
+{
+ int which = highByte(glyph);
+ engine(which)->getGlyphBearings(stripped(glyph), leftBearing, rightBearing);
+}
+
void QFontEngineMulti::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs,
QPainterPath *path, QTextItem::RenderFlags flags)
{
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 71ab5a5..e645caf 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -206,6 +206,8 @@ public:
virtual qreal minLeftBearing() const { return qreal(); }
virtual qreal minRightBearing() const { return qreal(); }
+ virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
+
virtual const char *name() const = 0;
virtual bool canRender(const QChar *string, int len) = 0;
@@ -374,6 +376,7 @@ public:
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags);
+ virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
virtual QFixed ascent() const;
virtual QFixed descent() const;
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index 55e93bd..3e79d79 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -649,6 +649,30 @@ static const ushort char_table[] = {
static const int char_table_entries = sizeof(char_table)/sizeof(ushort);
+void QFontEngineWin::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
+{
+ HDC hdc = shared_dc();
+ SelectObject(hdc, hfont);
+
+#ifndef Q_WS_WINCE
+ if (ttf)
+#endif
+
+ {
+ ABC abcWidths;
+ GetCharABCWidthsI(hdc, glyph, 1, 0, &abcWidths);
+ if (leftBearing)
+ *leftBearing = abcWidths.abcA;
+ if (rightBearing)
+ *rightBearing = abcWidths.abcC;
+ }
+
+#ifndef Q_WS_WINCE
+ else {
+ QFontEngine::getGlyphBearings(glyph, leftBearing, rightBearing);
+ }
+#endif
+}
qreal QFontEngineWin::minLeftBearing() const
{
diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h
index f9d8f8b..f19e48e 100644
--- a/src/gui/text/qfontengine_win_p.h
+++ b/src/gui/text/qfontengine_win_p.h
@@ -106,6 +106,8 @@ public:
virtual QImage alphaMapForGlyph(glyph_t, const QTransform &xform);
virtual QImage alphaRGBMapForGlyph(glyph_t t, int margin, const QTransform &xform);
+ virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
+
int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const;
void getCMap();
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 13a5704..9349f46 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -472,8 +472,9 @@ int QFontMetrics::leftBearing(QChar ch) const
int nglyphs = 9;
engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
// ### can nglyphs != 1 happen at all? Not currently I think
- glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]);
- return qRound(gi.x);
+ qreal lb;
+ engine->getGlyphBearings(glyphs.glyphs[0], &lb);
+ return qRound(lb);
}
/*!
@@ -506,8 +507,9 @@ int QFontMetrics::rightBearing(QChar ch) const
int nglyphs = 9;
engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
// ### can nglyphs != 1 happen at all? Not currently I think
- glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]);
- return qRound(gi.xoff - gi.x - gi.width);
+ qreal rb;
+ engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb);
+ return qRound(rb);
}
/*!
@@ -1317,8 +1319,9 @@ qreal QFontMetricsF::leftBearing(QChar ch) const
int nglyphs = 9;
engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
// ### can nglyphs != 1 happen at all? Not currently I think
- glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]);
- return gi.x.toReal();
+ qreal lb;
+ engine->getGlyphBearings(glyphs.glyphs[0], &lb);
+ return lb;
}
/*!
@@ -1351,8 +1354,10 @@ qreal QFontMetricsF::rightBearing(QChar ch) const
int nglyphs = 9;
engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
// ### can nglyphs != 1 happen at all? Not currently I think
- glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]);
- return (gi.xoff - gi.x - gi.width).toReal();
+ qreal rb;
+ engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb);
+ return rb;
+
}
/*!
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 2fc5d1a..312d135 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1702,9 +1702,9 @@ namespace {
if (currentPosition <= 0)
return;
- glyph_metrics_t gi = fontEngine->boundingBox(currentGlyph());
- if (gi.isValid())
- rightBearing = qMin(QFixed(), gi.xoff - gi.x - gi.width);
+ qreal rb;
+ fontEngine->getGlyphBearings(currentGlyph(), 0, &rb);
+ rightBearing = qMin(QFixed(), QFixed::fromReal(rb));
}
inline void resetRightBearing()
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index ebc05d9..404d46e 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -167,8 +167,8 @@ void QMenuPrivate::init()
#ifdef QT_SOFTKEYS_ENABLED
selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, q);
cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Back, q);
- selectAction->setVisible(false); // Don't show these in the menu
- cancelAction->setVisible(false);
+ selectAction->setPriority(QAction::HighPriority);
+ cancelAction->setPriority(QAction::HighPriority);
q->addAction(selectAction);
q->addAction(cancelAction);
#endif
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index 13aa02b..e368d3d 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -1404,7 +1404,6 @@ void QMenuBarPrivate::handleReparent()
if (!menuBarAction) {
if (newParent) {
menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, newParent);
- menuBarAction->setVisible(false);
newParent->addAction(menuBarAction);
}
} else {
diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp
index 726426d..2d871d0 100644
--- a/src/gui/widgets/qspinbox.cpp
+++ b/src/gui/widgets/qspinbox.cpp
@@ -448,11 +448,12 @@ void QSpinBox::setRange(int minimum, int maximum)
}
/*!
- This virtual function is used by the spin box whenever it needs
- to display the given \a value. The default implementation returns
- a string containing \a value printed in the standard way using
- QWidget::locale().toString(). Reimplementations may return anything. (See
- the example in the detailed description.)
+ This virtual function is used by the spin box whenever it needs to
+ display the given \a value. The default implementation returns a
+ string containing \a value printed in the standard way using
+ QWidget::locale().toString(), but with the thousand separator
+ removed. Reimplementations may return anything. (See the example
+ in the detailed description.)
Note: QSpinBox does not call this function for specialValueText()
and that neither prefix() nor suffix() should be included in the
@@ -461,7 +462,7 @@ void QSpinBox::setRange(int minimum, int maximum)
If you reimplement this, you may also need to reimplement
valueFromText() and validate()
- \sa valueFromText(), validate()
+ \sa valueFromText(), validate(), QLocale::groupSeparator()
*/
QString QSpinBox::textFromValue(int value) const
@@ -869,7 +870,7 @@ void QDoubleSpinBox::setDecimals(int decimals)
If you reimplement this, you may also need to reimplement
valueFromText().
- \sa valueFromText()
+ \sa valueFromText(), QLocale::groupSeparator()
*/
diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp
index 4b37b18..cb65f6e 100644
--- a/src/multimedia/audio/qaudioinput_mac_p.cpp
+++ b/src/multimedia/audio/qaudioinput_mac_p.cpp
@@ -670,8 +670,8 @@ bool QAudioInputPrivate::open()
}
// Allocate buffer
- periodSizeBytes = (numberOfFrames * streamFormat.mSampleRate / deviceFormat.mSampleRate) *
- streamFormat.mBytesPerFrame;
+ periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame;
+
if (internalBufferSize < periodSizeBytes * 2)
internalBufferSize = periodSizeBytes * 2;
else
diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/audio/qaudiooutput_symbian_p.cpp
index 945a08d..3f8e933 100644
--- a/src/multimedia/audio/qaudiooutput_symbian_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_symbian_p.cpp
@@ -185,10 +185,11 @@ void QAudioOutputPrivate::suspend()
const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples(
m_format, m_bytesWritten);
- m_bytesWritten = 0;
const qint64 samplesPlayed = getSamplesPlayed();
+ m_bytesWritten = 0;
+
// CMMFDevSound::Pause() is not guaranteed to work correctly in all
// implementations, for play-mode DevSound sessions. We therefore
// have to implement suspend() by calling CMMFDevSound::Stop().
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 1d8224c..82bc14f 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -865,7 +865,14 @@ void QHttpNetworkConnectionChannel::_q_disconnected()
void QHttpNetworkConnectionChannel::_q_connected()
{
// improve performance since we get the request sent by the kernel ASAP
- socket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
+ //socket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
+ // We have this commented out now. It did not have the effect we wanted. If we want to
+ // do this properly, Qt has to combine multiple HTTP requests into one buffer
+ // and send this to the kernel in one syscall and then the kernel immediately sends
+ // it as one TCP packet because of TCP_NODELAY.
+ // However, this code is currently not in Qt, so we rely on the kernel combining
+ // the requests into one TCP packet.
+
// not sure yet if it helps, but it makes sense
socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1);
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index 3d0c32d..baf69e7 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -479,6 +479,7 @@ void QHostInfoRunnable::run()
QHostInfoLookupManager::QHostInfoLookupManager() : mutex(QMutex::Recursive), wasDeleted(false)
{
moveToThread(QCoreApplicationPrivate::mainThread());
+ connect(QCoreApplication::instance(), SIGNAL(destroyed()), SLOT(waitForThreadPoolDone()), Qt::DirectConnection);
threadPool.setMaxThreadCount(5); // do 5 DNS lookups in parallel
}
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h
index 2b26b07..4fc74e9 100644
--- a/src/network/kernel/qhostinfo_p.h
+++ b/src/network/kernel/qhostinfo_p.h
@@ -184,6 +184,9 @@ protected:
QMutex mutex;
bool wasDeleted;
+
+private slots:
+ void waitForThreadPoolDone() { threadPool.waitForDone(); }
};
#endif
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index e66d80b..4cdbfdc 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -456,8 +456,8 @@ void QVGPixmapData::cleanup()
void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
{
-#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
if (type == QPixmapData::SgImage && pixmap) {
+#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap);
destroyImages();
@@ -528,6 +528,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
// release stuff
eglDestroyImageKHR(QEgl::display(), eglImage);
driver.Close();
+#endif
} else if (type == QPixmapData::FbsBitmap) {
CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap*>(pixmap);
@@ -573,16 +574,12 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
if(deleteSourceBitmap)
delete bitmap;
}
-#else
- Q_UNUSED(pixmap);
- Q_UNUSED(type);
-#endif
}
void* QVGPixmapData::toNativeType(NativeType type)
{
-#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
if (type == QPixmapData::SgImage) {
+#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
toVGImage();
if (!isValid() || vgImage == VG_INVALID_HANDLE)
@@ -649,6 +646,7 @@ void* QVGPixmapData::toNativeType(NativeType type)
eglDestroyImageKHR(QEgl::display(), eglImage);
driver.Close();
return reinterpret_cast<void*>(sgImage);
+#endif
} else if (type == QPixmapData::FbsBitmap) {
CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);
@@ -670,10 +668,7 @@ void* QVGPixmapData::toNativeType(NativeType type)
return reinterpret_cast<void*>(bitmap);
}
-#else
- Q_UNUSED(type);
return 0;
-#endif
}
#endif //Q_OS_SYMBIAN
diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro
index db1ee4d..ffd15e6 100644
--- a/src/s60installs/s60installs.pro
+++ b/src/s60installs/s60installs.pro
@@ -13,9 +13,12 @@ symbian: {
TARGET.UID3 = 0x2001E61C
# sqlite3 is expected to be already found on phone if infixed configuration is built.
+ BLD_INF_RULES.prj_exports += \
+ "sqlite3.sis $${EPOCROOT}epoc32/data/qt/sis/sqlite3.sis" \
+ "sqlite3_selfsigned.sis $${EPOCROOT}epoc32/data/qt/sis/sqlite3_selfsigned.sis"
sqlitedeployment = \
"; Deploy sqlite onto phone that does not have it already" \
- "@\"$$PWD/sqlite3.sis\", (0x2002af5f)"
+ "@\"$${EPOCROOT}epoc32/data/qt/sis/sqlite3.sis\", (0x2002af5f)"
qtlibraries.pkg_postrules += sqlitedeployment
} else {
# Always use experimental UID for infixed configuration to avoid UID clash
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index ba69cd8..7665e18 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -421,8 +421,8 @@ void tst_QDeclarativeItem::propertyChanges()
QVERIFY(parentItem);
QSignalSpy parentSpy(item, SIGNAL(parentChanged(QDeclarativeItem *)));
- QSignalSpy widthSpy(item, SIGNAL(widthChanged(qreal)));
- QSignalSpy heightSpy(item, SIGNAL(heightChanged(qreal)));
+ QSignalSpy widthSpy(item, SIGNAL(widthChanged()));
+ QSignalSpy heightSpy(item, SIGNAL(heightChanged()));
QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal)));
QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF)));
QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
@@ -442,15 +442,9 @@ void tst_QDeclarativeItem::propertyChanges()
QCOMPARE(item->width(), 100.0);
QCOMPARE(widthSpy.count(),1);
- QList<QVariant> widthArguments = widthSpy.first();
- QVERIFY(widthArguments.count() == 1);
- QCOMPARE(item->width(), widthArguments.at(0).toReal());
QCOMPARE(item->height(), 200.0);
QCOMPARE(heightSpy.count(),1);
- QList<QVariant> heightArguments = heightSpy.first();
- QVERIFY(heightArguments.count() == 1);
- QCOMPARE(item->height(), heightArguments.at(0).toReal());
QCOMPARE(item->baselineOffset(), 10.0);
QCOMPARE(baselineOffsetSpy.count(),1);
diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml
index ae0c86a..8e2c251 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml
@@ -49,6 +49,11 @@ Rectangle {
model: testModel
delegate: delegate
snapPosition: 0.0001
+ highlight: Rectangle {
+ width: 60
+ height: 20
+ color: "yellow"
+ }
path: Path {
startY: 120
startX: 160
diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
index 70cfbcd..f1bc66e 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
@@ -2,7 +2,7 @@ import Qt 4.6
PathView {
id: photoPathView
- y: 100; width: 800; height: 330; pathItemCount: 4; offset: 0.1
+ y: 100; width: 800; height: 330; pathItemCount: 4; offset: 1
dragMargin: 24; snapPosition: 0.50
path: Path {
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index c16c46f..6d7cc0d 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -219,7 +219,7 @@ void tst_QDeclarativePathView::items()
QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
QVERIFY(pathview != 0);
- QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible
+ QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight
for (int i = 0; i < model.count(); ++i) {
QDeclarativeText *name = findItem<QDeclarativeText>(pathview, "textName", i);
@@ -230,6 +230,16 @@ void tst_QDeclarativePathView::items()
QCOMPARE(number->text(), model.number(i));
}
+ QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
+ QVERIFY(path);
+
+ QVERIFY(pathview->highlightItem());
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;
+ offset.setX(pathview->highlightItem()->width()/2);
+ offset.setY(pathview->highlightItem()->height()/2);
+ QCOMPARE(pathview->highlightItem()->pos() + offset, start);
+
delete canvas;
}
@@ -262,8 +272,8 @@ void tst_QDeclarativePathView::pathview3()
QVERIFY(obj->delegate() != 0);
QVERIFY(obj->model() != QVariant());
QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.5); // ???
- QCOMPARE(obj->snapPosition(), 0.5); // ???
+ QCOMPARE(obj->offset(), 1.0);
+ QCOMPARE(obj->snapPosition(), 0.5);
QCOMPARE(obj->dragMargin(), 24.);
QCOMPARE(obj->count(), 8);
QCOMPARE(obj->pathItemCount(), 4);
@@ -422,14 +432,14 @@ void tst_QDeclarativePathView::pathMoved()
offset.setX(firstItem->width()/2);
offset.setY(firstItem->height()/2);
QCOMPARE(firstItem->pos() + offset, start);
- pathview->setOffset(0.1);
+ pathview->setOffset(1.0);
for(int i=0; i<model.count(); i++){
QDeclarativeRectangle *curItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", i);
- QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25));
+ QCOMPARE(curItem->pos() + offset, path->pointAt(0.25 + i*0.25));
}
- pathview->setOffset(1.0);
+ pathview->setOffset(0.0);
QCOMPARE(firstItem->pos() + offset, start);
delete canvas;
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml
index 7dce889..5443e54 100644
--- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml
@@ -16,8 +16,8 @@ Rectangle {
AnchorChanges {
id: ancCh
target: myRect;
- reset: "left"
- right: container.right
+ anchors.left: undefined
+ anchors.right: container.right
}
}
}
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml
index 545345e..56de560 100644
--- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml
@@ -14,8 +14,8 @@ Rectangle {
name: "right"
AnchorChanges {
target: myRect;
- reset: "left"
- right: parent.right
+ anchors.left: undefined
+ anchors.right: parent.right
}
}
}
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml
index 9d5b317..59c3c06 100644
--- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml
@@ -20,10 +20,10 @@ Rectangle {
name: "reanchored"
AnchorChanges {
target: myRect;
- left: leftGuideline.left
- right: container.right
- top: container.top
- bottom: bottomGuideline.bottom
+ anchors.left: leftGuideline.left
+ anchors.right: container.right
+ anchors.top: container.top
+ anchors.bottom: bottomGuideline.bottom
}
}
}
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml
index f128989..7e3ba1c 100644
--- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml
@@ -15,8 +15,8 @@ Rectangle {
name: "reanchored"
AnchorChanges {
target: myRect;
- horizontalCenter: bottomGuideline.horizontalCenter
- verticalCenter: leftGuideline.verticalCenter
+ anchors.horizontalCenter: bottomGuideline.horizontalCenter
+ anchors.verticalCenter: leftGuideline.verticalCenter
}
}
}
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml
index 4e6d34b..b85a922 100644
--- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml
@@ -15,8 +15,8 @@ Rectangle {
name: "reanchored"
AnchorChanges {
target: myRect;
- horizontalCenter: bottomGuideline.horizontalCenter
- baseline: leftGuideline.baseline
+ anchors.horizontalCenter: bottomGuideline.horizontalCenter
+ anchors.baseline: leftGuideline.baseline
}
}
}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 91883c9..2ab21a4 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -564,10 +564,10 @@ void tst_qdeclarativestates::anchorChanges()
rect->setState("right");
QCOMPARE(innerRect->x(), qreal(150));
- QCOMPARE(aChanges->reset(), QString("left"));
+ QCOMPARE(aChanges->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->right().item, rect->right().item);
- QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
+ QCOMPARE(aChanges->anchors()->right().item, rect->right().item);
+ QCOMPARE(aChanges->anchors()->right().anchorLine, rect->right().anchorLine);
rect->setState("");
QCOMPARE(innerRect->x(), qreal(5));
@@ -623,14 +623,14 @@ void tst_qdeclarativestates::anchorChanges3()
rect->setState("reanchored");
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->left().item, leftGuideline->left().item);
- QCOMPARE(aChanges->left().anchorLine, leftGuideline->left().anchorLine);
- QCOMPARE(aChanges->right().item, rect->right().item);
- QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
- QCOMPARE(aChanges->top().item, rect->top().item);
- QCOMPARE(aChanges->top().anchorLine, rect->top().anchorLine);
- QCOMPARE(aChanges->bottom().item, bottomGuideline->bottom().item);
- QCOMPARE(aChanges->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
+ QCOMPARE(aChanges->anchors()->left().item, leftGuideline->left().item);
+ QCOMPARE(aChanges->anchors()->left().anchorLine, leftGuideline->left().anchorLine);
+ QCOMPARE(aChanges->anchors()->right().item, rect->right().item);
+ QCOMPARE(aChanges->anchors()->right().anchorLine, rect->right().anchorLine);
+ QCOMPARE(aChanges->anchors()->top().item, rect->top().item);
+ QCOMPARE(aChanges->anchors()->top().anchorLine, rect->top().anchorLine);
+ QCOMPARE(aChanges->anchors()->bottom().item, bottomGuideline->bottom().item);
+ QCOMPARE(aChanges->anchors()->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
QCOMPARE(innerRect->x(), qreal(10));
QCOMPARE(innerRect->y(), qreal(0));
@@ -673,10 +673,10 @@ void tst_qdeclarativestates::anchorChanges4()
rect->setState("reanchored");
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- QCOMPARE(aChanges->verticalCenter().item, leftGuideline->verticalCenter().item);
- QCOMPARE(aChanges->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
+ QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ QCOMPARE(aChanges->anchors()->verticalCenter().item, leftGuideline->verticalCenter().item);
+ QCOMPARE(aChanges->anchors()->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
delete rect;
}
@@ -708,10 +708,10 @@ void tst_qdeclarativestates::anchorChanges5()
rect->setState("reanchored");
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- QCOMPARE(aChanges->baseline().item, leftGuideline->baseline().item);
- QCOMPARE(aChanges->baseline().anchorLine, leftGuideline->baseline().anchorLine);
+ QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ QCOMPARE(aChanges->anchors()->baseline().item, leftGuideline->baseline().item);
+ QCOMPARE(aChanges->anchors()->baseline().anchorLine, leftGuideline->baseline().anchorLine);
delete rect;
}
diff --git a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml
index e41a254..1d0495e 100644
--- a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml
+++ b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml
@@ -36,18 +36,19 @@ Rectangle {
name: "reanchored"
AnchorChanges {
target: myRect;
- left: leftGuideline.left
- right: container.right
- top: container.top
- bottom: bottomGuideline.bottom
+ anchors.left: leftGuideline.left
+ anchors.right: container.right
+ anchors.top: container.top
+ anchors.bottom: bottomGuideline.bottom
}
}, State {
name: "reanchored2"
AnchorChanges {
target: myRect;
- reset: "left, right"
- top: topGuideline2.top
- bottom: bottomGuideline2.bottom
+ anchors.left: undefined
+ anchors.right: undefined
+ anchors.top: topGuideline2.top
+ anchors.bottom: bottomGuideline2.bottom
}
}]
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index 1007d61..49b840f 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -46,6 +46,7 @@
#include <QtGui/qgraphicsview.h>
#include <QtGui/qgraphicsscene.h>
#include <QtGui/qgraphicsitem.h>
+#include <QtGui/qgraphicswidget.h>
#include <QtGui/qstyleoption.h>
#include "../../shared/util.h"
@@ -73,6 +74,7 @@ private slots:
void deviceCoordinateTranslateCaching();
void inheritOpacity();
void dropShadowClipping();
+ void childrenVisibilityShouldInvalidateCache();
};
void tst_QGraphicsEffect::initTestCase()
@@ -510,6 +512,7 @@ void tst_QGraphicsEffect::drawPixmapItem()
QGraphicsView view(&scene);
view.show();
QTest::qWaitForWindowShown(&view);
+ QTRY_VERIFY(effect->repaints >= 1);
item->rotate(180);
QTest::qWait(50);
@@ -613,6 +616,47 @@ void tst_QGraphicsEffect::dropShadowClipping()
QCOMPARE(img.pixel(x, y), img.pixel(x, y-1));
}
+class MyGraphicsItem : public QGraphicsWidget
+{
+public:
+ MyGraphicsItem(QGraphicsItem *parent = 0) :
+ QGraphicsWidget(parent), nbPaint(0)
+ {}
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ {
+ nbPaint++;
+ QGraphicsWidget::paint(painter, option, widget);
+ }
+ int nbPaint;
+};
+
+void tst_QGraphicsEffect::childrenVisibilityShouldInvalidateCache()
+{
+ QGraphicsScene scene;
+ MyGraphicsItem parent;
+ parent.resize(200, 200);
+ QGraphicsWidget child(&parent);
+ child.resize(200, 200);
+ child.setVisible(false);
+ scene.addItem(&parent);
+ QGraphicsView view(&scene);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(parent.nbPaint, 1);
+ //we set an effect on the parent
+ parent.setGraphicsEffect(new QGraphicsDropShadowEffect(&parent));
+ //flush the events
+ QApplication::processEvents();
+ //new effect applied->repaint
+ QCOMPARE(parent.nbPaint, 2);
+ child.setVisible(true);
+ //flush the events
+ QApplication::processEvents();
+ //a new child appears we need to redraw the effect.
+ QCOMPARE(parent.nbPaint, 3);
+}
+
QTEST_MAIN(tst_QGraphicsEffect)
#include "tst_qgraphicseffect.moc"
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 92a7f2e..f4fdacc 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -439,6 +439,7 @@ private slots:
void QTBUG_7714_fullUpdateDiscardingOpacityUpdate2();
void QT_2653_fullUpdateDiscardingOpacityUpdate();
void QT_2649_focusScope();
+ void sortItemsWhileAdding();
private:
QList<QGraphicsItem *> paintedItems;
@@ -10083,5 +10084,38 @@ void tst_QGraphicsItem::QT_2649_focusScope()
delete scene;
}
+class MyGraphicsItemWithItemChange : public QGraphicsWidget
+{
+public:
+ MyGraphicsItemWithItemChange(QGraphicsItem *parent = 0) : QGraphicsWidget(parent)
+ {}
+
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value)
+ {
+ if (change == QGraphicsItem::ItemSceneHasChanged) {
+ foreach (QGraphicsView *view, scene()->views()) {
+ //We trigger a sort of unindexed items in the BSP
+ view->sceneRect();
+ }
+ }
+ return QGraphicsWidget::itemChange(change, value);
+ }
+};
+
+void tst_QGraphicsItem::sortItemsWhileAdding()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ QGraphicsWidget grandGrandParent;
+ grandGrandParent.resize(200, 200);
+ scene.addItem(&grandGrandParent);
+ QGraphicsWidget grandParent;
+ grandParent.resize(200, 200);
+ QGraphicsWidget parent(&grandParent);
+ parent.resize(200, 200);
+ MyGraphicsItemWithItemChange item(&parent);
+ grandParent.setParentItem(&grandGrandParent);
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 587b7d5..4c0bc78 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -111,6 +111,8 @@ private slots:
void fontPropagationSceneChange();
void geometry_data();
void geometry();
+ void width();
+ void height();
void getContentsMargins_data();
void getContentsMargins();
void initStyleOption_data();
@@ -776,6 +778,32 @@ void tst_QGraphicsWidget::geometry()
QCOMPARE(widget.geometry(), QRectF(pos, size));
}
+void tst_QGraphicsWidget::width()
+{
+ QGraphicsWidget w;
+ QCOMPARE(w.property("width").toReal(), qreal(0));
+ QSignalSpy spy(&w, SIGNAL(widthChanged()));
+ w.setProperty("width", qreal(50));
+ QCOMPARE(w.property("width").toReal(), qreal(50));
+ QCOMPARE(spy.count(), 1);
+ //calling old school setGeometry should work too
+ w.setGeometry(0, 0, 200, 200);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_QGraphicsWidget::height()
+{
+ QGraphicsWidget w;
+ QCOMPARE(w.property("height").toReal(), qreal(0));
+ QSignalSpy spy(&w, SIGNAL(heightChanged()));
+ w.setProperty("height", qreal(50));
+ QCOMPARE(w.property("height").toReal(), qreal(50));
+ QCOMPARE(spy.count(), 1);
+ //calling old school setGeometry should work too
+ w.setGeometry(0, 0, 200, 200);
+ QCOMPARE(spy.count(), 2);
+}
+
void tst_QGraphicsWidget::getContentsMargins_data()
{
QTest::addColumn<qreal>("left");
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 90b5a22..2bf76e7 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -155,6 +155,7 @@ private slots:
void clearError();
void historyStateHasNowhereToGo();
void historyStateAsInitialState();
+ void historyStateAfterRestart();
void brokenStateIsNeverEntered();
void customErrorStateNotInGraph();
void transitionToStateNotInGraph();
@@ -906,6 +907,64 @@ void tst_QStateMachine::historyStateHasNowhereToGo()
QCOMPARE(machine.errorString(), QString::fromLatin1("Missing default state in history state 'historyState'"));
}
+void tst_QStateMachine::historyStateAfterRestart()
+{
+ // QTBUG-8842
+ QStateMachine machine;
+
+ QState *s1 = new QState(&machine);
+ machine.setInitialState(s1);
+ QState *s2 = new QState(&machine);
+ QState *s21 = new QState(s2);
+ QState *s22 = new QState(s2);
+ QHistoryState *s2h = new QHistoryState(s2);
+ s2h->setDefaultState(s21);
+ s1->addTransition(new EventTransition(QEvent::User, s2h));
+ s21->addTransition(new EventTransition(QEvent::User, s22));
+ s2->addTransition(new EventTransition(QEvent::User, s1));
+
+ for (int x = 0; x < 2; ++x) {
+ QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 1);
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ // s1 -> s2h -> s21 (default state)
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().count(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ // This used to fail on the 2nd run because the
+ // history had not been cleared.
+ QVERIFY(machine.configuration().contains(s21));
+
+ // s21 -> s22
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().count(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s22));
+
+ // s2 -> s1 (s22 saved in s2h)
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ // s1 -> s2h -> s22 (saved state)
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().count(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s22));
+
+ QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
+ machine.stop();
+ QTRY_COMPARE(stoppedSpy.count(), 1);
+ }
+}
+
void tst_QStateMachine::brokenStateIsNeverEntered()
{
QStateMachine machine;
diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro
index 38ea6c4..a7d426c 100644
--- a/tests/benchmarks/declarative/declarative.pro
+++ b/tests/benchmarks/declarative/declarative.pro
@@ -8,4 +8,4 @@ SUBDIRS += \
qdeclarativeimage \
qdeclarativemetaproperty \
script \
- qdeclarativetime
+ qmltime
diff --git a/tests/benchmarks/declarative/qdeclarativetime/example.qml b/tests/benchmarks/declarative/qmltime/example.qml
index dd6185d..68889f0 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/example.qml
+++ b/tests/benchmarks/declarative/qmltime/example.qml
@@ -1,11 +1,11 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
property string name: "Bob Smith"
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Item {
Text { text: name }
}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp
index 20f0d93d..3932e01 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp
+++ b/tests/benchmarks/declarative/qmltime/qmltime.cpp
@@ -156,7 +156,7 @@ int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- qmlRegisterType<Timer>("QDeclarativeTime", 1, 0, "Timer");
+ qmlRegisterType<Timer>("QmlTime", 1, 0, "Timer");
uint iterations = 1024;
QString filename;
@@ -228,4 +228,4 @@ int main(int argc, char ** argv)
return 0;
}
-#include "qdeclarativetime.moc"
+#include "qmltime.moc"
diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro b/tests/benchmarks/declarative/qmltime/qmltime.pro
index 7902ee1..9352f3b 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro
+++ b/tests/benchmarks/declarative/qmltime/qmltime.pro
@@ -1,10 +1,10 @@
load(qttest_p4)
TEMPLATE = app
-TARGET = qdeclarativetime
+TARGET = qmltime
QT += declarative
macx:CONFIG -= app_bundle
-SOURCES += qdeclarativetime.cpp
+SOURCES += qmltime.cpp
symbian* {
TARGET.CAPABILITY = "All -TCB"
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml
index 8d93594..31c879b 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Item {
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml
index 918c48a..23fe78e 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Item {
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml
index bb84538..bc447ef 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Item {
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml
index 978e3bf..c1cdb68 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
ParallelAnimation {
NumberAnimation { duration: 500 }
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml
index cceb3f4..3db9f08 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
ParallelAnimation {
NumberAnimation { }
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml
index 3387a32..996602c 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
children: [
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml
index a8b653c..9f79c34 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
data: [
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml
index 0a507d4..f228c2a 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml
index 227d8ad..335aeb8 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
resources: [
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml
index 6f8d849..6f8d849 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml
index 270add4..65d5010 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Loader {
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml
index d3b84cc..2dfe922 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Loader {}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml
index a94a12a..1fa0d3b 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Loaded {}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml
index 39ed1a6..33bb91c 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml
@@ -1,9 +1,9 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Loader {
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml
index c1f54a4..97bad47 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml
@@ -1,8 +1,8 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Rectangle { }
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml
index d49ff78..36dda15 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml
@@ -1,8 +1,8 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Rectangle { }
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml
index 05ca804..396e27d 100644
--- a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml
@@ -1,8 +1,8 @@
import Qt 4.6
-import QDeclarativeTime 1.0 as QDeclarativeTime
+import QmlTime 1.0 as QmlTime
Item {
- QDeclarativeTime.Timer {
+ QmlTime.Timer {
component: Component {
Item {
Rectangle { }