summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-09-15 06:23:57 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-09-15 06:23:57 (GMT)
commitb43b430b0668d145e31fd0445ed9d272270a576c (patch)
tree0cc28e21844da6d8717c9e47a51428a89e12d4b3
parent8cad28ef7abf92cab034ae3586e24cd0b8be38a2 (diff)
parent7c6bc5a25d11a9d455b5bf96cb5229f78790db3a (diff)
downloadQt-b43b430b0668d145e31fd0445ed9d272270a576c.zip
Qt-b43b430b0668d145e31fd0445ed9d272270a576c.tar.gz
Qt-b43b430b0668d145e31fd0445ed9d272270a576c.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/boxes/boxes.pro4
-rw-r--r--demos/composition/main.cpp6
-rw-r--r--demos/declarative/flickr/common/MediaLineEdit.qml2
-rw-r--r--demos/declarative/flickr/mobile/TitleBar.qml2
-rw-r--r--demos/declarative/minehunt/minehunt.qml4
-rw-r--r--demos/declarative/samegame/content/BoomBlock.qml4
-rw-r--r--demos/declarative/twitter/content/AuthView.qml14
-rw-r--r--demos/declarative/twitter/content/HomeTitleBar.qml2
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml3
-rw-r--r--dist/changes-4.6.011
-rw-r--r--doc/src/declarative/cppitem.qdoc6
-rw-r--r--doc/src/declarative/elements.qdoc2
-rw-r--r--doc/src/declarative/pics/qml-context-object.pngbin0 -> 23602 bytes
-rw-r--r--doc/src/declarative/pics/qml-context-tree.pngbin0 -> 10337 bytes
-rw-r--r--doc/src/declarative/pics/qml-context.pngbin0 -> 61465 bytes
-rw-r--r--doc/src/declarative/qmlforcpp.qdoc2
-rw-r--r--doc/src/declarative/qmlformat.qdoc175
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc2
-rw-r--r--doc/src/frameworks-technologies/gestures.qdoc8
-rw-r--r--doc/src/snippets/code/src_corelib_io_qfileinfo.cpp6
-rw-r--r--doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp41
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml10
-rw-r--r--doc/src/tutorials/declarative.qdoc2
-rw-r--r--doc/src/widgets-and-layouts/stylesheet.qdoc8
-rw-r--r--examples/declarative/aspectratio/face_fit_animated.qml2
-rw-r--r--examples/declarative/clock/Clock.qml6
-rw-r--r--examples/declarative/dial/DialLibrary/Dial.qml4
-rw-r--r--examples/declarative/extending/adding/example.qml2
-rw-r--r--examples/declarative/extending/attached/example.qml2
-rw-r--r--examples/declarative/extending/binding/example.qml2
-rw-r--r--examples/declarative/extending/coercion/example.qml2
-rw-r--r--examples/declarative/extending/default/example.qml2
-rw-r--r--examples/declarative/extending/extended/example.qml2
-rw-r--r--examples/declarative/extending/extended/lineedit.cpp2
-rw-r--r--examples/declarative/extending/grouped/example.qml2
-rw-r--r--examples/declarative/extending/properties/example.qml2
-rw-r--r--examples/declarative/extending/signal/example.qml2
-rw-r--r--examples/declarative/extending/valuesource/example.qml2
-rw-r--r--examples/declarative/focusscope/test3.qml4
-rw-r--r--examples/declarative/follow/follow.qml10
-rw-r--r--examples/declarative/follow/pong.qml6
-rw-r--r--examples/declarative/listview/content/ClickAutoRepeating.qml29
-rw-r--r--examples/declarative/listview/content/pics/add.pngbin0 -> 1577 bytes
-rw-r--r--examples/declarative/listview/content/pics/del.pngbin0 -> 1661 bytes
-rw-r--r--examples/declarative/listview/content/pics/trash.pngbin0 -> 989 bytes
-rw-r--r--examples/declarative/listview/dynamic.qml142
-rw-r--r--examples/declarative/listview/highlight.qml2
-rw-r--r--examples/declarative/listview/itemlist.qml4
-rw-r--r--examples/declarative/listview/listview.qml43
-rw-r--r--examples/declarative/loader/Browser.qml2
-rw-r--r--examples/declarative/snow/snow.qml6
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml12
-rw-r--r--examples/declarative/velocity/Day.qml2
-rw-r--r--examples/declarative/webview/newwindows.qml2
-rw-r--r--examples/declarative/xmldata/yahoonews.qml1
-rw-r--r--examples/opengl/opengl.pro3
-rw-r--r--examples/opengl/textures/glwidget.cpp74
-rw-r--r--examples/opengl/textures/glwidget.h8
-rw-r--r--examples/opengl/textures/window.cpp4
-rw-r--r--mkspecs/common/wince/qmake.conf (renamed from mkspecs/common/wince.conf)0
-rw-r--r--mkspecs/common/wince/qplatformdefs.h131
-rw-r--r--mkspecs/wince50standard-armv4i-msvc2005/qmake.conf2
-rw-r--r--mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h2
-rw-r--r--mkspecs/wince50standard-mipsii-msvc2005/qmake.conf2
-rw-r--r--mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h2
-rw-r--r--mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf2
-rw-r--r--mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h2
-rw-r--r--mkspecs/wince50standard-sh4-msvc2005/qmake.conf2
-rw-r--r--mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h2
-rw-r--r--mkspecs/wince50standard-x86-msvc2005/qmake.conf2
-rw-r--r--mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h2
-rw-r--r--mkspecs/wince60standard-armv4i-msvc2005/qmake.conf79
-rw-r--r--mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wince60standard-x86-msvc2005/qmake.conf27
-rw-r--r--mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h43
-rw-r--r--mkspecs/wincewm50pocket-msvc2005/qmake.conf2
-rw-r--r--mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h2
-rw-r--r--mkspecs/wincewm50smart-msvc2005/qmake.conf2
-rw-r--r--mkspecs/wincewm50smart-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wincewm50smart-msvc2008/qplatformdefs.h2
-rw-r--r--mkspecs/wincewm60professional-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wincewm60professional-msvc2008/qplatformdefs.h2
-rw-r--r--mkspecs/wincewm60standard-msvc2005/qplatformdefs.h90
-rw-r--r--mkspecs/wincewm60standard-msvc2008/qplatformdefs.h2
-rw-r--r--mkspecs/wincewm65professional-msvc2005/qplatformdefs.h3
-rw-r--r--mkspecs/wincewm65professional-msvc2008/qplatformdefs.h2
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi2
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp3
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/JSTypeInfo.h (renamed from src/3rdparty/webkit/JavaScriptCore/runtime/TypeInfo.h)6
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h2
-rw-r--r--src/corelib/animation/qabstractanimation.cpp17
-rw-r--r--src/corelib/global/qnamespace.h3
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp23
-rw-r--r--src/corelib/tools/qlist.h19
-rw-r--r--src/corelib/tools/qtimeline.cpp4
-rw-r--r--src/declarative/QmlChanges.txt19
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp126
-rw-r--r--src/declarative/extra/qmlxmllistmodel.h40
-rw-r--r--src/declarative/fx/fx.pri3
-rw-r--r--src/declarative/fx/qfxcomponentinstance.cpp149
-rw-r--r--src/declarative/fx/qfxcomponentinstance_p.h76
-rw-r--r--src/declarative/fx/qfxflickable.cpp34
-rw-r--r--src/declarative/fx/qfxflipable.cpp4
-rw-r--r--src/declarative/fx/qfxgridview.cpp103
-rw-r--r--src/declarative/fx/qfxgridview.h11
-rw-r--r--src/declarative/fx/qfximage.cpp41
-rw-r--r--src/declarative/fx/qfxitem.cpp12
-rw-r--r--src/declarative/fx/qfxitem.h4
-rw-r--r--src/declarative/fx/qfxlistview.cpp360
-rw-r--r--src/declarative/fx/qfxlistview.h40
-rw-r--r--src/declarative/fx/qfxloader.cpp260
-rw-r--r--src/declarative/fx/qfxloader.h13
-rw-r--r--src/declarative/fx/qfxloader_p.h6
-rw-r--r--src/declarative/fx/qfxpathview.cpp3
-rw-r--r--src/declarative/fx/qfxpositioners.cpp12
-rw-r--r--src/declarative/fx/qfxtext.cpp21
-rw-r--r--src/declarative/fx/qfxtextedit.cpp26
-rw-r--r--src/declarative/fx/qfxtextedit.h12
-rw-r--r--src/declarative/fx/qfxtextedit_p.h4
-rw-r--r--src/declarative/fx/qfxtextinput.cpp134
-rw-r--r--src/declarative/fx/qfxtextinput.h31
-rw-r--r--src/declarative/fx/qfxtextinput_p.h8
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp46
-rw-r--r--src/declarative/qml/parser/qmljs.g1
-rw-r--r--src/declarative/qml/parser/qmljsastfwd_p.h4
-rw-r--r--src/declarative/qml/parser/qmljsengine_p.cpp6
-rw-r--r--src/declarative/qml/parser/qmljsengine_p.h4
-rw-r--r--src/declarative/qml/parser/qmljslexer.cpp11
-rw-r--r--src/declarative/qml/parser/qmljslexer_p.h3
-rw-r--r--src/declarative/qml/qmetaobjectbuilder_p.h8
-rw-r--r--src/declarative/qml/qmlbinding.cpp4
-rw-r--r--src/declarative/qml/qmlcompiler.cpp11
-rw-r--r--src/declarative/qml/qmlcomponent.cpp5
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp1
-rw-r--r--src/declarative/qml/qmlcustomparser.cpp51
-rw-r--r--src/declarative/qml/qmlcustomparser_p.h19
-rw-r--r--src/declarative/qml/qmlcustomparser_p_p.h9
-rw-r--r--src/declarative/qml/qmlenginedebug.cpp7
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp24
-rw-r--r--src/declarative/qml/qmlmetatype.cpp1
-rw-r--r--src/declarative/qml/qmlrewrite.cpp4
-rw-r--r--src/declarative/util/qfxperf.cpp1
-rw-r--r--src/declarative/util/qfxperf_p.h1
-rw-r--r--src/declarative/util/qfxview.cpp2
-rw-r--r--src/declarative/util/qmlanimation.cpp3
-rw-r--r--src/declarative/util/qmleasefollow.cpp415
-rw-r--r--src/declarative/util/qmleasefollow.h (renamed from src/declarative/fx/qfxcomponentinstance.h)62
-rw-r--r--src/declarative/util/qmllistmodel.cpp334
-rw-r--r--src/declarative/util/qmllistmodel.h10
-rw-r--r--src/declarative/util/qmlpropertychanges.cpp7
-rw-r--r--src/declarative/util/qmlspringfollow.cpp (renamed from src/declarative/util/qmlfollow.cpp)134
-rw-r--r--src/declarative/util/qmlspringfollow.h (renamed from src/declarative/util/qmlfollow.h)15
-rw-r--r--src/declarative/util/util.pri6
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp4
-rw-r--r--src/gui/kernel/qapplication.cpp14
-rw-r--r--src/gui/kernel/qapplication_qws.cpp7
-rw-r--r--src/gui/kernel/qstandardgestures.cpp6
-rw-r--r--src/gui/kernel/qwidget.h1
-rw-r--r--src/gui/painting/qpaintengine.cpp1
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp8
-rw-r--r--src/gui/text/qtextlayout.cpp155
-rw-r--r--src/gui/widgets/qlinecontrol_p.h6
-rw-r--r--src/gui/widgets/qlineedit.cpp2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp5
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp81
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h3
-rw-r--r--src/opengl/opengl.pro7
-rw-r--r--src/opengl/qgl.cpp503
-rw-r--r--src/opengl/qgl.h8
-rw-r--r--src/opengl/qgl_p.h67
-rw-r--r--src/opengl/qgl_x11.cpp1
-rw-r--r--src/opengl/qglframebufferobject.cpp157
-rw-r--r--src/opengl/qglframebufferobject.h10
-rw-r--r--src/opengl/qglframebufferobject_p.h152
-rw-r--r--src/opengl/qglpaintdevice.cpp187
-rw-r--r--src/opengl/qglpaintdevice_p.h112
-rw-r--r--src/opengl/qglpixelbuffer.cpp17
-rw-r--r--src/opengl/qglpixelbuffer.h2
-rw-r--r--src/opengl/qglpixelbuffer_p.h15
-rw-r--r--src/opengl/qpaintengine_opengl.cpp121
-rw-r--r--src/opengl/qpixmapdata_gl.cpp123
-rw-r--r--src/opengl/qpixmapdata_gl_p.h52
-rw-r--r--src/opengl/qwindowsurface_gl.cpp65
-rw-r--r--src/opengl/qwindowsurface_gl_p.h19
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp36
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h2
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp2
-rw-r--r--src/scripttools/debugging/qscriptdebuggerbackend.cpp8
-rw-r--r--tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp14
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing.qml20
-rw-r--r--tests/auto/declarative/layouts/data/grid.qml20
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing.qml12
-rw-r--r--tests/auto/declarative/layouts/data/horizontal.qml12
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing.qml12
-rw-r--r--tests/auto/declarative/layouts/data/vertical.qml12
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp76
-rw-r--r--tests/auto/declarative/listview/data/listview.qml4
-rw-r--r--tests/auto/declarative/listview/tst_listview.cpp28
-rw-r--r--tests/auto/declarative/numberformatter/tst_numberformatter.cpp15
-rw-r--r--tests/auto/declarative/pathview/data/pathview.qml10
-rw-r--r--tests/auto/declarative/pathview/tst_pathview.cpp8
-rw-r--r--tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp4
-rw-r--r--tests/auto/declarative/qfxloader/NoResize.qml7
-rw-r--r--tests/auto/declarative/qfxloader/Rect120x60.qml6
-rw-r--r--tests/auto/declarative/qfxloader/SetSourceComponent.qml6
-rw-r--r--tests/auto/declarative/qfxloader/SizeToItem.qml6
-rw-r--r--tests/auto/declarative/qfxloader/SizeToLoader.qml7
-rw-r--r--tests/auto/declarative/qfxloader/qfxloader.pro5
-rw-r--r--tests/auto/declarative/qfxloader/tst_qfxloader.cpp103
-rw-r--r--tests/auto/declarative/qfxtext/tst_qfxtext.cpp160
-rw-r--r--tests/auto/declarative/qfxtextedit/data/cursorTest.qml6
-rw-r--r--tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp64
-rw-r--r--tests/auto/declarative/qfxtextinput/data/navigation.qml4
-rw-r--r--tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp291
-rw-r--r--tests/auto/declarative/qmlparser/Alias.qml8
-rw-r--r--tests/auto/declarative/qmlparser/alias.1.qml8
-rw-r--r--tests/auto/declarative/qmlparser/alias.2.qml8
-rw-r--r--tests/auto/declarative/qmlparser/alias.3.qml10
-rw-r--r--tests/auto/declarative/qmlparser/customParserIdNotAllowed.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/customParserIdNotAllowed.qml5
-rw-r--r--tests/auto/declarative/qmlparser/listItemDeleteSelf.qml38
-rw-r--r--tests/auto/declarative/qmlparser/testtypes.h8
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp75
-rw-r--r--tests/auto/declarative/repeater/data/repeater.qml6
-rw-r--r--tests/auto/declarative/repeater/tst_repeater.cpp22
-rw-r--r--tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp117
-rw-r--r--tests/auto/network-settings.h16
-rw-r--r--tests/auto/qabstractbutton/tst_qabstractbutton.cpp5
-rw-r--r--tests/auto/qbuttongroup/tst_qbuttongroup.cpp8
-rw-r--r--tests/auto/qbytearray/qbytearray.pro11
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp10
-rw-r--r--tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp7
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp14
-rw-r--r--tests/auto/qfocusevent/tst_qfocusevent.cpp25
-rw-r--r--tests/auto/qgl/tst_qgl.cpp49
-rw-r--r--tests/auto/qgridlayout/tst_qgridlayout.cpp11
-rw-r--r--tests/auto/qgroupbox/tst_qgroupbox.cpp6
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp9
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp9
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp30
-rw-r--r--tests/auto/qmdiarea/tst_qmdiarea.cpp17
-rw-r--r--tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp42
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp14
-rw-r--r--tests/auto/qmultiscreen/qmultiscreen.pro1
-rw-r--r--tests/auto/qpushbutton/tst_qpushbutton.cpp8
-rw-r--r--tests/auto/qspinbox/tst_qspinbox.cpp20
-rw-r--r--tests/auto/qstackedlayout/tst_qstackedlayout.cpp13
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp25
-rw-r--r--tests/auto/qtextbrowser/tst_qtextbrowser.cpp6
-rw-r--r--tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp8
-rw-r--r--tests/auto/qtransformedscreen/qtransformedscreen.pro1
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp5
-rw-r--r--tests/auto/qwsembedwidget/qwsembedwidget.pro1
-rw-r--r--tests/auto/qwsinputmethod/qwsinputmethod.pro1
-rw-r--r--tests/auto/qwswindowsystem/qwswindowsystem.pro1
-rw-r--r--tools/qmldebugger/engines.qml6
263 files changed, 5195 insertions, 3124 deletions
diff --git a/demos/boxes/boxes.pro b/demos/boxes/boxes.pro
index 59c9132..4963fb9 100644
--- a/demos/boxes/boxes.pro
+++ b/demos/boxes/boxes.pro
@@ -44,6 +44,6 @@ wince*: {
win32-msvc* {
QMAKE_CXXFLAGS -= -Zm200
QMAKE_CFLAGS -= -Zm200
- QMAKE_CXXFLAGS += -Zm1200
- QMAKE_CFLAGS += -Zm1200
+ QMAKE_CXXFLAGS += -Zm500
+ QMAKE_CFLAGS += -Zm500
}
diff --git a/demos/composition/main.cpp b/demos/composition/main.cpp
index 3a959a9..fe142ad 100644
--- a/demos/composition/main.cpp
+++ b/demos/composition/main.cpp
@@ -42,11 +42,17 @@
#include "composition.h"
#include <QApplication>
+#ifdef QT_OPENGL_SUPPORT
+#include <QtOpenGL>
+#endif
int main(int argc, char **argv)
{
// Q_INIT_RESOURCE(deform);
+#ifdef QT_OPENGL_SUPPORT
+ QGL::setPreferredPaintEngine(QPaintEngine::OpenGL);
+#endif
QApplication app(argc, argv);
CompositionWidget compWidget(0);
diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml
index 094571f..7599ce6a05 100644
--- a/demos/declarative/flickr/common/MediaLineEdit.qml
+++ b/demos/declarative/flickr/common/MediaLineEdit.qml
@@ -90,7 +90,7 @@ Item {
id: Editor
font.bold: true
color: "white"
- highlightColor: "green"
+ selectionColor: "green"
width: 0
clip: true
anchors.left: Label.right
diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml
index b95452a..13484a2 100644
--- a/demos/declarative/flickr/mobile/TitleBar.qml
+++ b/demos/declarative/flickr/mobile/TitleBar.qml
@@ -50,7 +50,7 @@ Item {
verticalCenter: parent.verticalCenter
}
cursorVisible: true; font.bold: true
- color: "#151515"; highlightColor: "Green"
+ color: "#151515"; selectionColor: "Green"
}
Keys.forwardTo: [ (ReturnKey), (Editor)]
diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml
index fa169aa..72431af 100644
--- a/demos/declarative/minehunt/minehunt.qml
+++ b/demos/declarative/minehunt/minehunt.qml
@@ -135,8 +135,8 @@ Item {
x: 1
y: 1
Component {
- ComponentInstance {
- component: tile
+ Loader {
+ sourceComponent: tile
x: (index - (Math.floor(index/9) * 9)) * 41
y: Math.floor(index/9) * 41
}
diff --git a/demos/declarative/samegame/content/BoomBlock.qml b/demos/declarative/samegame/content/BoomBlock.qml
index 7860cf4..a495cd0 100644
--- a/demos/declarative/samegame/content/BoomBlock.qml
+++ b/demos/declarative/samegame/content/BoomBlock.qml
@@ -7,8 +7,8 @@ Item { id:block
property int targetX: 0
property int targetY: 0
- x: Follow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 }
- y: Follow { source: targetY; spring: 2; damping: 0.2 }
+ x: SpringFollow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 }
+ y: SpringFollow { source: targetY; spring: 2; damping: 0.2 }
Image { id: img
source: {
diff --git a/demos/declarative/twitter/content/AuthView.qml b/demos/declarative/twitter/content/AuthView.qml
index 7d0d865..3fe7e7e 100644
--- a/demos/declarative/twitter/content/AuthView.qml
+++ b/demos/declarative/twitter/content/AuthView.qml
@@ -5,10 +5,9 @@ import "../../flickr/mobile"
Item {
id: wrapper
Column {
- width: childrenRect.width; height:childrenRect.height; anchors.centerIn: parent
+ anchors.centerIn: parent
spacing: 20
Row{
- width: childrenRect.width; height:childrenRect.height;
spacing: 4
Text {
width: 100
@@ -28,7 +27,7 @@ Item {
anchors.centerIn: parent
maximumLength:21
font.bold: true
- color: "#151515"; highlightColor: "green"
+ color: "#151515"; selectionColor: "green"
Keys.forwardTo: [(tabber), (nameIn)]
Item {
id: tabber
@@ -39,7 +38,6 @@ Item {
}
}
Row{
- width: childrenRect.width; height:childrenRect.height;
spacing: 4
Text {
width: 100
@@ -58,15 +56,15 @@ Item {
height: parent.height - 12
anchors.centerIn: parent
maximumLength:21
- echoMode: 2
+ echoMode: TextInput.Password
font.bold: true
- color: "#151515"; highlightColor: "green"
+ color: "#151515"; selectionColor: "green"
}
}
}
Item{
- width: childrenRect.width; anchors.horizontalCenter: parent.horizontalCenter
- height: childrenRect.height
+ width: childrenRect.width; height:childrenRect.height;
+ anchors.horizontalCenter: parent.horizontalCenter
Button {
x: 10
width: 100
diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml
index 9bca2c8..bd3bc2c 100644
--- a/demos/declarative/twitter/content/HomeTitleBar.qml
+++ b/demos/declarative/twitter/content/HomeTitleBar.qml
@@ -92,7 +92,7 @@ Item {
height: parent.height - 8
font.pointSize: 10
wrap:true
- color: "#151515"; highlightColor: "green"
+ color: "#151515"; selectionColor: "green"
}
Keys.forwardTo: [(ReturnKey), (Editor)]
Item {
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 9a8af29..3f23d83 100644
--- a/demos/declarative/webbrowser/webbrowser.qml
+++ b/demos/declarative/webbrowser/webbrowser.qml
@@ -55,7 +55,7 @@ Item {
id: Header
source: "content/pics/header.png"
width: parent.width
- height: 64
+ height: 60
state: "Normal"
x: Flick.viewportX < 0 ? -Flick.viewportX : Flick.viewportX > Flick.viewportWidth-Flick.width
? -Flick.viewportX+Flick.viewportWidth-Flick.width : 0
@@ -167,6 +167,7 @@ Item {
anchors.bottom: Footer.top
anchors.left: parent.left
anchors.right: parent.right
+ pressDelay: 200
WebView {
id: MyWebView
diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0
index ca984ac..f9984d3 100644
--- a/dist/changes-4.6.0
+++ b/dist/changes-4.6.0
@@ -54,8 +54,15 @@ information about a particular change.
this is that Nokia focuses on OpenGL for desktop hardware accelerated
rendering.
- - When mixing OpenGL and QPainter calls you need to surround your custom
- OpenGL calls with QPainter::beginNativePainting() and
+ - The default engine used to draw onto OpenGL buffers has changed in
+ Qt 4.6. The QPaintEngine::OpenGL2 engine is now used as the default
+ engine. This *may* cause compatibility problems for applications
+ that use a mix of QPainter and native OpenGL calls to draw into a GL
+ buffer. Use the QGL::setPreferredPaintEngine() function to enforce
+ usage of the old GL paint engine.
+
+ - When mixing OpenGL and QPainter calls you need to surround your
+ custom OpenGL calls with QPainter::beginNativePainting() and
QPainter::endNativePainting().
This is to ensure that the paint engine flushes any pending drawing and sets
up the GL modelview/projection matrices properly before you can issue custom
diff --git a/doc/src/declarative/cppitem.qdoc b/doc/src/declarative/cppitem.qdoc
index 4543156..38da0fb 100644
--- a/doc/src/declarative/cppitem.qdoc
+++ b/doc/src/declarative/cppitem.qdoc
@@ -94,7 +94,7 @@ You can create a new type of QML item by:
To add a new type, you first must add a new C++ class derived from QFxItem.
You may of course extend existing QFxItem subclasses.
-One existing subclass is QFxPainted, which provides
+One existing subclass is QFxPaintedItem, which provides
a simple cached-image painting model.
\section2 Reimplementing paint functions
@@ -105,11 +105,11 @@ Two alternative painters are available, offering
different levels of performance and functionality:
QPainter, GLPainter.
-You can choose to subclass QFxPainted rather than QFxItem,
+You can choose to subclass QFxPaintedItem rather than QFxItem,
and then implement the virtual method:
\code
- void paint(QPainter *painter);
+ void drawContents(QPainter *painter, const QRect &rect);
\endcode
This paints into an offscreen pixmap which is then painted to the display (transformed,
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index bfaf4ab..ca17fda 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -37,6 +37,7 @@ The following table lists the QML elements provided by the Qt Declarative module
\o \l ScriptAction
\o \l Transition
\o \l Follow
+\o \l EaseFollow
\o \l Behavior
\endlist
@@ -100,7 +101,6 @@ The following table lists the QML elements provided by the Qt Declarative module
\o \l Loader
\o \l Repeater
\o \l SystemPalette
-\o \l ComponentInstance
\o \l GraphicsObjectContainer
\endlist
diff --git a/doc/src/declarative/pics/qml-context-object.png b/doc/src/declarative/pics/qml-context-object.png
new file mode 100644
index 0000000..1b91aff
--- /dev/null
+++ b/doc/src/declarative/pics/qml-context-object.png
Binary files differ
diff --git a/doc/src/declarative/pics/qml-context-tree.png b/doc/src/declarative/pics/qml-context-tree.png
new file mode 100644
index 0000000..6bba5f4
--- /dev/null
+++ b/doc/src/declarative/pics/qml-context-tree.png
Binary files differ
diff --git a/doc/src/declarative/pics/qml-context.png b/doc/src/declarative/pics/qml-context.png
new file mode 100644
index 0000000..bdf2ecd
--- /dev/null
+++ b/doc/src/declarative/pics/qml-context.png
Binary files differ
diff --git a/doc/src/declarative/qmlforcpp.qdoc b/doc/src/declarative/qmlforcpp.qdoc
index 5838df7..ab456e5 100644
--- a/doc/src/declarative/qmlforcpp.qdoc
+++ b/doc/src/declarative/qmlforcpp.qdoc
@@ -15,6 +15,8 @@
either for the first time at startup or subsequently thereafter - the
property is automatically updated with the new value.
+ \tableofcontents
+
\section1 Loading and using QML Files
QmlComponent is used to load a QML file and to create object instances.
diff --git a/doc/src/declarative/qmlformat.qdoc b/doc/src/declarative/qmlformat.qdoc
index 9cfebf0..f16adca 100644
--- a/doc/src/declarative/qmlformat.qdoc
+++ b/doc/src/declarative/qmlformat.qdoc
@@ -16,21 +16,148 @@ Much of a QML file consists of valid ECMAScript \e {Statement}s. Except where c
by ECMAScript, C++ or QObject prevented it, the syntactic extensions introduced by QML are designed
to look similar and fit well with existing ECMAScript syntax and concepts.
+\section1 QML engine
+
+The \l {QmlEngine}{QML engine} executes a \l {QmlComponent}{QML document} in a
+\l {QmlContext}{QML context} to produce a \l {QObject}{QML object}. A single QML
+document may be executed in one or many contexts to produce many QML objects. A single
+QML document may be executed many times in the same context to produce many QML objects.
+
+The QML engine provides the environment in which QML documents, contexts and objects
+exist. It must exist before any of these structures can be created. If the engine is removed,
+existing documents, contexts and objects are invalidated, but not destroyed. An invalid
+
+\list
+\i \e {QML document} can no longer be used to create QML objects.
+\i \e {QML context} can no longer host QML objects, new context properties cannot be added
+and existing context properties cannot be modified.
+\i \e {QML object} will no longer evaluate bindings or scripts.
+\endlist
+
+A QML document is a block of QML source code. QML documents generally correspond to files stored
+on a disk or network resource, but can be constructed directly from text data. Syntactically a QML
+document is self contained; QML does \bold {not} have a preprocessor that modifies the document
+before presentation to the compiler. Type references within a QML document are resolved based
+exclusively on the import statements present in the document.
+
+A simple QML document looks like this:
+
+\table
+\row
+\o
+\code
+import Qt 4.6
+
+Rectangle {
+ id: MyRect
+ width: 100; height: 100
+ color: background
+}
+\endcode
+\endtable
+
+To instantiate a QML object, a QML document is executed in a QML context. QML contexts are used by
+programmers to pass data to a QML document. QML documents may include property bindings or
+ECMAScript blocks that can contain variable references that need to be resolved. Each property
+binding and ECMAScript block has an associated QML context that is used to resolve these references
+that is determined by the QML context in which the document is executed. The example document above
+contains one variable reference, \c background.
+
+Each QML context defines a scope for variable resolution and each may define local, named context
+properties. A QML context may also have a \l {QmlContext::addDefaultObject()}{default object},
+which is an object whose properties are searched \e after the context properties when resolving a
+variable name. QML contexts form a tree, starting from a root context that is provided by the QML
+engine. When resolving variable references, the QML contexts are searched starting from the
+QML objects containing context upwards towards the root context.
+
+Consider the following QML context tree. If the example QML document is executed in \c Context1,
+the \c background variable will resolve to \c Context1's context property. If the document is
+executed in \c Context2, the \c background variable will resolve to the root context's context
+property.
+
+\image qml-context-tree.png
+
+While QML contexts can be created explicitly by the programmer to pass data into QML objects,
+the QML engine also creates a new implicit QML context for every object it instantiates.
+Property bindings and ECMAScript blocks in the document are associated with this QML engine
+created context. Object ids that are defined in the document are added as context properties, and
+their value is set to reference the appropriate object, and the instantiated QML object is set as
+the context's default object. The following diagram shows the result of executing a simple QML
+document.
+
+\image qml-context-object.png
+
+The blue rectangle in the diagram represents a property binding. Associated with each property
+binding is the QML context to which it belongs, the object property to which it is bound and a
+\e {scope object}. The scope object is usually, but not always, the object to which the bound
+property belongs. The context properties, context default objects and the scope object are all
+involved when resolving a variable name in a binding. The following pseudo code describes the
+algorithm used:
+
+\table
+\row
+\o
+\code
+if (scopeObject.hasProperty(name))
+ return scopeObject.property(name)
+
+foreach (context in contextChain) {
+ if (context.hasContextProperty(name)
+ return context.contextProperty(name)
+
+ if (context.defaultObject.hasProperty(name))
+ return context.defaultObject.property(name)
+}
+\endcode
+\endtable
+
+QML supports two categories of types: \e builtin types and \e composite types. Builtin types are
+those written in C++ and registered with the QML engine. Builtin types form the most basic
+building blocks of QML. Composite types are constructed by composing other builtin or composite
+types, property bindings and ECMAScript blocks together into a brand new type using the QML
+language. Using a composite type is identical to using a builtin type.
+
+For example, Qt 4.6 includes a builtin type called \c Image that shows a bitmap image. The
+\c Image type has \c width and \c height properties that control the size of the displayed image.
+A simple composite type, that will be called \c SquareImage can be built that adds a \c size
+property that sets both the width and the height.
+
+\table
+\row
+\o
+\code
+import Qt 4.6
+Image {
+ property int size
+ width: size
+ height: size
+}
+\endcode
+\endtable
+
+To the QML engine, a composite type is just another QML document. When a composite type is
+used the engine instantiates it just as it would any other document - by creating a new implicit
+QML context and the object tree described by the document. The diagram below shows the
+\c SquareImage composite type used from within another QML document. When instantiated, the
+\c SquareImage object is created in its own QML context. Any property bindings specified in the
+\c SquareImage composite type document are associated with this context. Property bindings created
+in the outer document, however, are associated with its context, even those that are applied to the
+created \c SquareImage object. That is, the \c size, \c source, \c width and \c height property
+bindings all share a common \e {scope object}, but are owned by two different QML contexts. The
+difference in containing context results in the \c Root variable resolving differently in the
+different property bindings.
+
+\image qml-context.png
+
+\section1 Syntax
+
\section2 Commenting
The commenting rules in QML are the same as for ECMAScript. Both \e {MultiLineComment} blocks and \e {SingleLineComment}'s are supported.
-\section1 Definitions
-
-\e {QML interpreter}: QmlEngine
-
-\e {QML execution context}: QmlContext
+\section2 QML Document
-\e {inherited characteristic}
-
-\section1 QML Document
-
-\section2 Syntax
+\section3 Syntax
\e {QMLDocument} \bold {:}
@@ -69,22 +196,16 @@ The commenting rules in QML are the same as for ECMAScript. Both \e {MultiLineC
\e {DecimalLiteral} \bold {but not} with \e {ExponentPart}
\endquotation
-\section2 Semantics
-
-A QML document is the unit in which QML code may be passed to the QML interpreter. A QML document
-is syntactically self contained. QML documents are evaluated by the QML interpreter in a QML
-execution context to produce a single instantiated object of the type specified by
-\e {QMLObjectDefinition}.
+\section3 Semantics
The \e {QMLImportList} is used to statically resolve type references used within the enclosing
-QML document. The import list is \bold {not} an \e {inherited characteristic}; its scope of
-influence is limited to structures logically contained by the document.
+QML document.
An import statement is used to bring a set of types into scope for a QML document.
-\section1 Object Definition
+\section2 Object Definition
-\section2 Syntax
+\section3 Syntax
\e {QMLObjectDefinition} \bold {:}
\quotation
@@ -125,11 +246,11 @@ An import statement is used to bring a set of types into scope for a QML documen
\endquotation
-\section2 Semantics
+\section3 Semantics
-\section1 Object Extension
+\section2 Object Extension
-\section2 Syntax
+\section3 Syntax
\e {QMLObjectExtensionDefinition} \bold {:}
\quotation
@@ -171,14 +292,14 @@ An import statement is used to bring a set of types into scope for a QML documen
\quotation
\e {FunctionDeclaration} \bold {but not} \e {Identifier} \sub {opt}
\endquotation
-\section2 Semantics
+\section3 Semantics
-\section1 Binding Expression
+\section2 Binding Expression
-\section2 Syntax
+\section3 Syntax
\e {QMLBindingExpression} \bold {:}
-\section2 Semantics
+\section3 Semantics
*/
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index 1b7644c..460819a 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -80,7 +80,7 @@
QML Reference:
\list
- \o \l {QML Format}
+ \o \l {QML Format Reference}
\o \l {elements}{QML Elements}
\endlist
diff --git a/doc/src/frameworks-technologies/gestures.qdoc b/doc/src/frameworks-technologies/gestures.qdoc
index 317bb31..7929331 100644
--- a/doc/src/frameworks-technologies/gestures.qdoc
+++ b/doc/src/frameworks-technologies/gestures.qdoc
@@ -81,7 +81,7 @@
\table
\header \o New State \o Description \o QGesture Actions on Entering this State
- \row \o Qt::NoGesture \o Initial value \o emit \l {QGesture::cancelled()}{cancelled()}
+ \row \o Qt::NoGesture \o Initial value \o emit \l {QGesture::canceled()}{canceled()}
\row \o Qt::GestureStarted \o A continuous gesture has started \o emit \l{QGesture::started()}{started()} and emit \l{QGesture::triggered()}{triggered()}
\row \o Qt::GestureUpdated \o A gesture continues \o emit \l{QGesture::triggered()}{triggered()}
\row \o Qt::GestureFinished \o A gesture has finished. \o emit \l{QGesture::finished()}{finished()}
@@ -130,13 +130,13 @@
then the gesture is considered to have finished whether or not the
appropriate touch or mouse event has occurred. Also if a large jump in
the position of the event occurs, as calculated by the \l {QPoint::manhattanLength()}{manhattanLength()}
- call, then the gesture is cancelled by calling \l{QGesture::reset()}{reset()}
+ call, then the gesture is canceled by calling \l{QGesture::reset()}{reset()}
which tidies up and uses \l{QGesture::updateState()}{updateState()} to
- change state to NoGesture which will result in the \l{QGesture::cancelled()}{cancelled()}
+ change state to NoGesture which will result in the \l{QGesture::canceled()}{canceled()}
signal being emitted by the recognizer.
ImageWidget handles the signals by connecting the slots to the signals,
- although \c cancelled() is not connected here.
+ although \c canceled() is not connected here.
\snippet doc/src/snippets/gestures/imageviewer/imagewidget.cpp imagewidget-connect
diff --git a/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp
index f01757a..d2096cf 100644
--- a/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp
+++ b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp
@@ -72,9 +72,9 @@ info1.size(); // returns 743
info1.symLinkTarget(); // returns "C:/Pretty++/untabify"
QFileInfo info2(info1.symLinkTarget());
-info1.isSymLink(); // returns false
-info1.absoluteFilePath(); // returns "C:/Pretty++/untabify"
-info1.size(); // returns 63942
+info2.isSymLink(); // returns false
+info2.absoluteFilePath(); // returns "C:/Pretty++/untabify"
+info2.size(); // returns 63942
#endif
//! [1]
diff --git a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
index 128799f..8933ef3 100644
--- a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
+++ b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
//! [simple state machine]
QPushButton button;
diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml
index 29f41bf..97eac45 100644
--- a/doc/src/snippets/declarative/listview/highlight.qml
+++ b/doc/src/snippets/declarative/listview/highlight.qml
@@ -15,7 +15,7 @@ Rectangle {
Item {
id: Wrapper
width: 180; height: 40
- VerticalLayout {
+ Column {
x: 5; y: 5
Text { text: '<b>Name:</b> ' + name }
Text { text: '<b>Number:</b> ' + number }
@@ -32,10 +32,10 @@ Rectangle {
Rectangle {
width: 180; height: 40
color: "lightsteelblue"; radius: 5
- y: Follow {
- source: List.current.y
+ y: SpringFollow {
+ source: List.currentItem.y
spring: 3
- damping: 0.1
+ damping: 0.2
}
}
}
@@ -44,7 +44,7 @@ Rectangle {
width: parent.height; height: parent.height
model: ContactModel; delegate: Delegate
highlight: Highlight
- autoHighlight: false
+ highlightFollowsCurrentItem: false
focus: true
}
//! [1]
diff --git a/doc/src/tutorials/declarative.qdoc b/doc/src/tutorials/declarative.qdoc
index 7780988..48beabd 100644
--- a/doc/src/tutorials/declarative.qdoc
+++ b/doc/src/tutorials/declarative.qdoc
@@ -392,7 +392,7 @@
the contact field.
There are also two other ways to reuse components in QML. A component
- can be reused from within the same QML file using Component and ComponentInstance
+ can be reused from within the same QML file using Component and Loader
elements. The next code snippet produces three red rounded rectangles
within a large blue rectangle.
diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc
index 354050d..c137d6a 100644
--- a/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -230,9 +230,11 @@
\o \c{QPushButton[flat="false"]}
\o Matches instances of QPushButton that are not
\l{QPushButton::}{flat}. You may use this selector to test
- for any Qt property specified using Q_PROPERTY(). In
- addition, the special \c class property is supported, for
- the name of the class.
+ for any Qt \l{Qt's Property System}{property} that supports
+ QVariant::toString() (see the \l{QVariant::}{toString()}
+ function documentation for details). In addition, the
+ special \c class property is supported, for the name of the
+ class.
This selector may also be used to test dynamic properties.
For more information on customization using dynamic properties,
diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml
index 2768150..7db1c80 100644
--- a/examples/declarative/aspectratio/face_fit_animated.qml
+++ b/examples/declarative/aspectratio/face_fit_animated.qml
@@ -16,7 +16,7 @@ Rectangle {
source: "pics/face.png"
x: (parent.width-width*scale)/2
y: (parent.height-height*scale)/2
- scale: Follow {
+ scale: SpringFollow {
source: Math.max(Math.min(Image.parent.width/Image.width*1.333,Image.parent.height/Image.height),
Math.min(Image.parent.width/Image.width,Image.parent.height/Image.height*1.333))
spring: 1
diff --git a/examples/declarative/clock/Clock.qml b/examples/declarative/clock/Clock.qml
index e152be3..6064dd4 100644
--- a/examples/declarative/clock/Clock.qml
+++ b/examples/declarative/clock/Clock.qml
@@ -28,7 +28,7 @@ Item {
id: HourRotation
origin.x: 4; origin.y: 45
angle: 0
- angle: Follow {
+ angle: SpringFollow {
spring: 2
damping: .2
source: Clock.hours * 50 * 3 + Clock.minutes / 2
@@ -44,7 +44,7 @@ Item {
id: MinuteRotation
origin.x: 4; origin.y: 70
angle: 0
- angle: Follow {
+ angle: SpringFollow {
spring: 2
damping: .2
source: Clock.minutes * 6
@@ -60,7 +60,7 @@ Item {
id: SecondRotation
origin.x: 2; origin.y: 60
angle: 0
- angle: Follow {
+ angle: SpringFollow {
spring: 5
damping: .25
modulus: 360
diff --git a/examples/declarative/dial/DialLibrary/Dial.qml b/examples/declarative/dial/DialLibrary/Dial.qml
index f53b25e..1a163a8 100644
--- a/examples/declarative/dial/DialLibrary/Dial.qml
+++ b/examples/declarative/dial/DialLibrary/Dial.qml
@@ -26,8 +26,8 @@ Item {
id: NeedleRotation
origin.x: 7; origin.y: 65
angle: -130
- angle: Follow {
-id: MyFollow
+ angle: SpringFollow {
+ id: MyFollow
spring: 1.4
damping: .15
source: Math.min(Math.max(-130, Root.value*2.2 - 130), 133)
diff --git a/examples/declarative/extending/adding/example.qml b/examples/declarative/extending/adding/example.qml
index ba7af7a..c608f94 100644
--- a/examples/declarative/extending/adding/example.qml
+++ b/examples/declarative/extending/adding/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
// ![0]
Person {
diff --git a/examples/declarative/extending/attached/example.qml b/examples/declarative/extending/attached/example.qml
index 20233f6..952eb93 100644
--- a/examples/declarative/extending/attached/example.qml
+++ b/examples/declarative/extending/attached/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
BirthdayParty {
celebrant: Boy {
diff --git a/examples/declarative/extending/binding/example.qml b/examples/declarative/extending/binding/example.qml
index cedb8bd..1651b7a 100644
--- a/examples/declarative/extending/binding/example.qml
+++ b/examples/declarative/extending/binding/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
// ![0]
BirthdayParty {
diff --git a/examples/declarative/extending/coercion/example.qml b/examples/declarative/extending/coercion/example.qml
index 5090782..64d26b0 100644
--- a/examples/declarative/extending/coercion/example.qml
+++ b/examples/declarative/extending/coercion/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
// ![0]
BirthdayParty {
diff --git a/examples/declarative/extending/default/example.qml b/examples/declarative/extending/default/example.qml
index 5fe693a..58035f9 100644
--- a/examples/declarative/extending/default/example.qml
+++ b/examples/declarative/extending/default/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
// ![0]
BirthdayParty {
diff --git a/examples/declarative/extending/extended/example.qml b/examples/declarative/extending/extended/example.qml
index a276211..985ce20 100644
--- a/examples/declarative/extending/extended/example.qml
+++ b/examples/declarative/extending/extended/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
// ![0]
QLineEdit {
diff --git a/examples/declarative/extending/extended/lineedit.cpp b/examples/declarative/extending/extended/lineedit.cpp
index fe4fdc3..f11d22e 100644
--- a/examples/declarative/extending/extended/lineedit.cpp
+++ b/examples/declarative/extending/extended/lineedit.cpp
@@ -63,4 +63,4 @@ int LineEditExtension::setBottomMargin(int m)
}
QML_DECLARE_TYPE(QLineEdit);
-QML_DEFINE_EXTENDED_TYPE(QLineEdit, QLineEdit, LineEditExtension);
+QML_DEFINE_EXTENDED_TYPE(People, 1, 0, 0, QLineEdit, QLineEdit, LineEditExtension);
diff --git a/examples/declarative/extending/grouped/example.qml b/examples/declarative/extending/grouped/example.qml
index 1be7abe..55912ed 100644
--- a/examples/declarative/extending/grouped/example.qml
+++ b/examples/declarative/extending/grouped/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
// ![0]
BirthdayParty {
diff --git a/examples/declarative/extending/properties/example.qml b/examples/declarative/extending/properties/example.qml
index 326105a..9594a84 100644
--- a/examples/declarative/extending/properties/example.qml
+++ b/examples/declarative/extending/properties/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
// ![0]
BirthdayParty {
diff --git a/examples/declarative/extending/signal/example.qml b/examples/declarative/extending/signal/example.qml
index 1cbaab4..e46bf32 100644
--- a/examples/declarative/extending/signal/example.qml
+++ b/examples/declarative/extending/signal/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
// ![0]
BirthdayParty {
diff --git a/examples/declarative/extending/valuesource/example.qml b/examples/declarative/extending/valuesource/example.qml
index aba2796..6d47350 100644
--- a/examples/declarative/extending/valuesource/example.qml
+++ b/examples/declarative/extending/valuesource/example.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import People 1.0
// ![0]
BirthdayParty {
diff --git a/examples/declarative/focusscope/test3.qml b/examples/declarative/focusscope/test3.qml
index 51fa35a..8a53c3a 100644
--- a/examples/declarative/focusscope/test3.qml
+++ b/examples/declarative/focusscope/test3.qml
@@ -39,7 +39,9 @@ Rectangle {
focus: true
model: Model
delegate: VerticalDelegate
- currentItemPositioning: "SnapAuto"
+ preferredHighlightBegin: 100
+ preferredHighlightEnd: 101
+ strictlyEnforceHighlightRange: true
}
diff --git a/examples/declarative/follow/follow.qml b/examples/declarative/follow/follow.qml
index 37dc2e8..1f585e2 100644
--- a/examples/declarative/follow/follow.qml
+++ b/examples/declarative/follow/follow.qml
@@ -26,7 +26,7 @@ Rectangle {
color: "#ff0000"
x: Rect.width; width: Rect.width; height: 20
y: 200
- y: Follow { source: Rect.y; velocity: 200 }
+ y: SpringFollow { source: Rect.y; velocity: 200 }
}
Text { x: Rect.width; y: 220; text: "Velocity" }
@@ -35,13 +35,13 @@ Rectangle {
color: "#ff0000"
x: Rect.width * 2; width: Rect.width/2; height: 20
y: 200
- y: Follow { source: Rect.y; spring: 1.0; damping: 0.2 }
+ y: SpringFollow { source: Rect.y; spring: 1.0; damping: 0.2 }
}
Rectangle {
color: "#880000"
x: Rect.width * 2.5; width: Rect.width/2; height: 20
y: 200
- y: Follow { source: Rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
+ y: SpringFollow { source: Rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
}
Text { x: Rect.width * 2; y: 220; text: "Spring" }
@@ -54,8 +54,8 @@ Rectangle {
width: 20; height: 20
radius: 10
color: "#0000ff"
- x: Follow { id: "F1"; source: Mouse.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
- y: Follow { id: "F2"; source: Mouse.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ x: SpringFollow { id: "F1"; source: Mouse.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ y: SpringFollow { id: "F2"; source: Mouse.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
states: [
State {
name: "following"
diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml
index 0314bb8..b51c0d0 100644
--- a/examples/declarative/follow/pong.qml
+++ b/examples/declarative/follow/pong.qml
@@ -25,7 +25,7 @@ Rectangle {
}
// Make y follow the target y coordinate, with a velocity of 200
- y: Follow { source: Ball.targetY; velocity: 200 }
+ y: SpringFollow { source: Ball.targetY; velocity: 200 }
// Detect the ball hitting the top or bottom of the view and bounce it
onYChanged: {
@@ -42,7 +42,7 @@ Rectangle {
id: LeftBat
color: "#00ee00"
x: 2; width: 20; height: 90
- y: Follow {
+ y: SpringFollow {
source: Ball.y-45; velocity: 300
enabled: Ball.direction == 'left'
}
@@ -51,7 +51,7 @@ Rectangle {
id: RightBat
color: "#00ee00"
x: Page.width-22; width: 20; height: 90
- y: Follow {
+ y: SpringFollow {
source: Ball.y-45; velocity: 300
enabled: Ball.direction == 'right'
}
diff --git a/examples/declarative/listview/content/ClickAutoRepeating.qml b/examples/declarative/listview/content/ClickAutoRepeating.qml
new file mode 100644
index 0000000..19dd6f6
--- /dev/null
+++ b/examples/declarative/listview/content/ClickAutoRepeating.qml
@@ -0,0 +1,29 @@
+import Qt 4.6
+
+Item {
+ id: Page
+ property int repeatdelay: 300
+ property int repeatperiod: 75
+ property bool pressed: false
+ signal pressed
+ signal released
+ signal clicked
+ pressed: SequentialAnimation {
+ id: AutoRepeat
+ PropertyAction { target: Page; property: "pressed"; value: true }
+ ScriptAction { script: Page.onPressed }
+ ScriptAction { script: Page.onClicked }
+ PauseAnimation { duration: repeatdelay }
+ SequentialAnimation {
+ repeat: true
+ ScriptAction { script: Page.onClicked }
+ PauseAnimation { duration: repeatperiod }
+ }
+ }
+ MouseRegion {
+ id: MR
+ anchors.fill: parent
+ onPressed: AutoRepeat.start()
+ onReleased: { AutoRepeat.stop(); parent.pressed = false; Page.released }
+ }
+}
diff --git a/examples/declarative/listview/content/pics/add.png b/examples/declarative/listview/content/pics/add.png
new file mode 100644
index 0000000..f29d84b
--- /dev/null
+++ b/examples/declarative/listview/content/pics/add.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/del.png b/examples/declarative/listview/content/pics/del.png
new file mode 100644
index 0000000..1d753a3
--- /dev/null
+++ b/examples/declarative/listview/content/pics/del.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/trash.png b/examples/declarative/listview/content/pics/trash.png
new file mode 100644
index 0000000..2042595
--- /dev/null
+++ b/examples/declarative/listview/content/pics/trash.png
Binary files differ
diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml
new file mode 100644
index 0000000..52c3c0b
--- /dev/null
+++ b/examples/declarative/listview/dynamic.qml
@@ -0,0 +1,142 @@
+import Qt 4.6
+import "content"
+
+Item {
+ width: 320
+ height: 500
+
+ ListModel {
+ id: FruitModel
+ ListElement {
+ name: "Apple"
+ cost: 2.45
+ attributes: [
+ ListElement { description: "Core" },
+ ListElement { description: "Deciduous" }
+ ]
+ }
+ ListElement {
+ name: "Banana"
+ cost: 1.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Seedless" }
+ ]
+ }
+ ListElement {
+ name: "Cumquat"
+ cost: 3.25
+ types: [ "Small", "Smaller" ]
+ attributes: [
+ ListElement { description: "Citrus" }
+ ]
+ }
+ ListElement {
+ name: "Durian"
+ cost: 9.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Smelly" }
+ ]
+ }
+ ListElement {
+ name: "Elderberry"
+ cost: 0.05
+ attributes: [
+ ListElement { description: "Berry" }
+ ]
+ }
+ ListElement {
+ name: "Fig"
+ cost: 0.25
+ attributes: [
+ ListElement { description: "Flower" }
+ ]
+ }
+ }
+
+ Component {
+ id: FruitDelegate
+ Item {
+ width: parent.width; height: 55
+ Text { id: Label; font.pixelSize: 24; text: name; elide: "ElideRight"; anchors.right: Cost.left; anchors.left:parent.left }
+ Text { id: Cost; font.pixelSize: 24; text: '$'+Number(cost).toFixed(2); anchors.right: ItemButtons.left }
+ Row {
+ anchors.top: Label.bottom
+ spacing: 5
+ Repeater {
+ model: attributes
+ Component {
+ Text { text: description }
+ }
+ }
+ }
+ Row {
+ id: ItemButtons
+ anchors.right: parent.right
+ width: childrenRect.width
+ Image { source: "content/pics/add.png"
+ ClickAutoRepeating { id: ClickUp; anchors.fill: parent; onClicked: FruitModel.set(index,"cost",Number(cost)+0.25) }
+ scale: ClickUp.pressed ? 0.9 : 1
+ }
+ Image { source: "content/pics/del.png"
+ ClickAutoRepeating { id: ClickDown; anchors.fill: parent; onClicked: FruitModel.set(index,"cost",Math.max(0,Number(cost)-0.25)) }
+ scale: ClickDown.pressed ? 0.9 : 1
+ }
+ Image { source: "content/pics/trash.png"
+ MouseRegion { anchors.fill: parent; onClicked: FruitModel.remove(index) }
+ }
+ Column {
+ width: childrenRect.width
+ Image { source: "content/pics/moreUp.png"
+ MouseRegion { anchors.fill: parent; onClicked: FruitModel.move(index,index-1,1) }
+ }
+ Image { source: "content/pics/moreDown.png"
+ MouseRegion { anchors.fill: parent; onClicked: FruitModel.move(index,index+1,1) }
+ }
+ }
+ }
+ }
+ }
+
+ ListView {
+ model: FruitModel
+ delegate: FruitDelegate
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: Buttons.top
+ }
+
+ Row {
+ width: childrenRect.width
+ height: childrenRect.height
+ anchors.bottom: parent.bottom
+ id: Buttons
+ Image { source: "content/pics/add.png"
+ MouseRegion { anchors.fill: parent;
+ onClicked: {
+ FruitModel.append({
+ "name":"Pizza Margarita",
+ "cost":5.95,
+ "attributes":[{"description": "Cheese"},{"description": "Tomato"}]
+ })
+ }
+ }
+ }
+ Image { source: "content/pics/add.png"
+ MouseRegion { anchors.fill: parent;
+ onClicked: {
+ FruitModel.insert(0,{
+ "name":"Pizza Supreme",
+ "cost":9.95,
+ "attributes":[{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}]
+ })
+ }
+ }
+ }
+ Image { source: "content/pics/trash.png"
+ MouseRegion { anchors.fill: parent; onClicked: FruitModel.clear() }
+ }
+ }
+}
diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml
index 2bf3a9f..cb92ad9 100644
--- a/examples/declarative/listview/highlight.qml
+++ b/examples/declarative/listview/highlight.qml
@@ -44,7 +44,7 @@ Rectangle {
id: PetHighlight
Rectangle {
width: 200; height: 50; color: "#FFFF88"
- y: Follow { source: List1.current.y; spring: 3; damping: 0.1 }
+ y: SpringFollow { source: List1.currentItem.y; spring: 3; damping: 0.1 }
}
}
ListView {
diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml
index 061fab3..01781ec 100644
--- a/examples/declarative/listview/itemlist.qml
+++ b/examples/declarative/listview/itemlist.qml
@@ -29,7 +29,9 @@ Rectangle {
anchors.fill: parent
anchors.bottomMargin: 30
model: ItemModel
- currentItemPositioning: "SnapAuto"
+ preferredHighlightBegin: 0
+ preferredHighlightEnd: 1
+ strictlyEnforceHighlightRange: true
orientation: "Horizontal"
}
diff --git a/examples/declarative/listview/listview.qml b/examples/declarative/listview/listview.qml
index 1cca5ad..ac1cef1 100644
--- a/examples/declarative/listview/listview.qml
+++ b/examples/declarative/listview/listview.qml
@@ -29,21 +29,24 @@ Rectangle {
Rectangle { color: "#FFFF88" }
}
- // Show the model in three lists, with different currentItemPositioning.
- // currentItemPositioning determines how the list behaves when the
- // current item changes. Note that the second and third ListView
+ // Show the model in three lists, with different highlight ranges.
+ // preferredHighlightBegin and preferredHighlightEnd set the
+ // range in which to attempt to maintain the highlight.
+ // Note that the second and third ListView
// set their currentIndex to be the same as the first, and that
// the first ListView is given keyboard focus.
- // The default mode, Free, allows the currentItem to move freely
+ // The default mode allows the currentItem to move freely
// within the visible area. If it would move outside the visible
// area, the view is scrolled to keep it visible.
- // Snap currentItemPositioning attempts to keep the current item
- // aligned with the snapPosition by scrolling the view, however the
- // items will not scroll beyond the beginning or end of the view.
- // SnapAuto currentItemPositioning always keeps the current item on
- // the snapPosition by scrolling the view. It also automatically
- // sets the current item as is scrolled with the mouse. Note
- // that the first ListView sets its currentIndex to be equal to
+ // The second list sets a highlight range which attempts to keep the
+ // current item within the the bounds of the range, however
+ // items will not scroll beyond the beginning or end of the view,
+ // forcing the highlight to move outside the range at the ends.
+ // The third list sets strictlyEnforceHighlightRange to true
+ // and sets a range smaller than the height of an item. This
+ // forces the current item to change when the view is flicked,
+ // since the highlight is unable to move.
+ // Note that the first ListView sets its currentIndex to be equal to
// the third ListView's currentIndex. By flicking List3 with
// the mouse, the current index of List1 will be changed.
ListView {
@@ -57,23 +60,17 @@ Rectangle {
id: List2
x: 200; width: 200; height: parent.height
model: MyPetsModel; delegate: PetDelegate; highlight: PetHighlight
- currentItemPositioning: "Snap"; snapPosition: 125
+ preferredHighlightBegin: 80
+ preferredHighlightEnd: 220
currentIndex: List1.currentIndex
}
ListView {
id: List3
x: 400; width: 200; height: parent.height
- model: MyPetsModel; delegate: PetDelegate
- currentItemPositioning: "SnapAuto"; snapPosition: 125
+ model: MyPetsModel; delegate: PetDelegate; highlight: PetHighlight
currentIndex: List1.currentIndex
-
- // Position a static highlight rather than a normal highlight so that
- // when the view is flicked, the highlight does not move.
- // By positioning the highlight at the same position as the snapPosition
- // the item under the highlight will always be the current item.
- Rectangle {
- y: 125; width: 200; height: 50
- color: "#FFFF88"; z: -1
- }
+ preferredHighlightBegin: 125
+ preferredHighlightEnd: 126
+ strictlyEnforceHighlightRange: true
}
}
diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml
index 196cdc5..6711de4 100644
--- a/examples/declarative/loader/Browser.qml
+++ b/examples/declarative/loader/Browser.qml
@@ -82,7 +82,7 @@ Rectangle {
focus: true
Keys.onPressed: {
if (event.key == Qt.Key_Return || event.key == Qt.Key_Select) {
- View.current.launch();
+ View.currentItem.launch();
event.accepted = true;
}
}
diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml
index b6781c3..2241c3f 100644
--- a/examples/declarative/snow/snow.qml
+++ b/examples/declarative/snow/snow.qml
@@ -30,15 +30,15 @@ Rectangle {
property bool slowDeform: true
property real deform: 0
- deform: Follow {
+ deform: SpringFollow {
id: "DeformFollow"; source: MyLayout.targetDeform; velocity: MyLayout.slowDeform?0.1:2
onSyncChanged: if(inSync) { MyLayout.slowDeform = true; MyLayout.targetDeform = 0; }
}
ImageBatch { offset: 0; ref: ImagePanel }
- x: Follow { source: MyLayout.targetX; velocity: 1000 }
- y: Follow { source: -(selectedY + imageHeight / 2); velocity: 500 }
+ x: SpringFollow { source: MyLayout.targetX; velocity: 1000 }
+ y: SpringFollow { source: -(selectedY + imageHeight / 2); velocity: 500 }
}
transform: Rotation {
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml b/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml
index ec115fe..7bcdf50 100644
--- a/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml
+++ b/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml
@@ -16,18 +16,18 @@ Rectangle {
}
}
]
- ComponentInstance {
- component: redRectangle
+ Loader {
+ sourceComponent: redRectangle
anchors.right: parent.right
anchors.top: parent.top
}
- ComponentInstance {
- component: redRectangle
+ Loader {
+ sourceComponent: redRectangle
anchors.left: parent.left
anchors.top: parent.top
}
- ComponentInstance {
- component: redRectangle
+ Loader {
+ sourceComponent: redRectangle
anchors.left: parent.left
anchors.bottom: parent.bottom
}
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index 06d0bd4..4001a3e 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -31,7 +31,7 @@ Rectangle {
x: Math.random() * 200 + 100
y: Math.random() * 300 + 50
id: StickyPage
- rotation: Follow {
+ rotation: SpringFollow {
source: -Flick.horizontalVelocity / 100
spring: 2.0
damping: 0.1
diff --git a/examples/declarative/webview/newwindows.qml b/examples/declarative/webview/newwindows.qml
index 9ff902e2..57cbf4e 100644
--- a/examples/declarative/webview/newwindows.qml
+++ b/examples/declarative/webview/newwindows.qml
@@ -24,5 +24,5 @@ Row {
}
]
width: 500
- ComponentInstance { component: WebViewPage }
+ Loader { sourceComponent: WebViewPage }
}
diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml
index 6395284..7ebc2b2 100644
--- a/examples/declarative/xmldata/yahoonews.qml
+++ b/examples/declarative/xmldata/yahoonews.qml
@@ -101,6 +101,5 @@ Rectangle {
clip: true
model: feedModel
delegate: feedDelegate
- currentItemPositioning: "Snap"
}
}
diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro
index 567eb7b..b86e0ba 100644
--- a/examples/opengl/opengl.pro
+++ b/examples/opengl/opengl.pro
@@ -5,6 +5,9 @@ contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONF
SUBDIRS = hellogl_es2
} else {
SUBDIRS = hellogl_es
+ !contains(QT_CONFIG, opengles1cl) {
+ SUBDIRS += textures
+ }
}
} else {
SUBDIRS = 2dpainting \
diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp
index cfb99b0..9c6d5ea 100644
--- a/examples/opengl/textures/glwidget.cpp
+++ b/examples/opengl/textures/glwidget.cpp
@@ -42,12 +42,17 @@
#include <QtGui>
#include <QtOpenGL>
-#include <math.h>
-
#include "glwidget.h"
-GLuint GLWidget::sharedObject = 0;
-int GLWidget::refCount = 0;
+class CubeObject
+{
+public:
+ GLuint textures[6];
+ QVector<QVector3D> vertices;
+ QVector<QVector2D> texCoords;
+
+ void draw();
+};
GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget)
: QGLWidget(parent, shareWidget)
@@ -56,14 +61,12 @@ GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget)
xRot = 0;
yRot = 0;
zRot = 0;
+ cube = 0;
}
GLWidget::~GLWidget()
{
- if (--refCount == 0) {
- makeCurrent();
- glDeleteLists(sharedObject, 1);
- }
+ delete cube;
}
QSize GLWidget::minimumSizeHint() const
@@ -92,9 +95,7 @@ void GLWidget::setClearColor(const QColor &color)
void GLWidget::initializeGL()
{
- if (!sharedObject)
- sharedObject = makeObject();
- ++refCount;
+ makeObject();
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
@@ -106,11 +107,11 @@ void GLWidget::paintGL()
qglClearColor(clearColor);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
- glTranslated(0.0, 0.0, -10.0);
- glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
- glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
- glRotated(zRot / 16.0, 0.0, 0.0, 1.0);
- glCallList(sharedObject);
+ glTranslatef(0.0f, 0.0f, -10.0f);
+ glRotatef(xRot / 16.0f, 1.0f, 0.0f, 0.0f);
+ glRotatef(yRot / 16.0f, 0.0f, 1.0f, 0.0f);
+ glRotatef(zRot / 16.0f, 0.0f, 0.0f, 1.0f);
+ cube->draw();
}
void GLWidget::resizeGL(int width, int height)
@@ -120,7 +121,11 @@ void GLWidget::resizeGL(int width, int height)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
+#ifndef QT_OPENGL_ES
glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
+#else
+ glOrthof(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
+#endif
glMatrixMode(GL_MODELVIEW);
}
@@ -147,7 +152,7 @@ void GLWidget::mouseReleaseEvent(QMouseEvent * /* event */)
emit clicked();
}
-GLuint GLWidget::makeObject()
+void GLWidget::makeObject()
{
static const int coords[6][4][3] = {
{ { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } },
@@ -158,25 +163,32 @@ GLuint GLWidget::makeObject()
{ { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } }
};
+ cube = new CubeObject();
- GLuint textures[6];
- for (int j=0; j < 6; ++j)
- textures[j] = bindTexture(QPixmap(QString(":/images/side%1.png").arg(j + 1)),
- GL_TEXTURE_2D);
+ for (int j=0; j < 6; ++j) {
+ cube->textures[j] = bindTexture
+ (QPixmap(QString(":/images/side%1.png").arg(j + 1)), GL_TEXTURE_2D);
+ }
- GLuint list = glGenLists(1);
- glNewList(list, GL_COMPILE);
for (int i = 0; i < 6; ++i) {
- glBindTexture(GL_TEXTURE_2D, textures[i]);
- glBegin(GL_QUADS);
for (int j = 0; j < 4; ++j) {
- glTexCoord2d(j == 0 || j == 3, j == 0 || j == 1);
- glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1],
- 0.2 * coords[i][j][2]);
+ cube->texCoords.append
+ (QVector2D(j == 0 || j == 3, j == 0 || j == 1));
+ cube->vertices.append
+ (QVector3D(0.2 * coords[i][j][0], 0.2 * coords[i][j][1],
+ 0.2 * coords[i][j][2]));
}
- glEnd();
}
+}
- glEndList();
- return list;
+void CubeObject::draw()
+{
+ glVertexPointer(3, GL_FLOAT, 0, vertices.constData());
+ glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData());
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ for (int i = 0; i < 6; ++i) {
+ glBindTexture(GL_TEXTURE_2D, textures[i]);
+ glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4);
+ }
}
diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h
index 68be8bc..f793d6d 100644
--- a/examples/opengl/textures/glwidget.h
+++ b/examples/opengl/textures/glwidget.h
@@ -44,6 +44,8 @@
#include <QGLWidget>
+class CubeObject;
+
class GLWidget : public QGLWidget
{
Q_OBJECT
@@ -69,16 +71,14 @@ protected:
void mouseReleaseEvent(QMouseEvent *event);
private:
- GLuint makeObject();
+ void makeObject();
QColor clearColor;
QPoint lastPos;
int xRot;
int yRot;
int zRot;
-
- static GLuint sharedObject;
- static int refCount;
+ CubeObject *cube;
};
#endif
diff --git a/examples/opengl/textures/window.cpp b/examples/opengl/textures/window.cpp
index ea64512..9bd7931 100644
--- a/examples/opengl/textures/window.cpp
+++ b/examples/opengl/textures/window.cpp
@@ -48,8 +48,6 @@ Window::Window()
{
QGridLayout *mainLayout = new QGridLayout;
- glWidgets[0][0] = 0;
-
for (int i = 0; i < NumRows; ++i) {
for (int j = 0; j < NumColumns; ++j) {
QColor clearColor;
@@ -57,7 +55,7 @@ Window::Window()
/ (NumRows * NumColumns - 1),
255, 63);
- glWidgets[i][j] = new GLWidget(0, glWidgets[0][0]);
+ glWidgets[i][j] = new GLWidget(0, 0);
glWidgets[i][j]->setClearColor(clearColor);
glWidgets[i][j]->rotateBy(+42 * 16, +42 * 16, -21 * 16);
mainLayout->addWidget(glWidgets[i][j], i, j);
diff --git a/mkspecs/common/wince.conf b/mkspecs/common/wince/qmake.conf
index d6e4ba7..d6e4ba7 100644
--- a/mkspecs/common/wince.conf
+++ b/mkspecs/common/wince/qmake.conf
diff --git a/mkspecs/common/wince/qplatformdefs.h b/mkspecs/common/wince/qplatformdefs.h
new file mode 100644
index 0000000..4e67948
--- /dev/null
+++ b/mkspecs/common/wince/qplatformdefs.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake spec of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMDEFS_H
+#define QPLATFORMDEFS_H
+
+#ifdef UNICODE
+#ifndef _UNICODE
+#define _UNICODE
+#endif
+#endif
+
+// Get Qt defines/settings
+
+#include "qglobal.h"
+#include "qfunctions_wince.h"
+
+#define _POSIX_
+#include <limits.h>
+#undef _POSIX_
+
+#include <tchar.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+
+#define Q_FS_FAT
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_STATBUF struct _stati64 // non-ANSI defs
+#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
+#define QT_STAT ::_stati64
+#define QT_FSTAT ::_fstati64
+#else
+#define QT_STATBUF struct stat // non-ANSI defs
+#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
+#define QT_STAT ::qt_wince_stat
+#define QT_FSTAT ::qt_wince__fstat
+#endif
+#define QT_STAT_REG _S_IFREG
+#define QT_STAT_DIR _S_IFDIR
+#define QT_STAT_MASK _S_IFMT
+#if defined(_S_IFLNK)
+# define QT_STAT_LNK _S_IFLNK
+#endif
+#define QT_FILENO ::qt_wince___fileno
+#define QT_OPEN ::qt_wince_open
+#define QT_CLOSE ::qt_wince__close
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_LSEEK ::_lseeki64
+#define QT_TSTAT ::_tstati64
+#else
+#define QT_LSEEK ::qt_wince__lseek
+#define QT_TSTAT ::_tstat
+#endif
+#define QT_READ ::qt_wince__read
+#define QT_WRITE ::qt_wince__write
+#define QT_ACCESS ::qt_wince__access
+#define QT_GETCWD ::_getcwd
+#define QT_CHDIR ::_chdir
+#define QT_MKDIR ::qt_wince__mkdir
+#define QT_RMDIR ::qt_wince__rmdir
+#define QT_OPEN_RDONLY _O_RDONLY
+#define QT_OPEN_WRONLY _O_WRONLY
+#define QT_OPEN_RDWR _O_RDWR
+#define QT_OPEN_CREAT _O_CREAT
+#define QT_OPEN_TRUNC _O_TRUNC
+#define QT_OPEN_APPEND _O_APPEND
+# define QT_OPEN_TEXT _O_TEXT
+# define QT_OPEN_BINARY _O_BINARY
+
+#define QT_FOPEN ::fopen
+#define QT_FSEEK ::fseek
+#define QT_FTELL ::ftell
+#define QT_FGETPOS ::fgetpos
+#define QT_FSETPOS ::fsetpos
+#define QT_FPOS_T fpos_t
+#define QT_OFF_T long
+
+#define QT_SIGNAL_ARGS int
+
+#define QT_VSNPRINTF(buffer, count, format, arg) \
+ _vsnprintf(buffer, count, format, arg)
+
+#define QT_SNPRINTF ::_snprintf
+
+# define F_OK 0
+# define X_OK 1
+# define W_OK 2
+# define R_OK 4
+
+typedef int mode_t;
+
+#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf b/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf
index 45ebcf7..28ca6a6 100644
--- a/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf
+++ b/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf
@@ -3,7 +3,7 @@
#
# Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (ARMV4I)
#
-include(../common/wince.conf)
+include(../common/wince/qmake.conf)
CE_SDK = STANDARDSDK_500
CE_ARCH = ARMV4I
diff --git a/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h
+++ b/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h
index f775941..cda4ff4 100644
--- a/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h
+++ b/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wince50standard-armv4i-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf b/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf
index 7d765de..0cc1ab0 100644
--- a/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf
+++ b/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf
@@ -3,7 +3,7 @@
#
# Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (MIPSII)
#
-include(../common/wince.conf)
+include(../common/wince/qmake.conf)
CE_SDK = STANDARDSDK_500
CE_ARCH = MIPSII
diff --git a/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h
+++ b/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h
index 319d49a..cda4ff4 100644
--- a/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h
+++ b/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wince50standard-mipsii-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf b/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf
index 4750d88..a22505c 100644
--- a/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf
+++ b/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf
@@ -3,7 +3,7 @@
#
# Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (MIPSIV)
#
-include(../common/wince.conf)
+include(../common/wince/qmake.conf)
CE_SDK = STANDARDSDK_500
CE_ARCH = MIPSIV
diff --git a/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h
+++ b/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h
index 9a6f3ed..cda4ff4 100644
--- a/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h
+++ b/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wince50standard-mipsiv-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/mkspecs/wince50standard-sh4-msvc2005/qmake.conf b/mkspecs/wince50standard-sh4-msvc2005/qmake.conf
index aa420f2..1ee8950 100644
--- a/mkspecs/wince50standard-sh4-msvc2005/qmake.conf
+++ b/mkspecs/wince50standard-sh4-msvc2005/qmake.conf
@@ -3,7 +3,7 @@
#
# Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (SH4)
#
-include(../common/wince.conf)
+include(../common/wince/qmake.conf)
CE_SDK = STANDARDSDK_500
CE_ARCH = SH4
diff --git a/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h
+++ b/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h
index 88ca7ab..cda4ff4 100644
--- a/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h
+++ b/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wince50standard-sh4-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/mkspecs/wince50standard-x86-msvc2005/qmake.conf b/mkspecs/wince50standard-x86-msvc2005/qmake.conf
index 13bcc9f..2fa7556 100644
--- a/mkspecs/wince50standard-x86-msvc2005/qmake.conf
+++ b/mkspecs/wince50standard-x86-msvc2005/qmake.conf
@@ -3,7 +3,7 @@
#
# Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (x86)
#
-include(../common/wince.conf)
+include(../common/wince/qmake.conf)
CE_SDK = STANDARDSDK_500
CE_ARCH = x86
diff --git a/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h
+++ b/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h
index 76dc923..cda4ff4 100644
--- a/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h
+++ b/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wince50standard-x86-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf b/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf
index 6386141..3bb18af 100644
--- a/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf
+++ b/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf
@@ -1,65 +1,20 @@
#
# qmake configuration for wince-msvc2005
#
-# Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 6.0 (ARMV4I)
+# Written for Microsoft VS 2005 for WindowsCE 6.0 (ARMV4I)
+# This is just a template for creating Windows CE 6 mkspecs.
#
-MAKEFILE_GENERATOR = MSVC.NET
-TEMPLATE = app
-CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe
-QT += core gui
-CE_SDK = STANDARDSDK_600
-CE_ARCH = ARMV4I
-
-DEFINES += UNDER_CE WINCE _WINDOWS _UNICODE UNICODE STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _ARMV4I_ armv4i _ARM_ ARM _M_ARM ARM _WIN32 __arm__ Q_OS_WINCE_STD QT_NO_PRINTER QT_NO_PRINTDIALOG
-
-QMAKE_COMPILER_DEFINES += _MSC_VER=1400
-
-QMAKE_CC = cl
-QMAKE_LEX = flex
-QMAKE_LEXFLAGS =
-QMAKE_YACC = byacc
-QMAKE_YACCFLAGS = -d
-QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- -QRarch4T -QRinterwork-return
-QMAKE_CFLAGS_WARN_ON = -W3
-QMAKE_CFLAGS_WARN_OFF = -W0
-QMAKE_CFLAGS_RELEASE = -O2 -GL -MD
-QMAKE_CFLAGS_DEBUG = -DDEBUG -D_DEBUG -Zi -MDd
-QMAKE_CFLAGS_YACC =
-
-QMAKE_CXX = $$QMAKE_CC
-QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
-QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189
-QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
-QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE
-QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG
-QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
-QMAKE_CXXFLAGS_STL_ON = -EHsc
-QMAKE_CXXFLAGS_STL_OFF =
-QMAKE_CXXFLAGS_RTTI_ON = -GR
-QMAKE_CXXFLAGS_RTTI_OFF =
-QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc
-QMAKE_CXXFLAGS_EXCEPTIONS_OFF =
+include(../common/wince/qmake.conf)
-QMAKE_INCDIR =
-QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS]
-QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS]
+CE_SDK = STANDARDSDK_600 # replace with actual SDK name
+CE_ARCH = ARMV4I
-QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src
-QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $<
-QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<<
-QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src
-QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $<
-QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<<
+DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _ARMV4I_ armv4i _ARM_ ARM _M_ARM ARM _WIN32 __arm__
-QMAKE_LINK = link
-QMAKE_LFLAGS = /NOLOGO /NODEFAULTLIB:OLDNAMES.LIB
-QMAKE_LFLAGS_RELEASE = /LTCG /INCREMENTAL:NO
-QMAKE_LFLAGS_DEBUG = /DEBUG
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /ENTRY:mainACRTStartup
QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB
QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /DLL /SAFESEH:NO
-QMAKE_LIBFLAGS = $$QMAKE_LFLAGS_WINDOWS
QMAKE_LIBFLAGS_RELEASE = /LTCG
QMAKE_LIBS = corelibc.lib coredll.lib
QMAKE_LIBS_CORE = libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib
@@ -68,27 +23,5 @@ QMAKE_LIBS_NETWORK = ws2.lib $$QMAKE_LIBS_GUI
QMAKE_LIBS_OPENGL =
QMAKE_LIBS_COMPAT =
-QMAKE_LIBS_QT_ENTRY = -lqtmain
-
-QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe
-QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe
-QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe
-
-QMAKE_IDL = midl
-QMAKE_LIB = lib
QMAKE_RC = rc /DUNDER_CE=600 /D_WIN32_WCE=0x600
-QMAKE_ZIP = zip -r -9
-
-QMAKE_COPY = copy /y
-QMAKE_COPY_DIR = xcopy /s /q /y /i
-QMAKE_MOVE = move
-QMAKE_DEL_FILE = del
-QMAKE_DEL_DIR = rmdir
-QMAKE_CHK_DIR_EXISTS = if not exist
-QMAKE_MKDIR = mkdir
-
-VCPROJ_EXTENSION = .vcproj
-VCSOLUTION_EXTENSION = .sln
-VCPROJ_KEYWORD = Qt4VSv1.0
-load(qt_config)
diff --git a/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h b/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h
+++ b/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wince60standard-x86-msvc2005/qmake.conf b/mkspecs/wince60standard-x86-msvc2005/qmake.conf
new file mode 100644
index 0000000..2896c69
--- /dev/null
+++ b/mkspecs/wince60standard-x86-msvc2005/qmake.conf
@@ -0,0 +1,27 @@
+#
+# qmake configuration for wince-msvc2005
+#
+# Written for Microsoft VS 2005 for WindowsCE 6.0 (x86)
+# This is just a template for creating Windows CE 6 mkspecs.
+#
+
+include(../common/wince/qmake.conf)
+
+CE_SDK = STANDARDSDK_600 # replace with actual SDK name
+CE_ARCH = x86
+
+DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _X86_ _M_IX86
+
+QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 /ENTRY:mainACRTStartup
+QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86
+QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 /DLL /SAFESEH:NO
+QMAKE_LIBFLAGS_RELEASE = /LTCG
+QMAKE_LIBS = corelibc.lib coredll.lib
+QMAKE_LIBS_CORE = corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib
+QMAKE_LIBS_GUI = ceshell.lib ole32.lib $$QMAKE_LIBS_CORE
+QMAKE_LIBS_NETWORK = ws2.lib $$QMAKE_LIBS_GUI
+QMAKE_LIBS_OPENGL =
+QMAKE_LIBS_COMPAT =
+
+QMAKE_RC = rc /DUNDER_CE=600 /D_WIN32_WCE=0x600
+
diff --git a/mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h b/mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h
new file mode 100644
index 0000000..cda4ff4
--- /dev/null
+++ b/mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake spec of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../common/wince/qplatformdefs.h"
+
diff --git a/mkspecs/wincewm50pocket-msvc2005/qmake.conf b/mkspecs/wincewm50pocket-msvc2005/qmake.conf
index d75d86e..676be5a 100644
--- a/mkspecs/wincewm50pocket-msvc2005/qmake.conf
+++ b/mkspecs/wincewm50pocket-msvc2005/qmake.conf
@@ -3,7 +3,7 @@
#
# Written for Microsoft VC2005.NET with Windows Mobile 5.0 SDK for Pocket PC (ARMV4I)
#
-include(../common/wince.conf)
+include(../common/wince/qmake.conf)
CE_SDK = Windows Mobile 5.0 Pocket PC SDK
CE_ARCH = ARMV4I
diff --git a/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h b/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h
+++ b/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h b/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h
index f444562..cda4ff4 100644
--- a/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h
+++ b/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wincewm50pocket-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/mkspecs/wincewm50smart-msvc2005/qmake.conf b/mkspecs/wincewm50smart-msvc2005/qmake.conf
index 372b266..c0f09cc 100644
--- a/mkspecs/wincewm50smart-msvc2005/qmake.conf
+++ b/mkspecs/wincewm50smart-msvc2005/qmake.conf
@@ -3,7 +3,7 @@
#
# Written for Microsoft VC2005.NET with Windows Mobile 5.0 SDK for Smartphone (ARMV4I)
#
-include(../common/wince.conf)
+include(../common/wince/qmake.conf)
CE_SDK = Windows Mobile 5.0 Smartphone SDK
CE_ARCH = ARMV4I
diff --git a/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h b/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h
+++ b/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h b/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h
index 37c8f62..cda4ff4 100644
--- a/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h
+++ b/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wincewm50smart-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h b/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h
+++ b/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h b/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h
index a0737ae..cda4ff4 100644
--- a/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h
+++ b/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wincewm60professional-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h b/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h
index 4e67948..cda4ff4 100644
--- a/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h
+++ b/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h
@@ -39,93 +39,5 @@
**
****************************************************************************/
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
+#include "../common/wince/qplatformdefs.h"
-#ifdef UNICODE
-#ifndef _UNICODE
-#define _UNICODE
-#endif
-#endif
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-#include "qfunctions_wince.h"
-
-#define _POSIX_
-#include <limits.h>
-#undef _POSIX_
-
-#include <tchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-#define Q_FS_FAT
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_STATBUF struct _stati64 // non-ANSI defs
-#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
-#define QT_STAT ::_stati64
-#define QT_FSTAT ::_fstati64
-#else
-#define QT_STATBUF struct stat // non-ANSI defs
-#define QT_STATBUF4TSTAT struct stat // non-ANSI defs
-#define QT_STAT ::qt_wince_stat
-#define QT_FSTAT ::qt_wince__fstat
-#endif
-#define QT_STAT_REG _S_IFREG
-#define QT_STAT_DIR _S_IFDIR
-#define QT_STAT_MASK _S_IFMT
-#if defined(_S_IFLNK)
-# define QT_STAT_LNK _S_IFLNK
-#endif
-#define QT_FILENO ::qt_wince___fileno
-#define QT_OPEN ::qt_wince_open
-#define QT_CLOSE ::qt_wince__close
-#ifdef QT_LARGEFILE_SUPPORT
-#define QT_LSEEK ::_lseeki64
-#define QT_TSTAT ::_tstati64
-#else
-#define QT_LSEEK ::qt_wince__lseek
-#define QT_TSTAT ::_tstat
-#endif
-#define QT_READ ::qt_wince__read
-#define QT_WRITE ::qt_wince__write
-#define QT_ACCESS ::qt_wince__access
-#define QT_GETCWD ::_getcwd
-#define QT_CHDIR ::_chdir
-#define QT_MKDIR ::qt_wince__mkdir
-#define QT_RMDIR ::qt_wince__rmdir
-#define QT_OPEN_RDONLY _O_RDONLY
-#define QT_OPEN_WRONLY _O_WRONLY
-#define QT_OPEN_RDWR _O_RDWR
-#define QT_OPEN_CREAT _O_CREAT
-#define QT_OPEN_TRUNC _O_TRUNC
-#define QT_OPEN_APPEND _O_APPEND
-# define QT_OPEN_TEXT _O_TEXT
-# define QT_OPEN_BINARY _O_BINARY
-
-#define QT_FOPEN ::fopen
-#define QT_FSEEK ::fseek
-#define QT_FTELL ::ftell
-#define QT_FGETPOS ::fgetpos
-#define QT_FSETPOS ::fsetpos
-#define QT_FPOS_T fpos_t
-#define QT_OFF_T long
-
-#define QT_SIGNAL_ARGS int
-
-#define QT_VSNPRINTF(buffer, count, format, arg) \
- _vsnprintf(buffer, count, format, arg)
-
-#define QT_SNPRINTF ::_snprintf
-
-# define F_OK 0
-# define X_OK 1
-# define W_OK 2
-# define R_OK 4
-
-typedef int mode_t;
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h b/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h
index 819f150..cda4ff4 100644
--- a/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h
+++ b/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wincewm60standard-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h b/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h
index c3270e2..cda4ff4 100644
--- a/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h
+++ b/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h
@@ -39,4 +39,5 @@
**
****************************************************************************/
-#include "../wincewm60professional-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
+
diff --git a/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h b/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h
index 35219d0..cda4ff4 100644
--- a/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h
+++ b/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h
@@ -39,5 +39,5 @@
**
****************************************************************************/
-#include "../wincewm65professional-msvc2005/qplatformdefs.h"
+#include "../common/wince/qplatformdefs.h"
diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi
index 2d69c7d..5a75ab7 100644
--- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi
+++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi
@@ -323,7 +323,7 @@
'runtime/TimeoutChecker.cpp',
'runtime/TimeoutChecker.h',
'runtime/Tracing.h',
- 'runtime/TypeInfo.h',
+ 'runtime/JSTypeInfo.h',
'runtime/UString.cpp',
'runtime/UString.h',
'wrec/CharacterClass.cpp',
diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp
index 29a13ca..de5175e 100644
--- a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp
@@ -36,6 +36,9 @@ RegisterFile::~RegisterFile()
#if HAVE(MMAP)
munmap(reinterpret_cast<char*>(m_buffer), ((m_max - m_start) + m_maxGlobals) * sizeof(Register));
#elif HAVE(VIRTUALALLOC)
+#if PLATFORM(WINCE)
+ VirtualFree(m_buffer, DWORD(m_commitEnd) - DWORD(m_buffer), MEM_DECOMMIT);
+#endif
VirtualFree(m_buffer, 0, MEM_RELEASE);
#else
fastFree(m_buffer);
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/TypeInfo.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSTypeInfo.h
index 70aeed3..bea188b 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/TypeInfo.h
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSTypeInfo.h
@@ -24,8 +24,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef TypeInfo_h
-#define TypeInfo_h
+#ifndef JSTypeInfo_h
+#define JSTypeInfo_h
#include "JSType.h"
@@ -69,4 +69,4 @@ namespace JSC {
}
-#endif // TypeInfo_h
+#endif // JSTypeInfo_h
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h
index dcd4e50..ca4552b 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h
@@ -31,7 +31,7 @@
#include "JSValue.h"
#include "PropertyMapHashTable.h"
#include "StructureTransitionTable.h"
-#include "TypeInfo.h"
+#include "JSTypeInfo.h"
#include "UString.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index e1b8509..31f0841 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -157,6 +157,19 @@
#define DEFAULT_TIMER_INTERVAL 16
+#ifdef Q_WS_WIN
+ /// Fix for Qt 4.7
+ //on windows if you're currently dragging a widget an inner eventloop was started by the system
+ //to make sure that this timer is getting fired, we need to make sure to use the system timers
+ //that will send a WM_TIMER event. We do that by settings the timer interval to 11
+ //It is 11 because QEventDispatcherWin32Private::registerTimer specifically checks if the interval
+ //is greater than 10 to determine if it should use a system timer (or the multimedia timer).
+#define STARTSTOP_TIMER_DELAY 11
+#else
+#define STARTSTOP_TIMER_DELAY 0
+#endif
+
+
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
@@ -217,7 +230,7 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation)
if (animations.contains(animation) || animationsToStart.contains(animation))
return;
animationsToStart << animation;
- startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer
+ startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); // we delay the check if we should start/stop the global timer
}
void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation)
@@ -233,7 +246,7 @@ void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation)
} else {
animationsToStart.removeOne(animation);
}
- startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer
+ startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); // we delay the check if we should start/stop the global timer
}
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 8f34e30..93de911 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1655,7 +1655,8 @@ public:
FramebufferObject = 0x07, // GL framebuffer object
CustomRaster = 0x08,
MacQuartz = 0x09,
- PaintBuffer = 0x0a
+ PaintBuffer = 0x0a,
+ OpenGL = 0x0b
};
enum RelayoutType {
RelayoutNormal,
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 50b4af7..80ccda3 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -865,15 +865,22 @@ QString QFSFileEngine::fileName(FileName file) const
QString ret;
if (!isRelativePathSymbian(d->filePath)) {
if (d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':')
- && d->filePath.at(2) != slashChar || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt
- d->filePath.startsWith(slashChar) // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt
- ) {
- ret = QString(QDir::currentPath().left(2) + QDir::fromNativeSeparators(d->filePath));
+ && d->filePath.at(2) != slashChar){
+ // It's a drive-relative path, so C:a.txt -> C:/currentpath/a.txt,
+ // or if it's different drive than current, Z:a.txt -> Z:/a.txt
+ QString currentPath = QDir::currentPath();
+ if (0 == currentPath.left(1).compare(d->filePath.left(1), Qt::CaseInsensitive))
+ ret = currentPath + slashChar + d->filePath.mid(2);
+ else
+ ret = d->filePath.left(2) + slashChar + d->filePath.mid(2);
+ } else if (d->filePath.startsWith(slashChar)) {
+ // It's a absolute path to the current drive, so /a.txt -> C:/a.txt
+ ret = QDir::currentPath().left(2) + d->filePath;
} else {
ret = d->filePath;
}
} else {
- ret = QDir::cleanPath(QDir::currentPath() + slashChar + d->filePath);
+ ret = QDir::currentPath() + slashChar + d->filePath;
}
// The path should be absolute at this point.
@@ -889,6 +896,12 @@ QString QFSFileEngine::fileName(FileName file) const
ret[0] = ret.at(0).toUpper();
}
+ // Clean up the path
+ bool isDir = ret.endsWith(slashChar);
+ ret = QDir::cleanPath(ret);
+ if (isDir)
+ ret += slashChar;
+
if (file == AbsolutePathName) {
int slash = ret.lastIndexOf(slashChar);
if (slash < 0)
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index c2bdbee..f316fec 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -367,21 +367,26 @@ Q_INLINE_TEMPLATE void QList<T>::node_copy(Node *from, Node *to, Node *src)
if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
QT_TRY {
while(current != to) {
- (current++)->v = new T(*reinterpret_cast<T*>((src++)->v));
+ current->v = new T(*reinterpret_cast<T*>(src->v));
+ ++current;
+ ++src;
}
} QT_CATCH(...) {
- while (current != from)
- delete reinterpret_cast<T*>(current--);
+ while (current-- != from)
+ delete reinterpret_cast<T*>(current->v);
QT_RETHROW;
}
} else if (QTypeInfo<T>::isComplex) {
QT_TRY {
- while(current != to)
- new (current++) T(*reinterpret_cast<T*>(src++));
+ while(current != to) {
+ new (current) T(*reinterpret_cast<T*>(src));
+ ++current;
+ ++src;
+ }
} QT_CATCH(...) {
- while (current != from)
- (reinterpret_cast<T*>(current--))->~T();
+ while (current-- != from)
+ (reinterpret_cast<T*>(current))->~T();
QT_RETHROW;
}
} else {
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index 052c456..28ec963 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -388,6 +388,10 @@ void QTimeLine::setDirection(Direction direction)
By default, this value is 1000 (i.e., 1 second), but you can change this
by either passing a duration to QTimeLine's constructor, or by calling
setDuration(). The duration must be larger than 0.
+
+ \note Changing the duration does not cause the current time to be reset
+ to zero or the new duration. You also need to call setCurrentTime() with
+ the desired value.
*/
int QTimeLine::duration() const
{
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index e63eb8b..7661e03 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -29,14 +29,18 @@ SetPropertyAction -> PropertyAction
RunScriptAction -> ScriptAction
ParentChangeAction -> ParentAction
VisualModel -> VisualDataModel
+Follow -> SpringFollow
Renamed properties:
+Item: contents -> childrenRect
MouseRegion: xmin -> minimumX
MouseRegion: xmax -> maximumX
MouseRegion: ymin -> minimumY
MouseRegion: ymin -> maximumY
Text elements: hAlign -> horizontalAlignment
Text elements: vAlign -> verticalAlignment
+Text elements: highlightColor -> selectionColor
+Text elements: highlightedTextColor -> selectedTextColor
State: operations -> changes
Transition: operations -> animations
Transition: fromState -> from
@@ -58,6 +62,14 @@ WebView: status -> statusText
WebView: mouseX -> clickX (parameter to onDoubleClick)
WebView: mouseY -> clickY (parameter to onDoubleClick)
WebView: cacheSize -> pixelCacheSize
+Repeater: component -> delegate
+Repeater: dataSource -> model
+ListView: current -> currentItem
+GridView: current -> currentItem
+ListView: wrap -> keyNavigationWraps
+ListView: autoHighlight -> highlightFollowsCurrentItem
+GridView: wrap -> keyNavigationWraps
+GridView: autoHighlight -> highlightFollowsCurrentItem
Additions:
MouseRegion: add "acceptedButtons" property
@@ -66,6 +78,10 @@ MouseRegion: add "pressedButtons" property
Timer: add start() and stop() slots
WebView: add newWindowComponent and newWindowParent properties
Loader: add status() and progress() properties
+Loader: add sourceComponent property
+Loader: add resizeMode property
+ListView: preferredHighlightBegin, preferredHighlightEnd
+ListView: strictlyEnforceHighlightRange
Deletions:
Column/VerticalPositioner: lost "margins" property
@@ -73,6 +89,9 @@ Row/HorizontalPositioner: lost "margins" property
Grid/Positioner/Layout: lost "margins" property
WebView: lost "interactive" property (always true now)
Flickable: removed "dragMode" property
+ComponentInstance: removed. Replaced by Loader.sourceComponent
+ListView: removed currentItemMode. Replaced by highligh range.
+ListView: removed snapPos.
Other Changes:
Drag: axis becomes an enum with values "XAxis", "YAxis", "XandYAxis"
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index 4b67074..01efa0e 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -58,20 +58,85 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,XmlRole,XmlListModelRole)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,XmlRole,QmlXmlListModelRole)
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,XmlListModel,QmlXmlListModel)
+/*!
+ \qmlclass XmlRole
+ \brief The XmlRole element allows you to specify a role for an XmlListModel.
+*/
+
+/*!
+ \qmlproperty string XmlRole::name
+ The name for the role. This name is used to access the model data for this role from Qml.
+
+ \qml
+ XmlRole { name: "title"; query: "title/string()" }
+
+ ...
+
+ Component {
+ id: Delegate
+ Text { text: title }
+ }
+ \endqml
+*/
+
+/*!
+ \qmlproperty string XmlRole::query
+ The relative XPath query for this role. The query should not start with a '/' (i.e. it must be
+ relative).
+
+ \qml
+ XmlRole { name: "title"; query: "title/string()" }
+ \endqml
+*/
+
+class Q_DECLARATIVE_EXPORT QmlXmlListModelRole : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString query READ query WRITE setQuery)
+
+public:
+ QmlXmlListModelRole() {}
+ ~QmlXmlListModelRole() {}
+
+ QString name() const { return m_name; }
+ void setName(const QString &name) { m_name = name; }
+
+ QString query() const { return m_query; }
+ void setQuery(const QString &query)
+ {
+ if (query.startsWith(QLatin1Char('/'))) {
+ qmlInfo(this) << "An XmlRole query must not start with '/'";
+ return;
+ }
+ m_query = query;
+ }
+
+ bool isValid() {
+ return !m_name.isEmpty() && !m_query.isEmpty();
+ }
+
+private:
+ QString m_name;
+ QString m_query;
+};
+
+QML_DECLARE_TYPE(QmlXmlListModelRole)
+
class QmlXmlListModelPrivate;
-struct QmlXmlRoleList : public QmlConcreteList<XmlListModelRole *>
+struct QmlXmlRoleList : public QmlConcreteList<QmlXmlListModelRole *>
{
QmlXmlRoleList(QmlXmlListModelPrivate *p)
: model(p) {}
- virtual void append(XmlListModelRole *role);
+ virtual void append(QmlXmlListModelRole *role);
//XXX clear, removeAt, and insert need to invalidate any cached data (in data table) as well
// (and the model should emit the appropriate signals)
virtual void clear();
virtual void removeAt(int i);
- virtual void insert(int i, XmlListModelRole *role);
+ virtual void insert(int i, QmlXmlListModelRole *role);
QmlXmlListModelPrivate *model;
};
@@ -220,7 +285,7 @@ void QmlXmlQuery::doSubQueryJob()
//### we might be able to condense even further (query for everything in one go)
for (int i = 0; i < m_roleObjects->size(); ++i) {
- XmlListModelRole *role = m_roleObjects->at(i);
+ QmlXmlListModelRole *role = m_roleObjects->at(i);
if (!role->isValid()) {
QList<QVariant> resultList;
for (int j = 0; j < m_size; ++j)
@@ -248,7 +313,7 @@ void QmlXmlQuery::doSubQueryJob()
/*for (int j = 0; j < m_size; ++j) {
QList<QVariant> resultList;
for (int i = 0; i < m_roleObjects->size(); ++i) {
- XmlListModelRole *role = m_roleObjects->at(i);
+ QmlXmlListModelRole *role = m_roleObjects->at(i);
subquery.setQuery(m_prefix.arg(j+1) + role->query());
if (role->isStringList()) {
QStringList data;
@@ -274,10 +339,8 @@ void QmlXmlQuery::doSubQueryJob()
}
-//TODO: do something smart while waiting for data to load
-// error handling (currently quite fragile)
+//TODO: error handling (currently quite fragile)
// profile doQuery and doSubquery
-// some sort of loading indication while we wait for initial data load (status property similar to QWebImage?)
// support complex/nested objects?
// how do we handle data updates (like rss feed -- usually items inserted at beginning)
@@ -310,64 +373,33 @@ public:
};
-void QmlXmlRoleList::append(XmlListModelRole *role) {
- QmlConcreteList<XmlListModelRole *>::append(role);
+void QmlXmlRoleList::append(QmlXmlListModelRole *role) {
+ QmlConcreteList<QmlXmlListModelRole *>::append(role);
model->roles << model->highestRole;
model->roleNames << role->name();
++model->highestRole;
}
-/*!
- \qmlclass XmlRole
- \brief The XmlRole element allows you to specify a role for an XmlListModel.
-*/
-
-/*!
- \qmlproperty string XmlRole::name
- The name for the role. This name is used to access the model data for this role from Qml.
-
- \qml
- XmlRole { name: "title"; query: "title/string()" }
-
- ...
-
- Component {
- id: Delegate
- Text { text: title }
- }
- \endqml
-*/
-
-/*!
- \qmlproperty string XmlRole::query
- The relative XPath query for this role. The query should not start with a '/' (i.e. it must be
- relative).
-
- \qml
- XmlRole { name: "title"; query: "title/string()" }
- \endqml
-*/
-
//XXX clear, removeAt, and insert need to invalidate any cached data (in data table) as well
// (and the model should emit the appropriate signals)
void QmlXmlRoleList::clear()
{
model->roles.clear();
model->roleNames.clear();
- QmlConcreteList<XmlListModelRole *>::clear();
+ QmlConcreteList<QmlXmlListModelRole *>::clear();
}
void QmlXmlRoleList::removeAt(int i)
{
model->roles.removeAt(i);
model->roleNames.removeAt(i);
- QmlConcreteList<XmlListModelRole *>::removeAt(i);
+ QmlConcreteList<QmlXmlListModelRole *>::removeAt(i);
}
//### we should enforce unique role names
-void QmlXmlRoleList::insert(int i, XmlListModelRole *role)
+void QmlXmlRoleList::insert(int i, QmlXmlListModelRole *role)
{
- QmlConcreteList<XmlListModelRole *>::insert(i, role);
+ QmlConcreteList<QmlXmlListModelRole *>::insert(i, role);
model->roles.insert(i, model->highestRole);
model->roleNames.insert(i, role->name());
++model->highestRole;
@@ -413,7 +445,7 @@ QmlXmlListModel::~QmlXmlListModel()
The roles to make available for this model.
*/
-QmlList<XmlListModelRole *> *QmlXmlListModel::roleObjects()
+QmlList<QmlXmlListModelRole *> *QmlXmlListModel::roleObjects()
{
Q_D(QmlXmlListModel);
return &d->roleObjects;
diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h
index 5f7c831..1bcc008 100644
--- a/src/declarative/extra/qmlxmllistmodel.h
+++ b/src/declarative/extra/qmlxmllistmodel.h
@@ -53,37 +53,8 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QmlContext;
-class Q_DECLARATIVE_EXPORT XmlListModelRole : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QString query READ query WRITE setQuery)
-public:
- XmlListModelRole() {}
- ~XmlListModelRole() {}
-
- QString name() const { return m_name; }
- void setName(const QString &name) { m_name = name; }
-
- QString query() const { return m_query; }
- void setQuery(const QString &query)
- {
- if (query.startsWith(QLatin1Char('/'))) {
- qmlInfo(this) << "An XmlRole query must not start with '/'";
- return;
- }
- m_query = query;
- }
-
- bool isValid() {
- return !m_name.isEmpty() && !m_query.isEmpty();
- }
-
-private:
- QString m_name;
- QString m_query;
-};
+class QmlXmlListModelRole;
class QmlXmlListModelPrivate;
class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public QmlParserStatus
@@ -98,7 +69,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public
Q_PROPERTY(QString xml READ xml WRITE setXml)
Q_PROPERTY(QString query READ query WRITE setQuery)
Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
- Q_PROPERTY(QmlList<XmlListModelRole *> *roles READ roleObjects)
+ Q_PROPERTY(QmlList<QmlXmlListModelRole *> *roles READ roleObjects)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "roles")
@@ -111,7 +82,7 @@ public:
virtual QList<int> roles() const;
virtual QString toString(int role) const;
- QmlList<XmlListModelRole *> *roleObjects();
+ QmlList<QmlXmlListModelRole *> *roleObjects();
QUrl source() const;
void setSource(const QUrl&);
@@ -138,6 +109,10 @@ signals:
void countChanged();
public Q_SLOTS:
+ // ### need to use/expose Expiry to guess when to call this?
+ // ### property to auto-call this on reasonable Expiry?
+ // ### LastModified/Age also useful to guess.
+ // ### Probably also applies to other network-requesting types.
void reload();
private Q_SLOTS:
@@ -152,7 +127,6 @@ private:
QT_END_NAMESPACE
-QML_DECLARE_TYPE(XmlListModelRole)
QML_DECLARE_TYPE(QmlXmlListModel)
QT_END_HEADER
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index 80a6fdd..cfe78e1 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -1,8 +1,6 @@
HEADERS += \
fx/qfxanchors.h \
fx/qfxanchors_p.h \
- fx/qfxcomponentinstance.h \
- fx/qfxcomponentinstance_p.h \
fx/qfxevents_p.h \
fx/qfxflickable.h \
fx/qfxflickable_p.h \
@@ -49,7 +47,6 @@ HEADERS += \
SOURCES += \
fx/qfxanchors.cpp \
- fx/qfxcomponentinstance.cpp \
fx/qfxevents.cpp \
fx/qfxflickable.cpp \
fx/qfxflipable.cpp \
diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp
deleted file mode 100644
index 7a712aa..0000000
--- a/src/declarative/fx/qfxcomponentinstance.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfxcomponentinstance.h"
-#include "qfxcomponentinstance_p.h"
-#include <private/qfxperf_p.h>
-#include <QtDeclarative/qmlinfo.h>
-
-
-QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,ComponentInstance,QFxComponentInstance)
-
-/*!
- \internal
- \class QFxComponentInstance ComponentInstance
-
- \brief The QFxComponentInstance class provides a way to instantiate an item from a component.
- */
-
-/*!
- \qmlclass ComponentInstance QFxComponentInstance
- \brief The ComponentInstance item allows you to instantiate a \l{Component}.
-
- \qml
- Item {
- Component {
- id: RedSquare
- Rectangle { color: "red"; width: 10; height: 10 }
- }
-
- ComponentInstance { component: RedSquare }
- }
- \endqml
-*/
-QFxComponentInstance::QFxComponentInstance(QFxItem *parent)
- : QFxItem(*(new QFxComponentInstancePrivate), parent)
-{
-}
-
-QFxComponentInstance::QFxComponentInstance(QFxComponentInstancePrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
-{
-}
-
-/*!
- \qmlproperty Component QFxComponentInstance::component
-
- This property holds the component to instantiate.
-*/
-QmlComponent *QFxComponentInstance::component() const
-{
- Q_D(const QFxComponentInstance);
- return d->component;
-}
-
-void QFxComponentInstance::setComponent(QmlComponent *c)
-{
- Q_D(QFxComponentInstance);
- if (d->component) {
- qmlInfo(this) << "component is a write-once property.";
- return;
- }
- d->component = c;
- create();
-}
-
-void QFxComponentInstance::create()
-{
- Q_D(QFxComponentInstance);
- if (d->component) {
- QObject *obj= d->component->create(qmlContext(this));
- if (obj) {
- QFxItem *objitem = qobject_cast<QFxItem *>(obj);
- if (objitem) {
- d->instance = objitem;
- objitem->setParentItem(this);
- objitem->setFocus(true);
- connect(objitem, SIGNAL(widthChanged()), this, SLOT(updateSize()));
- connect(objitem, SIGNAL(heightChanged()), this, SLOT(updateSize()));
- updateSize();
- emit instanceChanged();
- } else {
- delete obj;
- }
- }
- }
-}
-
-void QFxComponentInstance::updateSize()
-{
- QFxItem *i = instance();
- if (i) {
- if (!widthValid())
- setImplicitWidth(i->width());
- if (!heightValid())
- setImplicitHeight(i->height());
- }
-}
-
-/*!
- \qmlproperty Item QFxComponentInstance::instance
-
- This property holds the instantiated component.
-*/
-QFxItem *QFxComponentInstance::instance() const
-{
- Q_D(const QFxComponentInstance);
- return d->instance;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxcomponentinstance_p.h b/src/declarative/fx/qfxcomponentinstance_p.h
deleted file mode 100644
index defeb74..0000000
--- a/src/declarative/fx/qfxcomponentinstance_p.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFXCOMPONENTINSTANCE_P_H
-#define QFXCOMPONENTINSTANCE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qfxitem_p.h"
-
-
-QT_BEGIN_NAMESPACE
-class QFxComponentInstancePrivate : public QFxItemPrivate
-{
- Q_DECLARE_PUBLIC(QFxComponentInstance)
-
-public:
- QFxComponentInstancePrivate()
- : component(0), instance(0)
- {
- }
-
- QmlComponent *component;
- QFxItem *instance;
-};
-
-QT_END_NAMESPACE
-
-#endif // QFXCOMPONENTINSTANCE_P_H
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 5fe9617..1e6ad5a 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -48,6 +48,16 @@
QT_BEGIN_NAMESPACE
+
+// These are highly device dependant.
+// DragThreshold determines how far the "mouse" must move before
+// we begin a drag.
+// FlickThreshold determines how far the "mouse" must have moved
+// before we perform a flick.
+static const int DragThreshold = 8;
+static const int FlickThreshold = 20;
+
+
class QFxFlickableVisibleArea : public QObject
{
Q_OBJECT
@@ -147,7 +157,7 @@ QFxFlickablePrivate::QFxFlickablePrivate()
: viewport(new QFxItem), _moveX(viewport, &QFxItem::setX), _moveY(viewport, &QFxItem::setY)
, vWidth(-1), vHeight(-1), overShoot(true), flicked(false), moving(false), stealMouse(false)
, pressed(false), atXEnd(false), atXBeginning(true), atYEnd(false), atYBeginning(true)
- , interactive(true), maxVelocity(-1), reportedVelocitySmoothing(100)
+ , interactive(true), maxVelocity(5000), reportedVelocitySmoothing(100)
, delayedPressEvent(0), delayedPressTarget(0), pressDelay(0)
, horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0)
{
@@ -327,8 +337,6 @@ void QFxFlickablePrivate::updateBeginningEnd()
visibleArea->updateVisible();
}
-static const int FlickThreshold = 5;
-
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Flickable,QFxFlickable)
/*!
@@ -602,7 +610,7 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (q->yflick()) {
int dy = int(event->pos().y() - pressPos.y());
- if (qAbs(dy) > FlickThreshold || pressTime.elapsed() > 200) {
+ if (qAbs(dy) > DragThreshold || pressTime.elapsed() > 200) {
qreal newY = dy + pressY;
const qreal minY = q->minYExtent();
const qreal maxY = q->maxYExtent();
@@ -615,14 +623,14 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
moved = true;
} else if (!q->overShoot())
rejectY = true;
- if (qAbs(dy) > FlickThreshold)
+ if (qAbs(dy) > DragThreshold)
stealMouse = true;
}
}
if (q->xflick()) {
int dx = int(event->pos().x() - pressPos.x());
- if (qAbs(dx) > FlickThreshold || pressTime.elapsed() > 200) {
+ if (qAbs(dx) > DragThreshold || pressTime.elapsed() > 200) {
qreal newX = dx + pressX;
const qreal minX = q->minXExtent();
const qreal maxX = q->maxXExtent();
@@ -635,7 +643,7 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
moved = true;
} else if (!q->overShoot())
rejectX = true;
- if (qAbs(dx) > FlickThreshold)
+ if (qAbs(dx) > DragThreshold)
stealMouse = true;
}
}
@@ -666,7 +674,7 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
lastPos = event->pos();
}
-void QFxFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *)
+void QFxFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_Q(QFxFlickable);
pressed = false;
@@ -674,12 +682,12 @@ void QFxFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *)
return;
vTime = timeline.time();
- if (qAbs(velocityY) > 10)
+ if (qAbs(velocityY) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold)
flickY(velocityY);
else
fixupY();
- if (qAbs(velocityX) > 10)
+ if (qAbs(velocityX) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold)
flickX(velocityX);
else
fixupX();
@@ -853,7 +861,7 @@ void QFxFlickablePrivate::data_append(QObject *o)
Q_Q(QFxFlickable);
QFxItem *i = qobject_cast<QFxItem *>(o);
if (i)
- viewport->children()->append(i);
+ viewport->fxChildren()->append(i);
else
o->setParent(q);
}
@@ -884,7 +892,7 @@ QmlList<QObject *> *QFxFlickable::flickableData()
QmlList<QFxItem *> *QFxFlickable::flickableChildren()
{
Q_D(QFxFlickable);
- return d->viewport->children();
+ return d->viewport->fxChildren();
}
/*!
@@ -1093,6 +1101,8 @@ bool QFxFlickable::sceneEventFilter(QGraphicsItem *i, QEvent *e)
/*!
\qmlproperty int Flickable::maximumFlickVelocity
This property holds the maximum velocity that the user can flick the view in pixels/second.
+
+ The default is 5000 pixels/s
*/
qreal QFxFlickable::maximumFlickVelocity() const
{
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
index 8e56e43..dc5101c 100644
--- a/src/declarative/fx/qfxflipable.cpp
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -146,7 +146,7 @@ void QFxFlipable::setFront(QFxItem *front)
return;
}
d->front = front;
- children()->append(d->front);
+ fxChildren()->append(d->front);
if (Back == d->current)
d->front->setOpacity(0.);
}
@@ -165,7 +165,7 @@ void QFxFlipable::setBack(QFxItem *back)
return;
}
d->back = back;
- children()->append(d->back);
+ fxChildren()->append(d->back);
if (Front == d->current)
d->back->setOpacity(0.);
}
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index cccd7a6..1095dc1 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -41,7 +41,7 @@
#include "qfxvisualitemmodel.h"
#include "qlistmodelinterface.h"
-#include "qmlfollow.h"
+#include "qmleasefollow.h"
#include "private/qfxflickable_p.h"
#include "qfxgridview.h"
@@ -313,8 +313,8 @@ public:
enum MovementReason { Other, Key, Mouse };
MovementReason moveReason;
int buffer;
- QmlFollow *highlightXAnimator;
- QmlFollow *highlightYAnimator;
+ QmlEaseFollow *highlightXAnimator;
+ QmlEaseFollow *highlightYAnimator;
int ownModel : 1;
int wrap : 1;
@@ -591,15 +591,13 @@ void QFxGridViewPrivate::createHighlight()
if (item) {
item->setParent(q->viewport());
highlight = new FxGridItem(item, q);
- highlightXAnimator = new QmlFollow(q);
+ highlightXAnimator = new QmlEaseFollow(q);
highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x")));
- highlightXAnimator->setSpring(3);
- highlightXAnimator->setDamping(0.3);
+ highlightXAnimator->setVelocity(400);
highlightXAnimator->setEnabled(autoHighlight);
- highlightYAnimator = new QmlFollow(q);
+ highlightYAnimator = new QmlEaseFollow(q);
highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y")));
- highlightYAnimator->setSpring(3);
- highlightYAnimator->setDamping(0.3);
+ highlightYAnimator->setVelocity(400);
highlightYAnimator->setEnabled(autoHighlight);
} else {
delete highlightContext;
@@ -725,6 +723,7 @@ void QFxGridView::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(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*)));
disconnect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*)));
}
@@ -753,6 +752,7 @@ void QFxGridView::setModel(const QVariant &model)
d->updateCurrent(d->currentIndex);
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(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*)));
connect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*)));
refill();
@@ -795,10 +795,10 @@ void QFxGridView::setDelegate(QmlComponent *delegate)
/*!
\qmlproperty int GridView::currentIndex
- \qmlproperty Item GridView::current
+ \qmlproperty Item GridView::currentItem
\c currentIndex holds the index of the current item.
- \c current is the current item. Note that the position of the current item
+ \c currentItem is the current item. Note that the position of the current item
may only be approximate until it becomes visible in the view.
*/
int QFxGridView::currentIndex() const
@@ -846,12 +846,12 @@ int QFxGridView::count() const
An instance of the highlight component will be created for each view.
The geometry of the resultant component instance will be managed by the view
- so as to stay with the current item, unless the autoHighlight property is false.
+ so as to stay with the current item, unless the highlightFollowsCurrentItem property is false.
The below example demonstrates how to make a simple highlight:
\snippet doc/src/snippets/declarative/gridview/gridview.qml 1
- \sa autoHighlight
+ \sa highlightFollowsCurrentItem
*/
QmlComponent *QFxGridView::highlight() const
{
@@ -868,11 +868,11 @@ void QFxGridView::setHighlight(QmlComponent *highlight)
}
/*!
- \qmlproperty component GridView::autoHighlight
+ \qmlproperty bool GridView::highlightFollowsCurrentItem
This property sets whether the highlight is managed by the view.
- If autoHighlight is true, the highlight will be moved smoothly
- to follow the current item. If autoHighlight is false, the
+ If highlightFollowsCurrentItem is true, the highlight will be moved smoothly
+ to follow the current item. If highlightFollowsCurrentItem is false, the
highlight will not be moved by the view, and must be implemented
by the highlight component, for example:
@@ -881,19 +881,19 @@ void QFxGridView::setHighlight(QmlComponent *highlight)
id: Highlight
Rectangle {
id: Wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60 >
- y: Follow { source: Wrapper.GridView.view.current.y; spring: 3; damping: 0.2 }
- x: Follow { source: Wrapper.GridView.view.current.x; spring: 3; damping: 0.2 }
+ y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
+ x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
}
}
\endcode
*/
-bool QFxGridView::autoHighlight() const
+bool QFxGridView::highlightFollowsCurrentItem() const
{
Q_D(const QFxGridView);
return d->autoHighlight;
}
-void QFxGridView::setAutoHighlight(bool autoHighlight)
+void QFxGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
{
Q_D(QFxGridView);
d->autoHighlight = autoHighlight;
@@ -936,7 +936,7 @@ void QFxGridView::setFlow(Flow flow)
}
/*!
- \qmlproperty bool GridView::wrap
+ \qmlproperty bool GridView::keyNavigationWraps
This property holds whether the grid wraps key navigation
If this property is true then key presses to move off of one end of the grid will cause the
@@ -1358,6 +1358,67 @@ void QFxGridView::destroyRemoved()
d->layout();
}
+void QFxGridView::itemsMoved(int from, int to, int count)
+{
+ Q_D(QFxGridView);
+ QHash<int,FxGridItem*> moved;
+
+ QList<FxGridItem*>::Iterator it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxGridItem *item = *it;
+ if (item->index >= from && item->index < from + count) {
+ // take the items that are moving
+ item->index += (to-from);
+ moved.insert(item->index, item);
+ it = d->visibleItems.erase(it);
+ } else {
+ if (item->index > from && item->index != -1) {
+ // move everything after the moved items.
+ item->index -= count;
+ }
+ ++it;
+ }
+ }
+
+ int remaining = count;
+ int endIndex = d->visibleIndex;
+ it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxGridItem *item = *it;
+ if (remaining && item->index >= to && item->index < to + count) {
+ // place items in the target position, reusing any existing items
+ FxGridItem *movedItem = moved.take(item->index);
+ if (!movedItem)
+ movedItem = d->createItem(item->index);
+ it = d->visibleItems.insert(it, movedItem);
+ ++it;
+ --remaining;
+ } else {
+ if (item->index != -1) {
+ if (item->index >= to) {
+ // update everything after the moved items.
+ item->index += count;
+ }
+ endIndex = item->index;
+ }
+ ++it;
+ }
+ }
+
+ // If we have moved items to the end of the visible items
+ // then add any existing moved items that we have
+ while (FxGridItem *item = moved.take(endIndex+1)) {
+ d->visibleItems.append(item);
+ ++endIndex;
+ }
+
+ // Whatever moved items remain are no longer visible items.
+ while (moved.count())
+ d->releaseItem(moved.take(moved.begin().key()));
+
+ d->layout();
+}
+
void QFxGridView::createdItem(int index, QFxItem *item)
{
Q_D(QFxGridView);
diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h
index 4ebd311..996141f 100644
--- a/src/declarative/fx/qfxgridview.h
+++ b/src/declarative/fx/qfxgridview.h
@@ -60,12 +60,12 @@ class Q_DECLARATIVE_EXPORT QFxGridView : public QFxFlickable
Q_PROPERTY(QVariant model READ model WRITE setModel)
Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
- Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged)
+ Q_PROPERTY(QFxItem *currentItem READ currentItem NOTIFY currentIndexChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight)
- Q_PROPERTY(bool autoHighlight READ autoHighlight WRITE setAutoHighlight)
+ Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
Q_PROPERTY(Flow flow READ flow WRITE setFlow)
- Q_PROPERTY(bool wrap READ isWrapEnabled WRITE setWrapEnabled)
+ Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellSizeChanged)
Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellSizeChanged)
@@ -90,8 +90,8 @@ public:
QmlComponent *highlight() const;
void setHighlight(QmlComponent *highlight);
- bool autoHighlight() const;
- void setAutoHighlight(bool);
+ bool highlightFollowsCurrentItem() const;
+ void setHighlightFollowsCurrentItem(bool);
Q_ENUMS(Flow)
enum Flow { LeftToRight, TopToBottom };
@@ -130,6 +130,7 @@ private Q_SLOTS:
void trackedPositionChanged();
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
+ void itemsMoved(int from, int to, int count);
void destroyRemoved();
void createdItem(int index, QFxItem *item);
void destroyingItem(QFxItem *item);
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 99e1b72..3ac3f3c 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -252,41 +252,12 @@ void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
if (width() != d->pix.width() || height() != d->pix.height()) {
if (d->fillMode >= Tile) {
- p->save();
- p->setClipRect(0, 0, width(), height(), Qt::IntersectClip);
-
- if (d->fillMode == Tile) {
- const int pw = d->pix.width();
- const int ph = d->pix.height();
- int yy = 0;
-
- while(yy < height()) {
- int xx = 0;
- while(xx < width()) {
- p->drawPixmap(xx, yy, d->pix);
- xx += pw;
- }
- yy += ph;
- }
- } else if (d->fillMode == TileVertically) {
- const int ph = d->pix.height();
- int yy = 0;
-
- while(yy < height()) {
- p->drawPixmap(QRect(0, yy, width(), ph), d->pix);
- yy += ph;
- }
- } else {
- const int pw = d->pix.width();
- int xx = 0;
-
- while(xx < width()) {
- p->drawPixmap(QRect(xx, 0, pw, height()), d->pix);
- xx += pw;
- }
- }
-
- p->restore();
+ if (d->fillMode == Tile)
+ p->drawTiledPixmap(QRectF(0,0,width(),height()), d->pix);
+ else if (d->fillMode == TileVertically)
+ p->drawTiledPixmap(QRectF(0,0,d->pix.width(),height()), d->pix);
+ else
+ p->drawTiledPixmap(QRectF(0,0,width(),d->pix.height()), d->pix);
} else {
qreal widthScale = width() / qreal(d->pix.width());
qreal heightScale = height() / qreal(d->pix.height());
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 5363148..a2c744e 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -235,10 +235,10 @@ QFxContents::QFxContents() : m_x(0), m_y(0), m_width(0), m_height(0)
}
/*!
- \qmlproperty qreal Item::childrenRect.x
- \qmlproperty qreal Item::childrenRect.y
- \qmlproperty qreal Item::childrenRect.width
- \qmlproperty qreal Item::childrenRect.height
+ \qmlproperty real Item::childrenRect.x
+ \qmlproperty real Item::childrenRect.y
+ \qmlproperty real Item::childrenRect.width
+ \qmlproperty real Item::childrenRect.height
The childrenRect properties allow an item access to the geometry of its
children. This property is useful if you have an item that needs to be
@@ -1473,7 +1473,7 @@ void QFxItemPrivate::data_append(QObject *o)
Q_Q(QFxItem);
QFxItem *i = qobject_cast<QFxItem *>(o);
if (i)
- q->children()->append(i);
+ q->fxChildren()->append(i);
else
resources_append(o);
}
@@ -2271,7 +2271,7 @@ void QFxItem::focusChanged(bool flag)
emit focusChanged();
}
-QmlList<QFxItem *> *QFxItem::children()
+QmlList<QFxItem *> *QFxItem::fxChildren()
{
Q_D(QFxItem);
return &(d->children);
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 643987d..c6a5311 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -70,7 +70,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
Q_PROPERTY(QFxItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL)
Q_PROPERTY(QmlList<QObject *> *data READ data DESIGNABLE false)
- Q_PROPERTY(QmlList<QFxItem *>* children READ children DESIGNABLE false)
+ Q_PROPERTY(QmlList<QFxItem *>* children READ fxChildren DESIGNABLE false)
Q_PROPERTY(QmlList<QObject *>* resources READ resources DESIGNABLE false)
Q_PROPERTY(QmlList<QmlState *>* states READ states DESIGNABLE false)
Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitions DESIGNABLE false)
@@ -112,7 +112,7 @@ public:
void setParent(QFxItem *parent) { setParentItem(parent); }
QmlList<QObject *> *data();
- QmlList<QFxItem *> *children();
+ QmlList<QFxItem *> *fxChildren();
QmlList<QObject *> *resources();
QFxAnchors *anchors();
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index c24610f..168e4c4 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include "private/qfxflickable_p.h"
-#include "qmlfollow.h"
+#include "qmleasefollow.h"
#include "qlistmodelinterface.h"
#include "qfxvisualitemmodel.h"
#include "qfxlistview.h"
@@ -172,11 +172,13 @@ public:
QFxListViewPrivate()
: model(0), currentItem(0), tmpCurrent(0), orient(Qt::Vertical)
, visiblePos(0), visibleIndex(0)
- , averageSize(100), currentIndex(-1), requestedIndex(-1)
- , currItemMode(QFxListView::Free), snapPos(0), highlightComponent(0), highlight(0), trackedItem(0)
- , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0)
+ , averageSize(100.0), currentIndex(-1), requestedIndex(-1)
+ , highlightRangeStart(0), highlightRangeEnd(0)
+ , highlightComponent(0), highlight(0), trackedItem(0)
+ , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0.0)
, ownModel(false), wrap(false), autoHighlight(true)
- , fixCurrentVisibility(false) {}
+ , haveHighlightRange(false), strictHighlightRange(false)
+ {}
void init();
void clear();
@@ -205,7 +207,7 @@ public:
else
q->setViewportX(pos);
}
- int size() const {
+ qreal size() const {
Q_Q(const QFxListView);
return orient == Qt::Vertical ? q->height() : q->width();
}
@@ -272,13 +274,16 @@ public:
}
int snapIndex() {
- qreal pos = position();
+ int index = currentIndex;
for (int i = 0; i < visibleItems.count(); ++i) {
- qreal itemTop = visibleItems[i]->position() - pos;
- if (itemTop >= snapPos-averageSize/2 && itemTop < snapPos+averageSize/2)
- return visibleItems[i]->index;
+ FxListItem *item = visibleItems[i];
+ if (item->index == -1)
+ continue;
+ qreal itemTop = item->position();
+ if (itemTop >= highlight->position()-item->size()/2 && itemTop < highlight->position()+item->size()/2)
+ return item->index;
}
- return -1;
+ return index;
}
int lastVisibleIndex() const {
@@ -372,25 +377,25 @@ public:
qreal averageSize;
int currentIndex;
int requestedIndex;
- QFxListView::CurrentItemPositioning currItemMode;
- int snapPos;
+ qreal highlightRangeStart;
+ qreal highlightRangeEnd;
QmlComponent *highlightComponent;
FxListItem *highlight;
FxListItem *trackedItem;
- QFxItem *activeItem; //XXX fix
enum MovementReason { Other, Key, Mouse };
MovementReason moveReason;
int buffer;
- QmlFollow *highlightPosAnimator;
- QmlFollow *highlightSizeAnimator;
+ QmlEaseFollow *highlightPosAnimator;
+ QmlEaseFollow *highlightSizeAnimator;
QString sectionExpression;
QString currentSection;
- int spacing;
+ qreal spacing;
- int ownModel : 1;
- int wrap : 1;
- int autoHighlight : 1;
- int fixCurrentVisibility : 1;
+ bool ownModel : 1;
+ bool wrap : 1;
+ bool autoHighlight : 1;
+ bool haveHighlightRange : 1;
+ bool strictHighlightRange : 1;
};
void QFxListViewPrivate::init()
@@ -438,7 +443,7 @@ FxListItem *QFxListViewPrivate::createItem(int modelIndex)
}
// complete
model->completeItem();
- listItem->item->setZValue(modelIndex + 1);
+ listItem->item->setZValue(1);
listItem->item->setParent(q->viewport());
if (orient == Qt::Vertical)
QObject::connect(listItem->item, SIGNAL(heightChanged()), q, SLOT(itemResized()));
@@ -659,16 +664,20 @@ void QFxListViewPrivate::createHighlight()
item->setParent(q->viewport());
}
if (item) {
+ item->setZValue(0);
highlight = new FxListItem(item, q);
+ if (orient == Qt::Vertical)
+ highlight->item->setHeight(currentItem->item->height());
+ else
+ highlight->item->setWidth(currentItem->item->width());
const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x");
- highlightPosAnimator = new QmlFollow(q);
+ highlightPosAnimator = new QmlEaseFollow(q);
highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp));
- highlightPosAnimator->setEpsilon(0.25);
- highlightPosAnimator->setSpring(2.5);
- highlightPosAnimator->setDamping(0.35);
+ highlightPosAnimator->setVelocity(400);
highlightPosAnimator->setEnabled(autoHighlight);
const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width");
- highlightSizeAnimator = new QmlFollow(q);
+ highlightSizeAnimator = new QmlEaseFollow(q);
+ highlightSizeAnimator->setVelocity(400);
highlightSizeAnimator->setTarget(QmlMetaProperty(highlight->item, sizeProp));
highlightSizeAnimator->setEnabled(autoHighlight);
}
@@ -680,7 +689,7 @@ void QFxListViewPrivate::updateHighlight()
if ((!currentItem && highlight) || (currentItem && !highlight))
createHighlight();
updateTrackedItem();
- if (currentItem && autoHighlight && highlight) {
+ if (currentItem && autoHighlight && highlight && !pressed && moveReason != QFxListViewPrivate::Mouse) {
// auto-update highlight
highlightPosAnimator->setSourceValue(currentItem->position());
highlightSizeAnimator->setSourceValue(currentItem->size());
@@ -753,7 +762,6 @@ void QFxListViewPrivate::updateCurrent(int modelIndex)
FxListItem *oldCurrentItem = currentItem;
currentIndex = modelIndex;
currentItem = createItem(modelIndex);
- fixCurrentVisibility = true;
if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item))
oldCurrentItem->attached->setIsCurrentItem(false);
if (currentItem) {
@@ -794,54 +802,30 @@ void QFxListViewPrivate::fixupPosition()
void QFxListViewPrivate::fixupY()
{
- Q_Q(QFxListView);
QFxFlickablePrivate::fixupY();
if (orient == Qt::Horizontal)
return;
- if (currItemMode == QFxListView::SnapAuto) {
- if (currentItem) {
+
+ if (haveHighlightRange && strictHighlightRange) {
+ if (currentItem && highlight && currentItem->position() != highlight->position()) {
moveReason = Mouse;
timeline.clear();
- timeline.move(_moveY, -(currentItem->position() - snapPos), QEasingCurve(QEasingCurve::InOutQuad), 200);
- }
- } else if (currItemMode == QFxListView::Snap) {
- moveReason = Mouse;
- int idx = snapIndex();
- if (FxListItem *snapItem = visibleItem(idx)) {
- int pos = snapItem->position() - snapPos;
- if (pos > -q->maxYExtent())
- pos = -q->maxYExtent();
- else if (pos < -q->minYExtent())
- pos = -q->minYExtent();
- timeline.clear();
- timeline.move(_moveY, -(pos), QEasingCurve(QEasingCurve::InOutQuad), 200);
+ timeline.move(_moveY, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
}
void QFxListViewPrivate::fixupX()
{
- Q_Q(QFxListView);
QFxFlickablePrivate::fixupX();
if (orient == Qt::Vertical)
return;
- if (currItemMode == QFxListView::SnapAuto) {
- if (currentItem) {
+
+ if (haveHighlightRange && strictHighlightRange) {
+ if (currentItem && highlight && currentItem->position() != highlight->position()) {
moveReason = Mouse;
timeline.clear();
- timeline.move(_moveX, -(currentItem->position() - snapPos), QEasingCurve(QEasingCurve::InOutQuad), 200);
- }
- } else if (currItemMode == QFxListView::Snap) {
- moveReason = Mouse;
- int idx = snapIndex();
- if (FxListItem *snapItem = visibleItem(idx)) {
- int pos = snapItem->position() - snapPos;
- if (pos > -q->maxXExtent())
- pos = -q->maxXExtent();
- else if (pos < -q->minXExtent())
- pos = -q->minXExtent();
- timeline.clear();
- timeline.move(_moveX, -(pos), QEasingCurve(QEasingCurve::InOutQuad), 200);
+ timeline.move(_moveX, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
}
@@ -909,6 +893,7 @@ void QFxListView::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(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*)));
disconnect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*)));
}
@@ -937,6 +922,7 @@ void QFxListView::setModel(const QVariant &model)
d->updateCurrent(d->currentIndex);
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(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*)));
connect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*)));
refill();
@@ -979,10 +965,10 @@ void QFxListView::setDelegate(QmlComponent *delegate)
/*!
\qmlproperty int ListView::currentIndex
- \qmlproperty Item ListView::current
+ \qmlproperty Item ListView::currentItem
\c currentIndex holds the index of the current item.
- \c current is the current item. Note that the position of the current item
+ \c currentItem is the current item. Note that the position of the current item
may only be approximate until it becomes visible in the view.
*/
int QFxListView::currentIndex() const
@@ -1033,7 +1019,8 @@ int QFxListView::count() const
An instance of the highlight component will be created for each list.
The geometry of the resultant component instance will be managed by the list
- so as to stay with the current item, unless the autoHighlight property is false.
+ so as to stay with the current item, unless the highlightFollowsCurrentItem
+ property is false.
The below example demonstrates how to make a simple highlight
for a vertical list.
@@ -1041,7 +1028,7 @@ int QFxListView::count() const
\snippet doc/src/snippets/declarative/listview/listview.qml 1
\image trivialListView.png
- \sa autoHighlight
+ \sa highlightFollowsCurrentItem
*/
QmlComponent *QFxListView::highlight() const
{
@@ -1058,26 +1045,26 @@ void QFxListView::setHighlight(QmlComponent *highlight)
}
/*!
- \qmlproperty bool ListView::autoHighlight
+ \qmlproperty bool ListView::highlightFollowsCurrentItem
This property holds whether the highlight is managed by the view.
- If autoHighlight is true, the highlight will be moved smoothly
- to follow the current item. If autoHighlight is false, the
+ If highlightFollowsCurrentItem is true, the highlight will be moved smoothly
+ to follow the current item. If highlightFollowsCurrentItem is false, the
highlight will not be moved by the view, and must be implemented
by the highlight. The following example creates a highlight with
- its motion defined by the spring \l {Follow}:
+ its motion defined by the spring \l {SpringFollow}:
\snippet doc/src/snippets/declarative/listview/highlight.qml 1
\sa highlight
*/
-bool QFxListView::autoHighlight() const
+bool QFxListView::highlightFollowsCurrentItem() const
{
Q_D(const QFxListView);
return d->autoHighlight;
}
-void QFxListView::setAutoHighlight(bool autoHighlight)
+void QFxListView::setHighlightFollowsCurrentItem(bool autoHighlight)
{
Q_D(QFxListView);
d->autoHighlight = autoHighlight;
@@ -1089,55 +1076,58 @@ void QFxListView::setAutoHighlight(bool autoHighlight)
}
/*!
- \qmlproperty enumeration ListView::currentItemPositioning
- This property determines the current item positioning and selection characteristics.
-
- The modes supported are:
- \list
- \i Free - For Mouse, the current item may be positioned anywhere,
- whether within the visible area, or outside. During Keyboard interaction,
- the current item can move within the visible area, and the view will
- scroll to keep the highlight visible.
- \i Snap - For mouse, the current item may be positioned anywhere,
- whether within the visible area, or outside. During keyboard interaction,
- the current item will be kept in the visible area and will prefer to be
- positioned at the \l snapPosition, however the view will never scroll
- beyond the beginning or end of the view.
- \i SnapAuto - For both mouse and keyboard, the current item will be
- kept at the \l {snapPosition}. Additionally, if the view is dragged or
- flicked, the current item will be automatically updated to be the item
- currently at the snapPosition.
- \endlist
+ \qmlproperty real ListView::preferredHighlightBegin
+ \qmlproperty real ListView::preferredHighlightEnd
+ \qmlproperty bool ListView::strictlyEnforceHighlightRange
+
+ These properties set the preferred range of the highlight (current item)
+ within the view.
+
+ If the strictlyEnforceHighlightRange property is false (default)
+ the highlight can move outside of the range at the ends of the list
+ or due to a mouse interaction.
+
+ If strictlyEnforceHighlightRange is true then the highlight will never
+ move outside the range. This means that the current item will change
+ if a keyboard or mouse action would cause the highlight to move
+ outside of the range.
*/
-QFxListView::CurrentItemPositioning QFxListView::currentItemPositioning() const
+qreal QFxListView::preferredHighlightBegin() const
{
Q_D(const QFxListView);
- return d->currItemMode;
+ return d->highlightRangeStart;
}
-void QFxListView::setCurrentItemPositioning(CurrentItemPositioning mode)
+void QFxListView::setPreferredHighlightBegin(qreal start)
{
Q_D(QFxListView);
- d->currItemMode = mode;
+ d->highlightRangeStart = start;
+ d->haveHighlightRange = d->highlightRangeStart < d->highlightRangeEnd;
}
-/*!
- \qmlproperty int ListView::snapPosition
+qreal QFxListView::preferredHighlightEnd() const
+{
+ Q_D(const QFxListView);
+ return d->highlightRangeEnd;
+}
- When currentItemPositioning is set to Snap or SnapAuto, the
- \c snapPosition determines where the top of the items will
- snap to.
-*/
-int QFxListView::snapPosition() const
+void QFxListView::setPreferredHighlightEnd(qreal end)
+{
+ Q_D(QFxListView);
+ d->highlightRangeEnd = end;
+ d->haveHighlightRange = d->highlightRangeStart < d->highlightRangeEnd;
+}
+
+bool QFxListView::strictlyEnforceHighlightRange() const
{
Q_D(const QFxListView);
- return d->snapPos;
+ return d->strictHighlightRange;
}
-void QFxListView::setSnapPosition(int pos)
+void QFxListView::setStrictlyEnforceHighlightRange(bool strict)
{
Q_D(QFxListView);
- d->snapPos = pos;
+ d->strictHighlightRange = strict;
}
/*!
@@ -1145,13 +1135,13 @@ void QFxListView::setSnapPosition(int pos)
This property holds the spacing to leave between items.
*/
-int QFxListView::spacing() const
+qreal QFxListView::spacing() const
{
Q_D(const QFxListView);
return d->spacing;
}
-void QFxListView::setSpacing(int spacing)
+void QFxListView::setSpacing(qreal spacing)
{
Q_D(QFxListView);
if (spacing != d->spacing) {
@@ -1194,11 +1184,11 @@ void QFxListView::setOrientation(Qt::Orientation orientation)
}
/*!
- \qmlproperty bool ListView::wrap
+ \qmlproperty bool ListView::keyNavigationWraps
This property holds whether the list wraps key navigation
If this property is true then key presses to move off of one end of the list will cause the
- selection to jump to the other side.
+ current item to jump to the other end.
*/
bool QFxListView::isWrapEnabled() const
{
@@ -1278,11 +1268,19 @@ void QFxListView::viewportMoved()
refill();
if (isFlicking() || d->pressed)
d->moveReason = QFxListViewPrivate::Mouse;
- if (d->currItemMode == SnapAuto && d->moveReason == QFxListViewPrivate::Mouse) {
- // Update current index
- int idx = d->snapIndex();
- if (idx >= 0 && idx != d->currentIndex)
- d->updateCurrent(idx);
+ if (d->moveReason == QFxListViewPrivate::Mouse) {
+ if (d->haveHighlightRange && d->strictHighlightRange && d->highlight) {
+ int idx = d->snapIndex();
+ if (idx >= 0 && idx != d->currentIndex)
+ d->updateCurrent(idx);
+
+ qreal pos = d->currentItem->position();
+ if (pos > d->position() + d->highlightRangeEnd - d->highlight->size())
+ pos = d->position() + d->highlightRangeEnd - d->highlight->size();
+ if (pos < d->position() + d->highlightRangeStart)
+ pos = d->position() + d->highlightRangeStart;
+ d->highlight->setPosition(pos);
+ }
}
}
@@ -1292,8 +1290,8 @@ qreal QFxListView::minYExtent() const
if (d->orient == Qt::Horizontal)
return QFxFlickable::minYExtent();
qreal extent = -d->startPosition();
- if (d->currItemMode == SnapAuto)
- extent += d->snapPos;
+ if (d->haveHighlightRange && d->strictHighlightRange)
+ extent += d->highlightRangeStart;
return extent;
}
@@ -1304,8 +1302,8 @@ qreal QFxListView::maxYExtent() const
if (d->orient == Qt::Horizontal)
return QFxFlickable::maxYExtent();
qreal extent;
- if (d->currItemMode == SnapAuto)
- extent = -(d->positionAt(count()-1) - d->snapPos);
+ if (d->haveHighlightRange && d->strictHighlightRange)
+ extent = -(d->endPosition() - d->highlightRangeEnd);
else
extent = -(d->endPosition() - height());
qreal minY = minYExtent();
@@ -1320,8 +1318,8 @@ qreal QFxListView::minXExtent() const
if (d->orient == Qt::Vertical)
return QFxFlickable::minXExtent();
qreal extent = -d->startPosition();
- if (d->currItemMode == SnapAuto)
- extent += d->snapPos;
+ if (d->haveHighlightRange && d->strictHighlightRange)
+ extent += d->highlightRangeStart;
return extent;
}
@@ -1332,8 +1330,8 @@ qreal QFxListView::maxXExtent() const
if (d->orient == Qt::Vertical)
return QFxFlickable::maxXExtent();
qreal extent;
- if (d->currItemMode == SnapAuto)
- extent = -(d->positionAt(count()-1) - d->snapPos);
+ if (d->haveHighlightRange && d->strictHighlightRange)
+ extent = -(d->endPosition() - d->highlightRangeEnd);
else
extent = -(d->endPosition() - width());
qreal minX = minXExtent();
@@ -1348,7 +1346,7 @@ void QFxListView::keyPressEvent(QKeyEvent *event)
if (d->model && d->model->count() && d->interactive) {
if ((d->orient == Qt::Horizontal && event->key() == Qt::Key_Left)
|| (d->orient == Qt::Vertical && event->key() == Qt::Key_Up)) {
- if (currentIndex() > 0 || d->wrap) {
+ if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) {
d->moveReason = QFxListViewPrivate::Key;
int index = currentIndex()-1;
d->updateCurrent(index >= 0 ? index : d->model->count()-1);
@@ -1357,7 +1355,7 @@ void QFxListView::keyPressEvent(QKeyEvent *event)
}
} else if ((d->orient == Qt::Horizontal && event->key() == Qt::Key_Right)
|| (d->orient == Qt::Vertical && event->key() == Qt::Key_Down)) {
- if (currentIndex() < d->model->count() - 1 || d->wrap) {
+ if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) {
d->moveReason = QFxListViewPrivate::Key;
int index = currentIndex()+1;
d->updateCurrent(index < d->model->count() ? index : 0);
@@ -1393,30 +1391,41 @@ void QFxListView::trackedPositionChanged()
if (!d->trackedItem)
return;
if (!isFlicking() && !d->pressed && d->moveReason != QFxListViewPrivate::Mouse) {
- switch (d->currItemMode) {
- case Free:
- if (d->trackedItem->position() < d->position()) {
- d->setPosition(d->trackedItem->position());
+ const qreal trackedPos = d->trackedItem->position();
+ if (d->haveHighlightRange) {
+ if (d->strictHighlightRange) {
+ qreal pos = d->position();
+ if (trackedPos > pos + d->highlightRangeEnd - d->trackedItem->size())
+ pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size();
+ if (trackedPos < pos + d->highlightRangeStart)
+ pos = trackedPos - d->highlightRangeStart;
+ d->setPosition(pos);
+ } else {
+ qreal pos = d->position();
+ if (trackedPos < d->startPosition() + d->highlightRangeStart) {
+ pos = d->startPosition();
+ } else if (d->trackedItem->endPosition() > d->endPosition() - d->size() + d->highlightRangeEnd) {
+ pos = d->endPosition() - d->size();
+ } else {
+ if (trackedPos < d->position() + d->highlightRangeStart) {
+ pos = trackedPos - d->highlightRangeStart;
+ } else if (trackedPos > d->position() + d->highlightRangeEnd - d->trackedItem->size()) {
+ pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size();
+ }
+ }
+ d->setPosition(pos);
+ }
+ } else {
+ if (trackedPos < d->position()) {
+ d->setPosition(trackedPos);
d->fixupPosition();
} else if (d->trackedItem->endPosition() > d->position() + d->size()) {
qreal pos = d->trackedItem->endPosition() - d->size();
if (d->trackedItem->size() > d->size())
- pos = d->trackedItem->position();
+ pos = trackedPos;
d->setPosition(pos);
d->fixupPosition();
}
- break;
- case Snap:
- if (d->trackedItem->position() < d->startPosition() + d->snapPos)
- d->setPosition(d->startPosition());
- else if (d->trackedItem->endPosition() > d->endPosition() - d->size() + d->snapPos + d->trackedItem->size())
- d->setPosition(d->endPosition() - d->size());
- else
- d->setPosition(d->trackedItem->position() - d->snapPos);
- break;
- case SnapAuto:
- d->setPosition(d->trackedItem->position() - d->snapPos);
- break;
}
}
}
@@ -1426,9 +1435,7 @@ void QFxListView::itemResized()
Q_D(QFxListView);
QFxItem *item = qobject_cast<QFxItem*>(sender());
if (item) {
- d->activeItem = item; // Ick - don't delete the sender
d->layout();
- d->activeItem = 0;
d->fixupPosition();
}
}
@@ -1507,7 +1514,8 @@ void QFxListView::itemsInserted(int modelIndex, int count)
// Update the indexes of the following visible items.
for (; index < d->visibleItems.count(); ++index) {
FxListItem *listItem = d->visibleItems.at(index);
- listItem->setPosition(listItem->position() + (pos - initialPos));
+ if (listItem->item != d->currentItem->item)
+ listItem->setPosition(listItem->position() + (pos - initialPos));
if (listItem->index != -1)
listItem->index += count;
}
@@ -1634,6 +1642,72 @@ void QFxListView::destroyRemoved()
d->layout();
}
+void QFxListView::itemsMoved(int from, int to, int count)
+{
+ Q_D(QFxListView);
+ qreal firstItemPos = d->visibleItems.first()->position();
+ QHash<int,FxListItem*> moved;
+ int moveBy = 0;
+
+ QList<FxListItem*>::Iterator it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxListItem *item = *it;
+ if (item->index >= from && item->index < from + count) {
+ // take the items that are moving
+ item->index += (to-from);
+ moved.insert(item->index, item);
+ moveBy += item->size();
+ it = d->visibleItems.erase(it);
+ } else {
+ // move everything after the moved items.
+ if (item->index > from && item->index != -1)
+ item->index -= count;
+ ++it;
+ }
+ }
+
+ int remaining = count;
+ int endIndex = d->visibleIndex;
+ it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxListItem *item = *it;
+ if (remaining && item->index >= to && item->index < to + count) {
+ // place items in the target position, reusing any existing items
+ FxListItem *movedItem = moved.take(item->index);
+ if (!movedItem)
+ movedItem = d->createItem(item->index);
+ it = d->visibleItems.insert(it, movedItem);
+ ++it;
+ --remaining;
+ } else {
+ if (item->index != -1) {
+ if (item->index >= to) {
+ // update everything after the moved items.
+ item->index += count;
+ }
+ endIndex = item->index;
+ }
+ ++it;
+ }
+ }
+
+ // If we have moved items to the end of the visible items
+ // then add any existing moved items that we have
+ while (FxListItem *item = moved.take(endIndex+1)) {
+ d->visibleItems.append(item);
+ ++endIndex;
+ }
+
+ // Whatever moved items remain are no longer visible items.
+ while (moved.count())
+ d->releaseItem(moved.take(moved.begin().key()));
+
+ // Ensure we don't cause an ugly list scroll.
+ d->visibleItems.first()->setPosition(firstItemPos);
+
+ d->layout();
+}
+
void QFxListView::createdItem(int index, QFxItem *item)
{
Q_D(QFxListView);
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 42ce1a2..e5c3138 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -50,6 +50,10 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+//### incrementCurrentIndex(), decrementCurrentIndex() slots
+//### default Keys.OnUp/DownPressed handler
+
+
class QFxVisualModel;
class QFxListViewAttached;
class QFxListViewPrivate;
@@ -62,15 +66,18 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
Q_PROPERTY(QVariant model READ model WRITE setModel)
Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
- Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged)
+ Q_PROPERTY(QFxItem *currentItem READ currentItem NOTIFY currentIndexChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight)
- Q_PROPERTY(bool autoHighlight READ autoHighlight WRITE setAutoHighlight)
- Q_PROPERTY(CurrentItemPositioning currentItemPositioning READ currentItemPositioning WRITE setCurrentItemPositioning)
- Q_PROPERTY(int snapPosition READ snapPosition WRITE setSnapPosition)
- Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
+ Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
+
+ Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin)
+ Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd)
+ Q_PROPERTY(bool strictlyEnforceHighlightRange READ strictlyEnforceHighlightRange WRITE setStrictlyEnforceHighlightRange)
+
+ Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
- Q_PROPERTY(bool wrap READ isWrapEnabled WRITE setWrapEnabled)
+ Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
Q_PROPERTY(QString sectionExpression READ sectionExpression WRITE setSectionExpression NOTIFY sectionExpressionChanged)
Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
@@ -95,18 +102,20 @@ public:
QmlComponent *highlight() const;
void setHighlight(QmlComponent *highlight);
- bool autoHighlight() const;
- void setAutoHighlight(bool);
+ bool highlightFollowsCurrentItem() const;
+ void setHighlightFollowsCurrentItem(bool);
- enum CurrentItemPositioning { Free, Snap, SnapAuto };
- CurrentItemPositioning currentItemPositioning() const;
- void setCurrentItemPositioning(CurrentItemPositioning mode);
+ bool strictlyEnforceHighlightRange() const;
+ void setStrictlyEnforceHighlightRange(bool strict);
+
+ qreal preferredHighlightBegin() const;
+ void setPreferredHighlightBegin(qreal);
- int snapPosition() const;
- void setSnapPosition(int pos);
+ qreal preferredHighlightEnd() const;
+ void setPreferredHighlightEnd(qreal);
- int spacing() const;
- void setSpacing(int spacing);
+ qreal spacing() const;
+ void setSpacing(qreal spacing);
Qt::Orientation orientation() const;
void setOrientation(Qt::Orientation);
@@ -145,6 +154,7 @@ private Q_SLOTS:
void itemResized();
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
+ void itemsMoved(int from, int to, int count);
void destroyRemoved();
void createdItem(int index, QFxItem *item);
void destroyingItem(QFxItem *item);
diff --git a/src/declarative/fx/qfxloader.cpp b/src/declarative/fx/qfxloader.cpp
index 869a5b0..668faa4 100644
--- a/src/declarative/fx/qfxloader.cpp
+++ b/src/declarative/fx/qfxloader.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
QFxLoaderPrivate::QFxLoaderPrivate()
-: item(0), qmlcomp(0)
+: item(0), component(0), ownComponent(false), resizeMode(QFxLoader::SizeLoaderToItem)
{
}
@@ -59,9 +59,22 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Loader,QFxLoader)
\qmlclass Loader
\inherits Item
- \brief The Loader item allows you to dynamically load an Item-based
- subtree from a QML URL.
- */
+ \brief The Loader item allows dynamically loading an Item-based
+ subtree from a QML URL or Component.
+
+ Loader instantiates an item from a component. The component to
+ instantiate may be specified directly by the \c sourceComponent
+ property, or loaded from a URL via the \c source property.
+
+ It is also an effective means of delaying the creation of a component
+ until it is required:
+ \code
+ Loader { id: PageLoader }
+ Rectangle {
+ MouseRegion { anchors.fill: parent; onClicked: PageLoader.source = "Page1.qml" }
+ }
+ \endcode
+*/
/*!
\internal
@@ -86,10 +99,10 @@ QFxLoader::~QFxLoader()
/*!
\qmlproperty url Loader::source
- This property holds the dynamic URL of the QML for the item.
+ This property holds the URL of the QML component to
+ instantiate.
- This property is used for dynamically loading QML into the
- item.
+ \sa status, progress
*/
QUrl QFxLoader::source() const
{
@@ -103,44 +116,98 @@ void QFxLoader::setSource(const QUrl &url)
if (d->source == url)
return;
- if (!d->source.isEmpty()) {
- QHash<QString, QFxItem *>::Iterator iter = d->cachedChildren.find(d->source.toString());
- if (iter != d->cachedChildren.end())
- (*iter)->setOpacity(0.);
+ if (d->ownComponent) {
+ delete d->component;
+ d->component = 0;
}
-
- d->source = url;
+ delete d->item;
d->item = 0;
- emit itemChanged();
+ d->source = url;
if (d->source.isEmpty()) {
emit sourceChanged();
emit statusChanged();
emit progressChanged();
+ emit itemChanged();
+ return;
+ }
+
+ d->component = new QmlComponent(qmlEngine(this), d->source, this);
+ d->ownComponent = true;
+ if (!d->component->isLoading()) {
+ d->_q_sourceLoaded();
+ } else {
+ connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)),
+ this, SLOT(_q_sourceLoaded()));
+ connect(d->component, SIGNAL(progressChanged(qreal)),
+ this, SIGNAL(progressChanged()));
+ emit statusChanged();
+ emit progressChanged();
+ emit sourceChanged();
+ emit itemChanged();
+ }
+}
+
+/*!
+ \qmlproperty Component Loader::sourceComponent
+ The sourceComponent property holds the \l{Component} to instantiate.
+
+ \qml
+ Item {
+ Component {
+ id: RedSquare
+ Rectangle { color: "red"; width: 10; height: 10 }
+ }
+
+ Loader { sourceComponent: RedSquare }
+ Loader { sourceComponent: RedSquare; x: 10 }
+ }
+ \endqml
+
+ \sa source
+*/
+
+QmlComponent *QFxLoader::sourceComponent() const
+{
+ Q_D(const QFxLoader);
+ return d->component;
+}
+
+void QFxLoader::setSourceComponent(QmlComponent *comp)
+{
+ Q_D(QFxLoader);
+ if (comp == d->component)
return;
+
+ d->source = QUrl();
+ if (d->ownComponent) {
+ delete d->component;
+ d->component = 0;
}
+ delete d->item;
+ d->item = 0;
- QHash<QString, QFxItem *>::Iterator iter = d->cachedChildren.find(d->source.toString());
- if (iter != d->cachedChildren.end()) {
- (*iter)->setOpacity(1.);
- d->item = (*iter);
+ d->component = comp;
+ d->ownComponent = false;
+ if (!d->component) {
emit sourceChanged();
emit statusChanged();
emit progressChanged();
emit itemChanged();
+ return;
+ }
+
+ if (!d->component->isLoading()) {
+ d->_q_sourceLoaded();
} else {
- d->qmlcomp =
- new QmlComponent(qmlEngine(this), d->source, this);
- if (!d->qmlcomp->isLoading()) {
- d->_q_sourceLoaded();
- } else {
- connect(d->qmlcomp, SIGNAL(statusChanged(QmlComponent::Status)),
- this, SLOT(_q_sourceLoaded()));
- connect(d->qmlcomp, SIGNAL(progressChanged(qreal)),
- this, SIGNAL(progressChanged()));
- emit statusChanged();
- emit progressChanged();
- }
+ connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)),
+ this, SLOT(_q_sourceLoaded()));
+ connect(d->component, SIGNAL(progressChanged(qreal)),
+ this, SIGNAL(progressChanged()));
+ emit progressChanged();
+ emit sourceChanged();
+ emit statusChanged();
+ emit itemChanged();
}
}
@@ -148,33 +215,39 @@ void QFxLoaderPrivate::_q_sourceLoaded()
{
Q_Q(QFxLoader);
- if (qmlcomp) {
+ if (component) {
QmlContext *ctxt = new QmlContext(qmlContext(q));
ctxt->addDefaultObject(q);
- if (!qmlcomp->errors().isEmpty()) {
- qWarning() << qmlcomp->errors();
- delete qmlcomp;
- qmlcomp = 0;
+ if (!component->errors().isEmpty()) {
+ qWarning() << component->errors();
emit q->sourceChanged();
emit q->statusChanged();
emit q->progressChanged();
return;
}
- QObject *obj = qmlcomp->create(ctxt);
- if (!qmlcomp->errors().isEmpty())
- qWarning() << qmlcomp->errors();
- QFxItem *qmlChild = qobject_cast<QFxItem *>(obj);
- if (qmlChild) {
- qmlChild->setParentItem(q);
- cachedChildren.insert(source.toString(), qmlChild);
- item = qmlChild;
+
+ QObject *obj = component->create(ctxt);
+ if (obj) {
+ item = qobject_cast<QFxItem *>(obj);
+ if (item) {
+ item->setParentItem(q);
+// item->setFocus(true);
+ QFxItem *resizeItem = 0;
+ if (resizeMode == QFxLoader::SizeLoaderToItem)
+ resizeItem = item;
+ else if (resizeMode == QFxLoader::SizeItemToLoader)
+ resizeItem = q;
+ if (resizeItem) {
+ QObject::connect(resizeItem, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::connect(resizeItem, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ }
+ _q_updateSize();
+ }
} else {
- delete qmlChild;
+ delete obj;
source = QUrl();
}
- delete qmlcomp;
- qmlcomp = 0;
emit q->sourceChanged();
emit q->statusChanged();
emit q->progressChanged();
@@ -196,6 +269,19 @@ void QFxLoaderPrivate::_q_sourceLoaded()
\sa progress
*/
+QFxLoader::Status QFxLoader::status() const
+{
+ Q_D(const QFxLoader);
+
+ if (d->component)
+ return static_cast<QFxLoader::Status>(d->component->status());
+
+ if (d->item)
+ return Ready;
+
+ return d->source.isEmpty() ? Null : Error;
+}
+
/*!
\qmlproperty real Loader::progress
@@ -204,27 +290,89 @@ void QFxLoaderPrivate::_q_sourceLoaded()
\sa status
*/
-QFxLoader::Status QFxLoader::status() const
+qreal QFxLoader::progress() const
{
Q_D(const QFxLoader);
- if (d->qmlcomp)
- return static_cast<QFxLoader::Status>(d->qmlcomp->status());
-
if (d->item)
- return Ready;
+ return 1.0;
- return d->source.isEmpty() ? Null : Error;
+ if (d->component)
+ return d->component->progress();
+
+ return 0.0;
}
-qreal QFxLoader::progress() const
+/*!
+ \qmlproperty enum Loader::resizeMode
+
+ This property determines how the Loader or item are resized:
+ \list
+ \o NoResize - no item will be resized
+ \o SizeLoaderToItem - the Loader will be sized to the size of the item, unless the size of the Loader has been otherwise specified.
+ \o SizeItemToLoader - the item will be sized to the size of the Loader.
+ \endlist
+
+ The default resizeMode is SizeLoaderToItem.
+*/
+QFxLoader::ResizeMode QFxLoader::resizeMode() const
{
Q_D(const QFxLoader);
+ return d->resizeMode;
+}
- if (d->qmlcomp)
- return d->qmlcomp->progress();
+void QFxLoader::setResizeMode(ResizeMode mode)
+{
+ Q_D(QFxLoader);
+ if (mode == d->resizeMode)
+ return;
- return d->item ? 1.0 : 0.0;
+ if (d->item) {
+ QFxItem *resizeItem = 0;
+ if (d->resizeMode == SizeLoaderToItem)
+ resizeItem = d->item;
+ else if (d->resizeMode == SizeItemToLoader)
+ resizeItem = this;
+ if (resizeItem) {
+ disconnect(resizeItem, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
+ disconnect(resizeItem, SIGNAL(heightChanged()), this, SLOT(_q_updateSize()));
+ }
+ }
+
+ d->resizeMode = mode;
+
+ if (d->item) {
+ QFxItem *resizeItem = 0;
+ if (d->resizeMode == SizeLoaderToItem)
+ resizeItem = d->item;
+ else if (d->resizeMode == SizeItemToLoader)
+ resizeItem = this;
+ if (resizeItem) {
+ connect(resizeItem, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
+ connect(resizeItem, SIGNAL(heightChanged()), this, SLOT(_q_updateSize()));
+ }
+ }
+}
+
+void QFxLoaderPrivate::_q_updateSize()
+{
+ Q_Q(QFxLoader);
+ if (!item)
+ return;
+ switch (resizeMode) {
+ case QFxLoader::SizeLoaderToItem:
+ if (!q->widthValid())
+ q->setImplicitWidth(item->width());
+ if (!q->heightValid())
+ q->setImplicitHeight(item->height());
+ break;
+ case QFxLoader::SizeItemToLoader:
+ item->setWidth(q->width());
+ item->setHeight(q->height());
+ break;
+ default:
+ break;
+ }
}
/*!
diff --git a/src/declarative/fx/qfxloader.h b/src/declarative/fx/qfxloader.h
index 132c8f4..b967465 100644
--- a/src/declarative/fx/qfxloader.h
+++ b/src/declarative/fx/qfxloader.h
@@ -55,14 +55,15 @@ class Q_DECLARATIVE_EXPORT QFxLoader : public QFxItem
{
Q_OBJECT
Q_ENUMS(Status)
+ Q_ENUMS(ResizeMode)
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent NOTIFY sourceChanged)
+ Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
Q_PROPERTY(QFxItem *item READ item NOTIFY itemChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
//### sourceItem
- //### sourceComponent
- //### resizeMode { NoResize, SizeLoaderToItem (default), SizeItemToLoader }
public:
QFxLoader(QFxItem *parent=0);
@@ -71,10 +72,17 @@ public:
QUrl source() const;
void setSource(const QUrl &);
+ QmlComponent *sourceComponent() const;
+ void setSourceComponent(QmlComponent *);
+
enum Status { Null, Ready, Loading, Error };
Status status() const;
qreal progress() const;
+ enum ResizeMode { NoResize, SizeLoaderToItem, SizeItemToLoader };
+ ResizeMode resizeMode() const;
+ void setResizeMode(ResizeMode mode);
+
QFxItem *item() const;
Q_SIGNALS:
@@ -87,6 +95,7 @@ private:
Q_DISABLE_COPY(QFxLoader)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxLoader)
Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxloader_p.h b/src/declarative/fx/qfxloader_p.h
index 13f3b53..0700fcd 100644
--- a/src/declarative/fx/qfxloader_p.h
+++ b/src/declarative/fx/qfxloader_p.h
@@ -69,10 +69,12 @@ public:
QUrl source;
QFxItem *item;
- QmlComponent *qmlcomp;
- QHash<QString, QFxItem *> cachedChildren;
+ QmlComponent *component;
+ bool ownComponent;
+ QFxLoader::ResizeMode resizeMode;
void _q_sourceLoaded();
+ void _q_updateSize();
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 469e9f3..62f9db0 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -128,6 +128,9 @@ QFxPathView::QFxPathView(QFxPathViewPrivate &dd, QFxItem *parent)
QFxPathView::~QFxPathView()
{
+ Q_D(QFxPathView);
+ if (d->ownModel)
+ delete d->model;
}
/*!
diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp
index bad4944..e4500aa 100644
--- a/src/declarative/fx/qfxpositioners.cpp
+++ b/src/declarative/fx/qfxpositioners.cpp
@@ -251,6 +251,18 @@ void QFxBasePositioner::prePositioning()
d->_animated.clear();
doPositioning();
finishApplyTransitions();
+ //Set implicit size to the size of its children
+ //###To keep this valid, do we need to update on pos change as well?
+ qreal h = 0.0f;
+ qreal w = 0.0f;
+ foreach(QFxItem *child, d->_items){
+ if(!child->isVisible() || child->opacity() <= 0)
+ continue;
+ h = qMax(h, child->y() + child->height());
+ w = qMax(w, child->x() + child->width());
+ }
+ setImplicitHeight(h);
+ setImplicitWidth(w);
}
void QFxBasePositioner::applyTransition(const QList<QPair<QString, QVariant> >& changes, QFxItem* target, QmlStateOperation::ActionList &actions)
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index c60aaf2..5b10289 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -466,9 +466,6 @@ void QFxTextPrivate::updateSize()
{
Q_Q(QFxText);
if (q->isComponentComplete()) {
- if (text.isEmpty()) {
- return;
- }
QFontMetrics fm(font);
int dy = q->height();
@@ -633,15 +630,17 @@ QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle)
//paint text
QPixmap img(size);
- img.fill(Qt::transparent);
- QPainter p(&img);
- if (drawStyle) {
- p.setPen(styleColor);
+ if (!size.isEmpty()) {
+ img.fill(Qt::transparent);
+ QPainter p(&img);
+ if (drawStyle) {
+ p.setPen(styleColor);
+ }
+ else
+ p.setPen(color);
+ p.setFont(font);
+ layout.draw(&p, QPointF(0, 0));
}
- else
- p.setPen(color);
- p.setFont(font);
- layout.draw(&p, QPointF(0, 0));
return img;
}
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index c2c418e..72f12cc 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -271,24 +271,24 @@ void QFxTextEdit::setColor(const QColor &color)
}
/*!
- \qmlproperty color TextEdit::highlightColor
+ \qmlproperty color TextEdit::selectionColor
The text highlight color, used behind selections.
*/
-QColor QFxTextEdit::highlightColor() const
+QColor QFxTextEdit::selectionColor() const
{
Q_D(const QFxTextEdit);
- return d->highlightColor;
+ return d->selectionColor;
}
-void QFxTextEdit::setHighlightColor(const QColor &color)
+void QFxTextEdit::setSelectionColor(const QColor &color)
{
Q_D(QFxTextEdit);
- if (d->highlightColor == color)
+ if (d->selectionColor == color)
return;
clearCache();
- d->highlightColor = color;
+ d->selectionColor = color;
QPalette pal = d->control->palette();
pal.setColor(QPalette::Highlight, color);
d->control->setPalette(pal);
@@ -296,24 +296,24 @@ void QFxTextEdit::setHighlightColor(const QColor &color)
}
/*!
- \qmlproperty color TextEdit::highlightedTextColor
+ \qmlproperty color TextEdit::selectedTextColor
- The highlighted text color, used in selections.
+ The selected text color, used in selections.
*/
-QColor QFxTextEdit::highlightedTextColor() const
+QColor QFxTextEdit::selectedTextColor() const
{
Q_D(const QFxTextEdit);
- return d->highlightedTextColor;
+ return d->selectedTextColor;
}
-void QFxTextEdit::setHighlightedTextColor(const QColor &color)
+void QFxTextEdit::setSelectedTextColor(const QColor &color)
{
Q_D(QFxTextEdit);
- if (d->highlightedTextColor == color)
+ if (d->selectedTextColor == color)
return;
clearCache();
- d->highlightedTextColor = color;
+ d->selectedTextColor = color;
QPalette pal = d->control->palette();
pal.setColor(QPalette::HighlightedText, color);
d->control->setPalette(pal);
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 6a10e85..1a5d968 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -68,8 +68,8 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QColor color READ color WRITE setColor)
- Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) //### selectionColor
- Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) //### selectedTextColor
+ Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor)
+ Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign)
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign)
@@ -119,11 +119,11 @@ public:
QColor color() const;
void setColor(const QColor &c);
- QColor highlightColor() const;
- void setHighlightColor(const QColor &c);
+ QColor selectionColor() const;
+ void setSelectionColor(const QColor &c);
- QColor highlightedTextColor() const;
- void setHighlightedTextColor(const QColor &c);
+ QColor selectedTextColor() const;
+ void setSelectedTextColor(const QColor &c);
HAlignment hAlign() const;
void setHAlign(HAlignment align);
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index fb757de..9c73db9 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -84,8 +84,8 @@ public:
QString text;
QFont font;
QColor color;
- QColor highlightColor;
- QColor highlightedTextColor;
+ QColor selectionColor;
+ QColor selectedTextColor;
QString style;
QColor styleColor;
bool imgDirty;
diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp
index 4dd29cd..d9da308 100644
--- a/src/declarative/fx/qfxtextinput.cpp
+++ b/src/declarative/fx/qfxtextinput.cpp
@@ -55,6 +55,12 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QIntValidator,QIntValidator);
/*!
\qmlclass TextInput
The TextInput item allows you to add an editable line of text to a scene.
+
+ TextInput can only display a single line of text, and can only display
+ plain text. However it can provide addition input constraints on the text.
+
+ Input constraints include setting a QValidator, an input mask, or a
+ maximum input length.
*/
QFxTextInput::QFxTextInput(QFxItem* parent)
: QFxPaintedItem(*(new QFxTextInputPrivate), parent)
@@ -148,47 +154,62 @@ void QFxTextInput::setColor(const QColor &c)
/*!
- \qmlproperty color TextInput::highlightColor
+ \qmlproperty color TextInput::selectionColor
The text highlight color, used behind selections.
*/
-QColor QFxTextInput::highlightColor() const
+QColor QFxTextInput::selectionColor() const
{
Q_D(const QFxTextInput);
- return d->highlightColor;
+ return d->selectionColor;
}
-void QFxTextInput::setHighlightColor(const QColor &color)
+void QFxTextInput::setSelectionColor(const QColor &color)
{
Q_D(QFxTextInput);
- if (d->highlightColor == color)
+ if (d->selectionColor == color)
return;
- d->highlightColor = color;
+ d->selectionColor = color;
//TODO: implement
}
/*!
- \qmlproperty color TextInput::highlightedTextColor
+ \qmlproperty color TextInput::selectedTextColor
The highlighted text color, used in selections.
*/
-QColor QFxTextInput::highlightedTextColor() const
+QColor QFxTextInput::selectedTextColor() const
{
Q_D(const QFxTextInput);
- return d->highlightedTextColor;
+ return d->selectedTextColor;
}
-void QFxTextInput::setHighlightedTextColor(const QColor &color)
+void QFxTextInput::setSelectedTextColor(const QColor &color)
{
Q_D(QFxTextInput);
- if (d->highlightedTextColor == color)
+ if (d->selectedTextColor == color)
return;
- d->highlightedTextColor = color;
+ d->selectedTextColor = color;
//TODO: implement
}
+/*!
+ \qmlproperty enumeration TextInput::horizontalAlignment
+
+ Sets the horizontal alignment of the text within the TextInput item's
+ width and height. By default, the text is left aligned.
+
+ TextInput does not have vertical alignment, as the natural height is
+ exactly the height of the single line of text. If you set the height
+ manually to something larger, TextInput will always be top aligned
+ vertically. You can use anchors to align it however you want within
+ another item.
+
+ The valid values for \c horizontalAlignment are \c AlignLeft, \c AlignRight and
+ \c AlignHCenter.
+*/
QFxTextInput::HAlignment QFxTextInput::hAlign() const
{
Q_D(const QFxTextInput);
@@ -340,6 +361,34 @@ QString QFxTextInput::selectedText() const
return d->control->selectedText();
}
+/*!
+ \qmlproperty bool TextInput::focusOnPress
+
+ Whether the TextInput should gain focus on a mouse press. By default this is
+ set to true.
+*/
+bool QFxTextInput::focusOnPress() const
+{
+ Q_D(const QFxTextInput);
+ return d->focusOnPress;
+}
+
+void QFxTextInput::setFocusOnPress(bool b)
+{
+ Q_D(QFxTextInput);
+ d->focusOnPress = b;
+}
+
+/*!
+ \qmlproperty QValidator* TextInput::validator
+
+ Allows you to set a QValidator on the TextInput. When a validator is set
+ the TextInput will only accept input which leaves the text property in
+ an acceptable or intermediate state. The accepted signal will only be sent
+ if the text is in an acceptable state when enter is pressed.
+
+ \sa acceptableInput, inputMask
+*/
QValidator* QFxTextInput::validator() const
{
Q_D(const QFxTextInput);
@@ -357,6 +406,15 @@ void QFxTextInput::setValidator(QValidator* v)
}
}
+/*!
+ \qmlproperty string TextInput::inputMask
+
+ Allows you to set an input mask on the TextInput, restricting the allowable
+ text inputs. See QLineEdit::inputMask for further details, as the exact
+ same mask strings are used by TextInput.
+
+ \sa acceptableInput, validator
+*/
QString QFxTextInput::inputMask() const
{
Q_D(const QFxTextInput);
@@ -369,22 +427,40 @@ void QFxTextInput::setInputMask(const QString &im)
d->control->setInputMask(im);
}
+/*!
+ \qmlproperty bool TextInput::acceptableInput
+
+ This property is always true unless a validator or input mask has been set.
+ If a validator or input mask has been set, this property will only be true
+ if the current text is acceptable to the validator or input mask as a final
+ string (not as an intermediate string).
+*/
bool QFxTextInput::hasAcceptableInput() const
{
Q_D(const QFxTextInput);
return d->control->hasAcceptableInput();
}
-uint QFxTextInput::echoMode() const
+/*!
+ \qmlproperty TextInput.EchoMode TextInput::echoMode
+
+ Specifies how the text should be displayed in the TextInput.
+ The default is Normal, which displays the text as it is. Other values
+ are Password, which displays asterixes instead of characters, NoEcho,
+ which displays nothing, and PasswordEchoOnEdit, which displays all but the
+ current character as asterixes.
+
+*/
+QFxTextInput::EchoMode QFxTextInput::echoMode() const
{
Q_D(const QFxTextInput);
- return d->control->echoMode();
+ return (QFxTextInput::EchoMode)d->control->echoMode();
}
-void QFxTextInput::setEchoMode(uint echo)
+void QFxTextInput::setEchoMode(QFxTextInput::EchoMode echo)
{
Q_D(QFxTextInput);
- d->control->setEchoMode(echo);
+ d->control->setEchoMode((uint)echo);
}
/*!
@@ -431,7 +507,7 @@ void QFxTextInputPrivate::startCreatingCursor()
q->connect(cursorComponent, SIGNAL(statusChanged(int)),
q, SLOT(createCursor()));
}else{//isError
- qWarning() << "You could really use the error checking for QFxTextInput. We'll implement it soon.";
+ qWarning() << "You could really use the error checking for QFxTextInput. We'll implement it soon.";//TODO:better error handling
}
}
@@ -446,7 +522,7 @@ void QFxTextInput::createCursor()
delete d->cursorItem;
d->cursorItem = qobject_cast<QFxItem*>(d->cursorComponent->create());
if(!d->cursorItem){
- qWarning() << "You could really use the error reporting for QFxTextInput. We'll implement it soon.";
+ qWarning() << "You could really use the error reporting for QFxTextInput. We'll implement it soon.";//TODO:better error handling
return;
}
@@ -480,7 +556,14 @@ void QFxTextInput::focusChanged(bool hasFocus)
void QFxTextInput::keyPressEvent(QKeyEvent* ev)
{
Q_D(QFxTextInput);
- d->control->processKeyEvent(ev);
+ if((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
+ || (d->control->cursor() == d->control->text().length()
+ && ev->key() == Qt::Key_Right)){
+ //ignore when moving off the end
+ ev->ignore();
+ }else{
+ d->control->processKeyEvent(ev);
+ }
if (!ev->isAccepted())
QFxPaintedItem::keyPressEvent(ev);
}
@@ -488,11 +571,12 @@ void QFxTextInput::keyPressEvent(QKeyEvent* ev)
void QFxTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxTextInput);
- setFocus(true);//###Should we make 'focusOnPress' be optional like TextEdit?
- setCursorVisible(true);
- d->focused = true;
+ if(d->focusOnPress){
+ setFocus(true);
+ setCursorVisible(true);
+ d->focused = true;
+ }
d->control->processEvent(event);
- //event->accept();
}
bool QFxTextInput::event(QEvent* ev)
@@ -500,6 +584,7 @@ bool QFxTextInput::event(QEvent* ev)
Q_D(QFxTextInput);
//Anything we don't deal with ourselves, pass to the control
switch(ev->type()){
+ case QEvent::KeyPress:
case QEvent::GraphicsSceneMousePress:
break;
default:
@@ -645,7 +730,8 @@ void QFxTextInput::updateSize()
setImplicitHeight(d->control->height());
//d->control->width() is max width, not current width
QFontMetrics fm = QFontMetrics(d->font);
- setImplicitWidth(fm.boundingRect(d->control->text()).width()+1);
+ setImplicitWidth(fm.width(d->control->text())+1);
+ //setImplicitWidth(d->control->naturalWidth());//### This fn should be coming into 4.6 shortly, and might be faster
setContentsSize(QSize(width(), height()));
}
diff --git a/src/declarative/fx/qfxtextinput.h b/src/declarative/fx/qfxtextinput.h
index 1dca945..4fa4100 100644
--- a/src/declarative/fx/qfxtextinput.h
+++ b/src/declarative/fx/qfxtextinput.h
@@ -59,11 +59,12 @@ class Q_DECLARATIVE_EXPORT QFxTextInput : public QFxPaintedItem
{
Q_OBJECT
Q_ENUMS(HAlignment)
+ Q_ENUMS(EchoMode)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QColor color READ color WRITE setColor)
- Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) //### selectionColor
- Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) //### selectedTextColor
+ Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor)
+ Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign)
@@ -79,13 +80,20 @@ class Q_DECLARATIVE_EXPORT QFxTextInput : public QFxPaintedItem
Q_PROPERTY(QValidator* validator READ validator WRITE setValidator)
Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask)
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
- Q_PROPERTY(uint echoMode READ echoMode WRITE setEchoMode) //### enum
- //### Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress)
+ Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode)
+ Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress)
public:
QFxTextInput(QFxItem* parent=0);
~QFxTextInput();
+ enum EchoMode {//To match QLineEdit::EchoMode
+ Normal,
+ NoEcho,
+ Password,
+ PasswordEchoOnEdit
+ };
+
enum HAlignment {
AlignLeft = Qt::AlignLeft,
AlignRight = Qt::AlignRight,
@@ -105,11 +113,11 @@ public:
QColor color() const;
void setColor(const QColor &c);
- QColor highlightColor() const;
- void setHighlightColor(const QColor &c);
+ QColor selectionColor() const;
+ void setSelectionColor(const QColor &c);
- QColor highlightedTextColor() const;
- void setHighlightedTextColor(const QColor &c);
+ QColor selectedTextColor() const;
+ void setSelectedTextColor(const QColor &c);
HAlignment hAlign() const;
void setHAlign(HAlignment align);
@@ -140,12 +148,15 @@ public:
QString inputMask() const;
void setInputMask(const QString &im);
- uint echoMode() const;
- void setEchoMode(uint echo);
+ EchoMode echoMode() const;
+ void setEchoMode(EchoMode echo);
QmlComponent* cursorDelegate() const;
void setCursorDelegate(QmlComponent*);
+ bool focusOnPress() const;
+ void setFocusOnPress(bool);
+
bool hasAcceptableInput() const;
void drawContents(QPainter *p,const QRect &r);
diff --git a/src/declarative/fx/qfxtextinput_p.h b/src/declarative/fx/qfxtextinput_p.h
index b533854..a2b45bb 100644
--- a/src/declarative/fx/qfxtextinput_p.h
+++ b/src/declarative/fx/qfxtextinput_p.h
@@ -66,7 +66,8 @@ public:
QFxTextInputPrivate() : control(new QLineControl(QString())),
color((QRgb)0), style(QFxText::Normal),
styleColor((QRgb)0), hAlign(QFxTextInput::AlignLeft),
- hscroll(0), oldScroll(0), focused(false), cursorVisible(false)
+ hscroll(0), oldScroll(0), focused(false), focusOnPress(true),
+ cursorVisible(false)
{
}
@@ -82,8 +83,8 @@ public:
QFont font;
QColor color;
- QColor highlightColor;
- QColor highlightedTextColor;
+ QColor selectionColor;
+ QColor selectedTextColor;
QFxText::TextStyle style;
QColor styleColor;
QFxTextInput::HAlignment hAlign;
@@ -98,6 +99,7 @@ public:
int hscroll;
int oldScroll;
bool focused;
+ bool focusOnPress;
bool cursorVisible;
};
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index 82bec09..81fbafa 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -50,6 +50,7 @@
#include "private/qmetaobjectbuilder_p.h"
#include "qmlopenmetaobject.h"
#include "qmllistaccessor.h"
+#include "qmlinfo.h"
#include "qfxvisualitemmodel.h"
#include "private/qguard_p.h"
#include <QtCore/qdebug.h>
@@ -243,6 +244,16 @@ public:
QmlContext *m_context;
QList<int> m_roles;
QHash<int,QString> m_roleNames;
+ void ensureRoles() {
+ if (m_roles.isEmpty()) {
+ if (m_listModelInterface) {
+ m_roles = m_listModelInterface->roles();
+ for (int ii = 0; ii < m_roles.count(); ++ii)
+ m_roleNames.insert(m_roles.at(ii),
+ m_listModelInterface->toString(m_roles.at(ii)));
+ }
+ }
+ }
struct ObjectRef {
ObjectRef(QObject *object=0) : obj(object), ref(1) {}
@@ -375,6 +386,7 @@ int QFxVisualDataModelDataMetaObject::createProperty(const char *name, const cha
return QmlOpenMetaObject::createProperty(name, type);
} else {
const QLatin1String sname(name);
+ data->m_model->ensureRoles();
for (QHash<int, QString>::ConstIterator iter = data->m_model->m_roleNames.begin();
iter != data->m_model->m_roleNames.end(); ++iter) {
@@ -397,6 +409,7 @@ QFxVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro
&& data->m_model->m_modelList) {
return data->m_model->m_modelList->at(data->m_index);
} else if (data->m_model->m_listModelInterface) {
+ data->m_model->ensureRoles();
for (QHash<int, QString>::ConstIterator iter = data->m_model->m_roleNames.begin();
iter != data->m_model->m_roleNames.end(); ++iter) {
@@ -410,6 +423,7 @@ QFxVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro
}
}
} else if (data->m_model->m_abstractItemModel) {
+ data->m_model->ensureRoles();
for (QHash<int, QString>::ConstIterator iter = data->m_model->m_roleNames.begin();
iter != data->m_model->m_roleNames.end(); ++iter) {
@@ -560,12 +574,6 @@ void QFxVisualDataModel::setModel(const QVariant &model)
if (object && (d->m_listModelInterface = qobject_cast<QListModelInterface *>(object))) {
d->m_roles.clear();
d->m_roleNames.clear();
- if (d->m_listModelInterface) {
- d->m_roles = d->m_listModelInterface->roles();
- for (int ii = 0; ii < d->m_roles.count(); ++ii)
- d->m_roleNames.insert(d->m_roles.at(ii),
- d->m_listModelInterface->toString(d->m_roles.at(ii)));
- }
QObject::connect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList<int>)),
this, SLOT(_q_itemsChanged(int,int,QList<int>)));
@@ -688,7 +696,8 @@ QFxVisualDataModel::ReleaseFlags QFxVisualDataModel::release(QFxItem *item)
if (inPackage)
emit destroyingPackage(qobject_cast<QmlPackage*>(obj));
stat |= Destroyed;
- delete obj;
+ obj->setParent(0);
+ obj->deleteLater();
} else if (!inPackage) {
stat |= Referenced;
}
@@ -742,9 +751,14 @@ QFxItem *QFxVisualDataModel::item(int index, const QByteArray &viewId, bool comp
if (package) {
QObject *o = package->part(QLatin1String(viewId));
item = qobject_cast<QFxItem *>(o);
- d->m_packaged.insertMulti(item, package);
+ if (item)
+ d->m_packaged.insertMulti(item, package);
}
}
+ if (!item) {
+ d->m_cache.releaseItem(nobj);
+ qmlInfo(d->m_delegate) << "Delegate component must be Item type.";
+ }
return item;
}
@@ -909,6 +923,22 @@ void QFxVisualDataModel::_q_itemsMoved(int from, int to, int count)
++iter;
}
}
+ for (QHash<int,QFxVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin();
+ iter != d->m_cache.end(); ) {
+
+ if (iter.key() >= qMin(from,to) && iter.key() < qMax(from+count,to+count)) {
+ QFxVisualDataModelPrivate::ObjectRef objRef = *iter;
+ int index = iter.key() + from - to;
+ iter = d->m_cache.erase(iter);
+
+ items.insert(index, objRef);
+
+ QFxVisualDataModelData *data = d->data(objRef.obj);
+ data->setIndex(index);
+ } else {
+ ++iter;
+ }
+ }
d->m_cache.unite(items);
emit itemsMoved(from, to, count);
diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g
index b0ef866..4ed75e8 100644
--- a/src/declarative/qml/parser/qmljs.g
+++ b/src/declarative/qml/parser/qmljs.g
@@ -80,6 +80,7 @@
%token T_DEBUGGER "debugger"
%token T_RESERVED_WORD "reserved word"
%token T_MULTILINE_STRING_LITERAL "multiline string literal"
+%token T_COMMENT "comment"
--- context keywords.
%token T_PUBLIC "public"
diff --git a/src/declarative/qml/parser/qmljsastfwd_p.h b/src/declarative/qml/parser/qmljsastfwd_p.h
index f79cfc2..a6fee1d 100644
--- a/src/declarative/qml/parser/qmljsastfwd_p.h
+++ b/src/declarative/qml/parser/qmljsastfwd_p.h
@@ -62,9 +62,9 @@ namespace QmlJS { namespace AST {
class SourceLocation
{
public:
- SourceLocation(quint32 offset = 0, quint32 length = 0)
+ SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
: offset(offset), length(length),
- startLine(0), startColumn(0)
+ startLine(line), startColumn(column)
{ }
bool isValid() const { return length != 0; }
diff --git a/src/declarative/qml/parser/qmljsengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp
index 02d9b9c..eab8944 100644
--- a/src/declarative/qml/parser/qmljsengine_p.cpp
+++ b/src/declarative/qml/parser/qmljsengine_p.cpp
@@ -178,6 +178,12 @@ Engine::~Engine()
QSet<NameId> Engine::literals() const
{ return _literals; }
+void Engine::addComment(int pos, int len, int line, int col)
+{ if (len > 0) _comments.append(QmlJS::AST::SourceLocation(pos, len, line, col)); }
+
+QList<QmlJS::AST::SourceLocation> Engine::comments() const
+{ return _comments; }
+
NameId *Engine::intern(const QChar *u, int s)
{ return const_cast<NameId *>(&*_literals.insert(NameId(u, s))); }
diff --git a/src/declarative/qml/parser/qmljsengine_p.h b/src/declarative/qml/parser/qmljsengine_p.h
index 5aea983..877fff2 100644
--- a/src/declarative/qml/parser/qmljsengine_p.h
+++ b/src/declarative/qml/parser/qmljsengine_p.h
@@ -143,6 +143,7 @@ class Engine
Lexer *_lexer;
NodePool *_nodePool;
QSet<NameId> _literals;
+ QList<QmlJS::AST::SourceLocation> _comments;
public:
Engine();
@@ -150,6 +151,9 @@ public:
QSet<NameId> literals() const;
+ void addComment(int pos, int len, int line, int col);
+ QList<QmlJS::AST::SourceLocation> comments() const;
+
NameId *intern(const QChar *u, int s);
static QString toString(NameId *id);
diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp
index 9da6ec0..f302733 100644
--- a/src/declarative/qml/parser/qmljslexer.cpp
+++ b/src/declarative/qml/parser/qmljslexer.cpp
@@ -71,7 +71,7 @@ extern double integerFromString(const char *buf, int size, int radix);
using namespace QmlJS;
-Lexer::Lexer(Engine *eng)
+Lexer::Lexer(Engine *eng, bool tokenizeComments)
: driver(eng),
yylineno(0),
done(false),
@@ -94,7 +94,8 @@ Lexer::Lexer(Engine *eng)
check_reserved(true),
parenthesesState(IgnoreParentheses),
parenthesesCount(0),
- prohibitAutomaticSemicolon(false)
+ prohibitAutomaticSemicolon(false),
+ tokenizeComments(tokenizeComments)
{
driver->setLexer(this);
// allocate space for read buffers
@@ -647,22 +648,28 @@ int Lexer::lex()
setDone(Other);
} else
state = Start;
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (current == 0) {
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
setDone(Eof);
}
+
break;
case InMultiLineComment:
if (current == 0) {
setDone(Bad);
err = UnclosedComment;
errmsg = QLatin1String("Unclosed comment at end of file");
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
} else if (current == '*' && next1 == '/') {
state = Start;
shift(1);
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
}
+
break;
case InIdentifier:
if (isIdentLetter(current) || isDecimalDigit(current)) {
diff --git a/src/declarative/qml/parser/qmljslexer_p.h b/src/declarative/qml/parser/qmljslexer_p.h
index 5817868..6cca45d 100644
--- a/src/declarative/qml/parser/qmljslexer_p.h
+++ b/src/declarative/qml/parser/qmljslexer_p.h
@@ -67,7 +67,7 @@ class NameId;
class Lexer
{
public:
- Lexer(Engine *eng);
+ Lexer(Engine *eng, bool tokenizeComments = false);
~Lexer();
void setCode(const QString &c, int lineno);
@@ -239,6 +239,7 @@ private:
ParenthesesState parenthesesState;
int parenthesesCount;
bool prohibitAutomaticSemicolon;
+ bool tokenizeComments;
};
} // namespace QmlJS
diff --git a/src/declarative/qml/qmetaobjectbuilder_p.h b/src/declarative/qml/qmetaobjectbuilder_p.h
index 18277aa..fc26c11 100644
--- a/src/declarative/qml/qmetaobjectbuilder_p.h
+++ b/src/declarative/qml/qmetaobjectbuilder_p.h
@@ -68,7 +68,7 @@ class QMetaPropertyBuilderPrivate;
class QMetaEnumBuilder;
class QMetaEnumBuilderPrivate;
-class Q_CORE_EXPORT QMetaObjectBuilder
+class Q_DECLARATIVE_EXPORT QMetaObjectBuilder
{
public:
enum AddMember
@@ -193,7 +193,7 @@ private:
friend class QMetaEnumBuilder;
};
-class Q_CORE_EXPORT QMetaMethodBuilder
+class Q_DECLARATIVE_EXPORT QMetaMethodBuilder
{
public:
QMetaMethodBuilder() : _mobj(0), _index(0) {}
@@ -231,7 +231,7 @@ private:
QMetaMethodBuilderPrivate *d_func() const;
};
-class Q_CORE_EXPORT QMetaPropertyBuilder
+class Q_DECLARATIVE_EXPORT QMetaPropertyBuilder
{
public:
QMetaPropertyBuilder() : _mobj(0), _index(0) {}
@@ -282,7 +282,7 @@ private:
QMetaPropertyBuilderPrivate *d_func() const;
};
-class Q_CORE_EXPORT QMetaEnumBuilder
+class Q_DECLARATIVE_EXPORT QMetaEnumBuilder
{
public:
QMetaEnumBuilder() : _mobj(0), _index(0) {}
diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp
index 39851ff..f9c9561 100644
--- a/src/declarative/qml/qmlbinding.cpp
+++ b/src/declarative/qml/qmlbinding.cpp
@@ -126,10 +126,6 @@ void QmlBinding::update()
value = con(value.toString());
}
- if (d->property.propertyType() == QVariant::Url &&
- (value.type() == QVariant::String || value.type() == QVariant::ByteArray) && !value.isNull())
- value.setValue(context()->resolvedUrl(QUrl(value.toString())));
-
if (d->property.propertyType() == QVariant::Vector3D &&
value.type() == QVariant::String) {
value = qVariantFromValue(QmlStringConverters::vector3DFromString(value.toString()));
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index b8e9d47..f02dad5 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -761,12 +761,13 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
// Compile custom parser parts
if (isCustomParser && !customProps.isEmpty()) {
- // ### Check for failure
- bool ok = false;
QmlCustomParser *cp = output->types.at(obj->type).type->customParser();
- obj->custom = cp->compile(customProps, &ok);
- if(!ok)
- COMPILE_EXCEPTION(obj, "Failure compiling custom type");
+ cp->clearErrors();
+ obj->custom = cp->compile(customProps);
+ foreach (QmlError err, cp->errors()) {
+ err.setUrl(output->url);
+ exceptions << err;
+ }
}
return true;
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index f291ac0..1c35606 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -91,8 +91,8 @@ Item {
height: 10
}
}
- ComponentInstance { component: RedSquare }
- ComponentInstance { component: RedSquare; x: 20 }
+ Loader { sourceComponent: RedSquare }
+ Loader { sourceComponent: RedSquare; x: 20 }
}
\endqml
*/
@@ -328,6 +328,7 @@ QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledData *cc, int start, in
d->start = start;
d->count = count;
d->url = cc->url;
+ d->progress = 1.0;
}
/*!
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
index bcfbcc8..a99cff0 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -87,6 +87,7 @@ QmlComponent *QmlCompositeTypeData::toComponent(QmlEngine *engine)
QmlCompiledData *cc = toCompiledComponent(engine);
if (cc) {
component = new QmlComponent(engine, cc, -1, -1, 0);
+ cc->release();
} else {
component = new QmlComponent(engine, 0);
component->d_func()->url = imports.baseUrl();
diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp
index b543978..dbcbeb1 100644
--- a/src/declarative/qml/qmlcustomparser.cpp
+++ b/src/declarative/qml/qmlcustomparser.cpp
@@ -70,7 +70,7 @@ using namespace QmlParser;
*/
/*
- \fn QByteArray QmlCustomParser::compile(QXmlStreamReader& reader, bool *ok)
+ \fn QByteArray QmlCustomParser::compile(QXmlStreamReader& reader)
Upon entry to this function, \a reader is positioned on a
QXmlStreamReader::StartElement with the name specified when the
@@ -80,7 +80,7 @@ using namespace QmlParser;
EndElement matching the initial start element is reached, or until
error.
- On return, \c *ok indicates success.
+ Errors must be reported via the error() functions.
The returned QByteArray contains data meaningful only to the
custom parser; the type engine will pass this same data to
@@ -109,6 +109,7 @@ QmlCustomParserNodePrivate::fromObject(QmlParser::Object *root)
{
QmlCustomParserNode rootNode;
rootNode.d->name = root->typeName;
+ rootNode.d->location = root->location.start;
for(QHash<QByteArray, Property *>::Iterator iter = root->properties.begin();
iter != root->properties.end();
@@ -128,6 +129,7 @@ QmlCustomParserNodePrivate::fromProperty(QmlParser::Property *p)
QmlCustomParserProperty prop;
prop.d->name = p->name;
prop.d->isList = (p->values.count() > 1);
+ prop.d->location = p->location.start;
if (p->value) {
QmlCustomParserNode node = fromObject(p->value);
@@ -167,6 +169,7 @@ QmlCustomParserNode &QmlCustomParserNode::operator=(const QmlCustomParserNode &o
{
d->name = other.d->name;
d->properties = other.d->properties;
+ d->location = other.d->location;
return *this;
}
@@ -185,6 +188,11 @@ QList<QmlCustomParserProperty> QmlCustomParserNode::properties() const
return d->properties;
}
+QmlParser::Location QmlCustomParserNode::location() const
+{
+ return d->location;
+}
+
QmlCustomParserProperty::QmlCustomParserProperty()
: d(new QmlCustomParserPropertyPrivate)
{
@@ -201,6 +209,7 @@ QmlCustomParserProperty &QmlCustomParserProperty::operator=(const QmlCustomParse
d->name = other.d->name;
d->isList = other.d->isList;
d->values = other.d->values;
+ d->location = other.d->location;
return *this;
}
@@ -219,19 +228,49 @@ bool QmlCustomParserProperty::isList() const
return d->isList;
}
+QmlParser::Location QmlCustomParserProperty::location() const
+{
+ return d->location;
+}
+
QList<QVariant> QmlCustomParserProperty::assignedValues() const
{
return d->values;
}
-QByteArray QmlCustomParser::compile(const QList<QmlCustomParserProperty> &, bool *ok)
+void QmlCustomParser::clearErrors()
{
- Q_UNUSED(ok);
- return QByteArray();
+ exceptions.clear();
}
-void QmlCustomParser::setCustomData(QObject *, const QByteArray &)
+/*!
+ Reports an error in parsing \a prop, with the given \a description.
+
+ An error is generated referring to the position of \a node in the source file.
+*/
+void QmlCustomParser::error(const QmlCustomParserProperty& prop, const QString& description)
+{
+ QmlError error;
+ QString exceptionDescription;
+ error.setLine(prop.location().line);
+ error.setColumn(prop.location().column);
+ error.setDescription(description);
+ exceptions << error;
+}
+
+/*!
+ Reports an error in parsing \a node, with the given \a description.
+
+ An error is generated referring to the position of \a node in the source file.
+*/
+void QmlCustomParser::error(const QmlCustomParserNode& node, const QString& description)
{
+ QmlError error;
+ QString exceptionDescription;
+ error.setLine(node.location().line);
+ error.setColumn(node.location().column);
+ error.setDescription(description);
+ exceptions << error;
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h
index 74bd15c..5be0680 100644
--- a/src/declarative/qml/qmlcustomparser_p.h
+++ b/src/declarative/qml/qmlcustomparser_p.h
@@ -57,6 +57,8 @@
#include <QtCore/qxmlstream.h>
#include <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qmlmetatype.h>
+#include <QtDeclarative/qmlerror.h>
+#include <private/qmlparser_p.h>
QT_BEGIN_HEADER
@@ -74,6 +76,7 @@ public:
~QmlCustomParserProperty();
QByteArray name() const;
+ QmlParser::Location location() const;
bool isList() const;
// Will be one of QmlParser::Variant, QmlCustomParserProperty or
@@ -96,6 +99,7 @@ public:
~QmlCustomParserNode();
QByteArray name() const;
+ QmlParser::Location location() const;
QList<QmlCustomParserProperty> properties() const;
@@ -109,8 +113,19 @@ class Q_DECLARATIVE_EXPORT QmlCustomParser
public:
virtual ~QmlCustomParser() {}
- virtual QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok);
- virtual void setCustomData(QObject *, const QByteArray &);
+ void clearErrors();
+
+ virtual QByteArray compile(const QList<QmlCustomParserProperty> &)=0;
+ virtual void setCustomData(QObject *, const QByteArray &)=0;
+
+ QList<QmlError> errors() const { return exceptions; }
+
+protected:
+ void error(const QmlCustomParserProperty&, const QString& description);
+ void error(const QmlCustomParserNode&, const QString& description);
+
+private:
+ QList<QmlError> exceptions;
};
#define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, NAME, TYPE, CUSTOMTYPE) \
template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN_FROM), (VERSION_MAJ_TO)>::instance(qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, #NAME, #TYPE, new CUSTOMTYPE));
diff --git a/src/declarative/qml/qmlcustomparser_p_p.h b/src/declarative/qml/qmlcustomparser_p_p.h
index 0011c3b..25023d3 100644
--- a/src/declarative/qml/qmlcustomparser_p_p.h
+++ b/src/declarative/qml/qmlcustomparser_p_p.h
@@ -55,20 +55,16 @@
#include <QtCore/qglobal.h>
#include "qmlcustomparser_p.h"
+#include "qmlparser_p.h"
QT_BEGIN_NAMESPACE
-namespace QmlParser
-{
- class Object;
- class Property;
-};
-
class QmlCustomParserNodePrivate
{
public:
QByteArray name;
QList<QmlCustomParserProperty> properties;
+ QmlParser::Location location;
static QmlCustomParserNode fromObject(QmlParser::Object *);
static QmlCustomParserProperty fromProperty(QmlParser::Property *);
@@ -82,6 +78,7 @@ public:
QByteArray name;
bool isList;
+ QmlParser::Location location;
QList<QVariant> values;
};
diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp
index 321fe74..7f9e530 100644
--- a/src/declarative/qml/qmlenginedebug.cpp
+++ b/src/declarative/qml/qmlenginedebug.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qmlenginedebug_p.h"
+#include "qmlboundsignal_p.h"
#include <QtCore/qdebug.h>
#include <QtCore/qmetaobject.h>
#include <QtDeclarative/qmlengine.h>
@@ -103,7 +104,11 @@ QmlEngineDebugServer::propertyData(QObject *obj, int propIdx)
if (prop.type() < QVariant::UserType) {
rv.type = QmlObjectProperty::Basic;
- rv.value = prop.read(obj);
+ if (qobject_cast<QmlBoundSignalParameters*>(obj) && prop.name() != QByteArray("objectName"))
+ // these "properties" only have meaning during signal emission
+ rv.value = tr("(signal parameter)");
+ else
+ rv.value = prop.read(obj);
} else if (QmlMetaType::isObject(prop.userType())) {
rv.type = QmlObjectProperty::Object;
} else if (QmlMetaType::isList(prop.userType()) ||
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index fdba79e..b305619 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -874,6 +874,30 @@ void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value)
}
break;
+ case QVariant::Url:
+ {
+ QUrl u;
+ if (vt == QVariant::ByteArray) {
+ u = QUrl(QLatin1String(value.toByteArray()));
+ found = true;
+ } else if (vt == QVariant::String) {
+ u = QUrl(value.toString());
+ found = true;
+ }
+
+ if (found) {
+ if (context && u.isRelative() && !u.isEmpty())
+ u = context->baseUrl().resolved(u);
+ void *a[1];
+ a[0] = &u;
+ QMetaObject::metacall(object,
+ QMetaObject::WriteProperty,
+ coreIdx, a);
+ }
+
+ }
+ break;
+
default:
{
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index ac89d28..14d85ff 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -197,6 +197,7 @@ QmlType::QmlType(int type, int listType, int qmlListType,
QmlType::~QmlType()
{
+ delete d->m_customParser;
delete d;
}
diff --git a/src/declarative/qml/qmlrewrite.cpp b/src/declarative/qml/qmlrewrite.cpp
index 3f35160..5166c96 100644
--- a/src/declarative/qml/qmlrewrite.cpp
+++ b/src/declarative/qml/qmlrewrite.cpp
@@ -73,8 +73,8 @@ QString RewriteBinding::rewrite(QString code, unsigned position,
unsigned startOfStatement = node->firstSourceLocation().begin() - _position;
unsigned endOfStatement = node->lastSourceLocation().end() - _position;
- _writer->replace(startOfStatement, 0, QLatin1String("(function() {\n"));
- _writer->replace(endOfStatement, 0, QLatin1String("\n})"));
+ _writer->replace(startOfStatement, 0, QLatin1String("(function() { "));
+ _writer->replace(endOfStatement, 0, QLatin1String(" })"));
w.write(&code);
diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp
index 90f639e..739e480 100644
--- a/src/declarative/util/qfxperf.cpp
+++ b/src/declarative/util/qfxperf.cpp
@@ -58,7 +58,6 @@ Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") {
Q_DEFINE_PERFORMANCE_METRIC(CreateParticle, " QFxParticles: Particle creation")
Q_DEFINE_PERFORMANCE_METRIC(ItemComponentComplete, " QFxItem::componentComplete")
Q_DEFINE_PERFORMANCE_METRIC(ImageComponentComplete, " QFxImage::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(ComponentInstanceComponentComplete, " QFxComponentInstance::componentComplete")
Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QFxBasePositioner::componentComplete")
Q_DEFINE_PERFORMANCE_METRIC(TextComponentComplete, " QFxText::componentComplete")
Q_DEFINE_PERFORMANCE_METRIC(QFxText_setText, " QFxText::setText")
diff --git a/src/declarative/util/qfxperf_p.h b/src/declarative/util/qfxperf_p.h
index a1e38b7..cea7e80 100644
--- a/src/declarative/util/qfxperf_p.h
+++ b/src/declarative/util/qfxperf_p.h
@@ -77,7 +77,6 @@ Q_DECLARE_PERFORMANCE_LOG(QFxPerf) {
Q_DECLARE_PERFORMANCE_METRIC(CreateParticle)
Q_DECLARE_PERFORMANCE_METRIC(ItemComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(ImageComponentComplete)
- Q_DECLARE_PERFORMANCE_METRIC(ComponentInstanceComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(BaseLayoutComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(TextComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(QFxText_setText)
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index 9291e1a..2a38cda 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -222,7 +222,7 @@ void QFxView::execute()
if (d->qml.isEmpty()) {
d->component = new QmlComponent(&d->engine, d->source, this);
} else {
- d->component = new QmlComponent(&d->engine, d->qml.toUtf8(), d->source);
+ d->component = new QmlComponent(&d->engine, d->qml.toUtf8(), d->source, this);
}
if (!d->component->isLoading()) {
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 6047d4a..3edbc5f 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -1442,8 +1442,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,ParallelAnimation,QmlParallelAni
void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
{
if (variant.type() != QVariant::String) {
- if ((uint)type < QVariant::UserType)
- variant.convert((QVariant::Type)type);
+ variant.convert((QVariant::Type)type);
return;
}
diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp
new file mode 100644
index 0000000..b58ad14
--- /dev/null
+++ b/src/declarative/util/qmleasefollow.cpp
@@ -0,0 +1,415 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmleasefollow.h"
+#include <QtDeclarative/qmlmetaproperty.h>
+#include <math.h>
+#include <QtCore/qdebug.h>
+#include <private/qmlanimation_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,EaseFollow,QmlEaseFollow);
+
+class QmlEaseFollowPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QmlEaseFollow)
+public:
+ QmlEaseFollowPrivate()
+ : source(0), velocity(200), duration(-1),
+ reversingMode(QmlEaseFollow::Eased), initialVelocity(0),
+ initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0),
+ lastTick(0), clock(this)
+ {}
+
+ qreal source;
+ qreal velocity;
+ qreal duration;
+ QmlEaseFollow::ReversingMode reversingMode;
+
+ qreal initialVelocity;
+ qreal initialValue;
+ bool invert;
+ bool enabled;
+
+ qreal trackVelocity;
+
+ QmlMetaProperty target;
+
+ int clockOffset;
+ int lastTick;
+ void tick(int);
+ void clockStart();
+ void clockStop();
+ QTickAnimationProxy<QmlEaseFollowPrivate, &QmlEaseFollowPrivate::tick> clock;
+
+ void restart();
+
+ // Parameters for use in tick()
+ qreal a; // Acceleration
+ qreal tf; // Total time
+ qreal tp; // Time at which peak velocity occurs
+ qreal vp; // Velocity at tp
+ qreal sp; // Displacement at tp
+ qreal vi; // "Normalized" initialvelocity
+ bool recalc();
+};
+
+bool QmlEaseFollowPrivate::recalc()
+{
+ qreal s = source - initialValue;
+ vi = initialVelocity;
+
+ s = (invert?-1.0:1.0) * s;
+ vi = (invert?-1.0:1.0) * vi;
+
+ if (duration > 0 && velocity > 0) {
+ tf = s / velocity;
+ if (tf > (duration / 1000.)) tf = (duration / 1000.);
+ } else if (duration > 0) {
+ tf = duration / 1000.;
+ } else if (velocity > 0) {
+ tf = s / velocity;
+ } else {
+ return false;
+ }
+
+ qreal c1 = 0.25 * tf * tf;
+ qreal c2 = 0.5 * vi * tf - s;
+ qreal c3 = -0.25 * vi * vi;
+
+ qreal a1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
+ // qreal a2 = (-c2 - sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
+
+ qreal tp1 = 0.5 * tf - 0.5 * vi / a1;
+ // qreal tp2 = 0.5 * tf - 0.5 * vi / a2;
+ qreal vp1 = a1 * tp1 + vi;
+ // qreal vp2 = a2 * tp2 + vi;
+
+ qreal sp1 = 0.5 * a1 * tp1 * tp1 + vi * tp1;
+ // qreal sp2 = 0.5 * a2 * tp2 * tp2 + vi * tp2;
+
+ a = a1;
+ tp = tp1;
+ vp = vp1;
+ sp = sp1;
+
+ return true;
+}
+
+void QmlEaseFollowPrivate::clockStart()
+{
+ if (clock.state() == QAbstractAnimation::Running) {
+ clockOffset = lastTick;
+ return;
+ } else {
+ clockOffset = 0;
+ lastTick = 0;
+ clock.start();
+ }
+}
+
+void QmlEaseFollowPrivate::clockStop()
+{
+ clockOffset = 0;
+ lastTick = 0;
+ clock.stop();
+}
+
+void QmlEaseFollowPrivate::tick(int t)
+{
+ lastTick = t;
+ t -= clockOffset;
+
+ qreal time_seconds = qreal(t) / 1000.;
+
+ if (time_seconds < tp) {
+
+ trackVelocity = vi + time_seconds * a;
+ trackVelocity = (invert?-1.0:1.0) * trackVelocity;
+
+ qreal value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds;
+ value = (invert?-1.0:1.0) * value;
+ target.write(initialValue + value);
+
+ } else if (time_seconds < tf) {
+
+ time_seconds -= tp;
+
+ trackVelocity = vp - time_seconds * a;
+ trackVelocity = (invert?-1.0:1.0) * trackVelocity;
+
+ qreal value = 0.5 * a * tp * tp + vi * tp
+ - 0.5 * a * time_seconds * time_seconds + vp * time_seconds;
+ value = (invert?-1.0:1.0) * value;
+
+ target.write(initialValue + value);
+
+ } else {
+
+ clock.stop();
+
+ trackVelocity = 0;
+ target.write(source);
+ }
+}
+
+/*!
+ \qmlclass EaseFollow QmlEaseFollow
+ \brief The EaseFollow element allows a property to smoothly track a value.
+
+ The EaseFollow smoothly animates a property's value to a set target value
+ using an ease in/out quad easing curve. If the target value changes while
+ the animation is in progress, the easing curves used to animate to the old
+ and the new target values are spliced together to avoid any obvious visual
+ glitches.
+
+ The property animation is configured by setting the velocity at which the
+ animation should occur, or the duration that the animation should take.
+ If both a velocity and a duration are specified, the one that results in
+ the quickest animation is chosen for each change in the target value.
+
+ For example, animating from 0 to 800 will take 4 seconds if a velocity
+ of 200 is set, will take 8 seconds with a duration of 8000 set, and will
+ take 4 seconds with both a velocity of 200 and a duration of 8000 set.
+ Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
+ will take 8 seconds with a duration of 8000 set, and will take 8 seconds
+ with both a velocity of 200 and a duration of 8000 set.
+
+ The follow example shows one rectangle tracking the position of another.
+\code
+import Qt 4.6
+
+Rectangle {
+ width: 800; height: 600; color: "blue"
+
+ Rectangle {
+ color: "green"
+ width: 60; height: 60;
+ x: -5; y: -5;
+ x: EaseFollow { source: Rect1.x - 5; velocity: 200 }
+ y: EaseFollow { source: Rect1.y - 5; velocity: 200 }
+ }
+
+ Rectangle {
+ id: Rect1
+ color: "red"
+ width: 50; height: 50;
+ }
+
+ focus: true
+ Keys.onRightPressed: Rect1.x = Rect1.x + 100
+ Keys.onLeftPressed: Rect1.x = Rect1.x - 100
+ Keys.onUpPressed: Rect1.y = Rect1.y - 100
+ Keys.onDownPressed: Rect1.y = Rect1.y + 100
+}
+\endcode
+*/
+
+QmlEaseFollow::QmlEaseFollow(QObject *parent)
+: QObject(*(new QmlEaseFollowPrivate), parent)
+{
+}
+
+QmlEaseFollow::~QmlEaseFollow()
+{
+}
+
+/*!
+ \qmlproperty qreal EaseFollow::source
+ This property holds the source value which will be tracked.
+
+ Bind to a property in order to track its changes.
+*/
+qreal QmlEaseFollow::sourceValue() const
+{
+ Q_D(const QmlEaseFollow);
+ return d->source;
+}
+
+/*!
+ \qmlproperty enumeration EaseFollow::reversingMode
+
+ Sets how the EaseFollow behaves if an animation direction is reversed.
+
+ If reversing mode is \c Eased, the animation will smoothly decelerate, and
+ then reverse direction. If the reversing mode is \c Immediate, the
+ animation will immediately begin accelerating in the reverse direction,
+ begining with a velocity of 0. If the reversing mode is \c Sync, the
+ property is immediately set to the target value.
+*/
+QmlEaseFollow::ReversingMode QmlEaseFollow::reversingMode() const
+{
+ Q_D(const QmlEaseFollow);
+ return d->reversingMode;
+}
+
+void QmlEaseFollow::setReversingMode(ReversingMode m)
+{
+ Q_D(QmlEaseFollow);
+ d->reversingMode = m;
+}
+
+void QmlEaseFollowPrivate::restart()
+{
+ if (!enabled)
+ return;
+
+ initialValue = target.read().toReal();
+
+ if (source == initialValue) {
+ clockStop();
+ return;
+ }
+
+ bool hasReversed = trackVelocity != 0. &&
+ ((trackVelocity > 0) == ((initialValue - source) > 0));
+
+ if (hasReversed) {
+ switch (reversingMode) {
+ default:
+ case QmlEaseFollow::Eased:
+ break;
+ case QmlEaseFollow::Sync:
+ target.write(source);
+ return;
+ case QmlEaseFollow::Immediate:
+ initialVelocity = 0;
+ clockStop();
+ break;
+ }
+ }
+
+ trackVelocity = initialVelocity;
+
+ invert = (source < initialValue);
+
+ if (!recalc()) {
+ target.write(source);
+ clockStop();
+ return;
+ }
+
+ clockStart();
+}
+
+void QmlEaseFollow::setSourceValue(qreal s)
+{
+ Q_D(QmlEaseFollow);
+
+ d->source = s;
+ d->initialVelocity = d->trackVelocity;
+ d->restart();
+}
+
+/*!
+ \qmlproperty qreal EaseFollow::duration
+
+ This property holds the animation duration used when tracking the source.
+
+ Setting this to -1 disables the duration value.
+*/
+qreal QmlEaseFollow::duration() const
+{
+ Q_D(const QmlEaseFollow);
+ return d->duration;
+}
+
+void QmlEaseFollow::setDuration(qreal v)
+{
+ Q_D(QmlEaseFollow);
+ d->duration = v;
+ d->trackVelocity = 0;
+
+ if (d->clock.state() == QAbstractAnimation::Running)
+ d->restart();
+}
+
+qreal QmlEaseFollow::velocity() const
+{
+ Q_D(const QmlEaseFollow);
+ return d->velocity;
+}
+
+/*!
+ \qmlproperty qreal EaseFollow::velocity
+
+ This property holds the average velocity allowed when tracking the source.
+
+ Setting this to -1 disables the velocity value.
+*/
+void QmlEaseFollow::setVelocity(qreal v)
+{
+ Q_D(QmlEaseFollow);
+ d->velocity = v;
+ d->trackVelocity = 0;
+
+ if (d->clock.state() == QAbstractAnimation::Running)
+ d->restart();
+}
+
+/*!
+ \qmlproperty bool EaseFollow::enabled
+ This property holds whether the target will track the source.
+*/
+bool QmlEaseFollow::enabled() const
+{
+ Q_D(const QmlEaseFollow);
+ return d->enabled;
+}
+
+void QmlEaseFollow::setEnabled(bool enabled)
+{
+ Q_D(QmlEaseFollow);
+ d->enabled = enabled;
+ if (enabled)
+ d->restart();
+ else
+ d->clockStop();
+}
+
+void QmlEaseFollow::setTarget(const QmlMetaProperty &t)
+{
+ Q_D(QmlEaseFollow);
+ d->target = t;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/util/qmleasefollow.h
index b223ca2..8e8c59d 100644
--- a/src/declarative/fx/qfxcomponentinstance.h
+++ b/src/declarative/util/qmleasefollow.h
@@ -39,10 +39,12 @@
**
****************************************************************************/
-#ifndef QFXCOMPONENTINSTANCE_H
-#define QFXCOMPONENTINSTANCE_H
+#ifndef QMLEASEFOLLOW_H
+#define QMLEASEFOLLOW_H
-#include <QtDeclarative/qfxitem.h>
+#include <QtCore/qobject.h>
+#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qmlpropertyvaluesource.h>
QT_BEGIN_HEADER
@@ -50,44 +52,50 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-//### remove
-//### add component property to Loader
-
-class QFxComponentInstancePrivate;
-class Q_DECLARATIVE_EXPORT QFxComponentInstance : public QFxItem
+class QmlMetaProperty;
+class QmlEaseFollowPrivate;
+class Q_DECLARATIVE_EXPORT QmlEaseFollow : public QObject,
+ public QmlPropertyValueSource
{
Q_OBJECT
- Q_PROPERTY(QmlComponent *component READ component WRITE setComponent)
- Q_PROPERTY(QFxItem *instance READ instance)
- Q_CLASSINFO("DefaultProperty", "component")
+ Q_DECLARE_PRIVATE(QmlEaseFollow)
+ Q_INTERFACES(QmlPropertyValueSource)
+ Q_ENUMS(ReversingMode)
+
+ Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue)
+ Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
+ Q_PROPERTY(qreal duration READ duration WRITE setDuration)
+ Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
+
public:
- QFxComponentInstance(QFxItem *parent=0);
+ enum ReversingMode { Eased, Immediate, Sync };
- QmlComponent *component() const;
- void setComponent(QmlComponent *);
+ QmlEaseFollow(QObject *parent = 0);
+ ~QmlEaseFollow();
- QFxItem *instance() const;
+ ReversingMode reversingMode() const;
+ void setReversingMode(ReversingMode);
-Q_SIGNALS:
- void instanceChanged();
+ qreal sourceValue() const;
+ void setSourceValue(qreal);
-private Q_SLOTS:
- void updateSize();
+ qreal velocity() const;
+ void setVelocity(qreal);
-private:
- void create();
+ qreal duration() const;
+ void setDuration(qreal);
-protected:
- QFxComponentInstance(QFxComponentInstancePrivate &dd, QFxItem *parent);
+ bool enabled() const;
+ void setEnabled(bool enabled);
-private:
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxComponentInstance)
+ virtual void setTarget(const QmlMetaProperty &);
};
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QFxComponentInstance)
+QML_DECLARE_TYPE(QmlEaseFollow);
QT_END_HEADER
-#endif // QFXCOMPONENTINSTANCE_H
+#endif // QMLEASEFOLLOW_H
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index 0d9ea94..69bed25 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -47,6 +47,7 @@
#include "qmlopenmetaobject.h"
#include <qmlcontext.h>
#include "qmllistmodel.h"
+#include <QtScript/qscriptvalueiterator.h>
Q_DECLARE_METATYPE(QListModelInterface *)
@@ -68,11 +69,15 @@ struct ListModelData
ListInstruction *instructions() const { return (ListInstruction *)((char *)this + sizeof(ListModelData)); }
};
+static void dump(ModelNode *node, int ind);
+
/*!
\qmlclass ListModel
\brief The ListModel element defines a free-form list data source.
- The ListModel is a simple hierarchy of elements containing data roles.
+ The ListModel is a simple hierarchy of elements containing data roles. The contents can
+ be defined dynamically, or explicitly in QML:
+
For example:
\code
@@ -138,7 +143,7 @@ struct ListModelData
name: "Banana"
cost: 1.95
attributes: [
- ListElement { description: "Tropical" }
+ ListElement { description: "Tropical" },
ListElement { description: "Seedless" }
]
}
@@ -166,13 +171,36 @@ struct ListModelData
}
\endcode
+ The content of a ListModel may be created and modified using the clear(),
+ append(), and set() methods. For example:
+
+ \code
+ Component {
+ id: FruitDelegate
+ Item {
+ width: 200; height: 50
+ Text { text: name }
+ Text { text: '$'+cost; anchors.right: parent.right }
+
+ // Double the price when clicked.
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: FruitModel.set(index, "cost", cost*2)
+ }
+ }
+ }
+ \endcode
+
+ When creating content dynamically, note that the set of available properties cannot be changed
+ except by first clearing the model - whatever properties are first added are then the
+ only permitted properties in the model.
*/
class ModelObject : public QObject
{
Q_OBJECT
public:
- ModelObject(ModelNode *);
+ ModelObject();
void setValue(const QByteArray &name, const QVariant &val)
{
@@ -180,8 +208,6 @@ public:
}
private:
- ModelNode *_node;
- bool _haveProperties;
QmlOpenMetaObject *_mo;
};
@@ -189,7 +215,6 @@ struct ModelNode
{
ModelNode();
~ModelNode();
- QString className;
QList<QVariant> values;
QHash<QString, ModelNode *> properties;
@@ -204,7 +229,7 @@ struct ModelNode
ModelObject *object() {
if (!objectCache) {
- objectCache = new ModelObject(this);
+ objectCache = new ModelObject();
QHash<QString, ModelNode *>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
if (!(*it)->values.isEmpty())
@@ -214,12 +239,61 @@ struct ModelNode
return objectCache;
}
+ void setListValue(const QScriptValue& valuelist) {
+ QScriptValueIterator it(valuelist);
+ values.clear();
+ while (it.hasNext()) {
+ it.next();
+ ModelNode *value = new ModelNode;
+ QScriptValue v = it.value();
+ if (v.isArray()) {
+ value->setListValue(v);
+ } else if (v.isObject()) {
+ value->setObjectValue(v);
+ } else {
+ value->values << v.toVariant();
+ }
+ values.append(qVariantFromValue(value));
+
+ }
+ }
+
+ void setObjectValue(const QScriptValue& valuemap) {
+ QScriptValueIterator it(valuemap);
+ while (it.hasNext()) {
+ it.next();
+ ModelNode *value = new ModelNode;
+ QScriptValue v = it.value();
+ if (v.isArray()) {
+ value->setListValue(v);
+ } else if (v.isObject()) {
+ value->setObjectValue(v);
+ } else {
+ value->values << v.toVariant();
+ }
+ properties.insert(it.name(),value);
+ }
+ }
+
+ void setProperty(const QString& prop, const QVariant& val) {
+ QHash<QString, ModelNode *>::const_iterator it = properties.find(prop);
+ if (it != properties.end()) {
+ (*it)->values[0] = val;
+ } else {
+ ModelNode *n = new ModelNode;
+ n->values << val;
+ properties.insert(prop,n);
+ }
+ if (objectCache)
+ objectCache->setValue(prop.toLatin1(), val);
+ }
+
QmlListModel *modelCache;
ModelObject *objectCache;
};
-ModelObject::ModelObject(ModelNode *node)
-: _node(node), _haveProperties(false), _mo(new QmlOpenMetaObject(this))
+ModelObject::ModelObject()
+: _mo(new QmlOpenMetaObject(this))
{
}
@@ -235,7 +309,7 @@ QmlListModel::~QmlListModel()
void QmlListModel::checkRoles() const
{
- if (_rolesOk)
+ if (_rolesOk || !_root)
return;
for (int ii = 0; ii < _root->values.count(); ++ii) {
@@ -341,10 +415,229 @@ int QmlListModel::count() const
return _root->values.count();
}
+/*!
+ \qmlmethod ListModel::clear()
+
+ Deletes all content from the model. The properties are cleared such that
+ different properties may be set on subsequent additions.
+
+ \sa append() remove()
+*/
+void QmlListModel::clear()
+{
+ int cleared = count();
+ _rolesOk = false;
+ delete _root;
+ _root = 0;
+ roleStrings.clear();
+ emit itemsRemoved(0,cleared);
+}
+
+/*!
+ \qmlmethod ListModel::remove(int index)
+
+ Deletes the content at \a index from the model.
+
+ \sa clear()
+*/
+void QmlListModel::remove(int index)
+{
+ if (_root) {
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
+ _root->values.removeAt(index);
+ if (node)
+ delete node;
+ emit itemsRemoved(index,1);
+ }
+}
+
+/*!
+ \qmlmethod ListModel::insert(index,dict)
+
+ Adds a new item to the list model at position \a index, with the
+ values in \a dict.
+
+ \code
+ FruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ The \a index must be to an existing item in the list, or one past
+ the end of the list (equivalent to append).
+
+ \sa set() append()
+*/
+void QmlListModel::insert(int index, const QScriptValue& valuemap)
+{
+ if (!_root)
+ _root = new ModelNode;
+ if (index >= _root->values.count()) {
+ if (index == _root->values.count())
+ append(valuemap);
+ return;
+ }
+ ModelNode *mn = new ModelNode;
+ mn->setObjectValue(valuemap);
+ _root->values.insert(index,qVariantFromValue(mn));
+ emit itemsInserted(index,1);
+}
+
+/*!
+ \qmlmethod ListModel::move(from,to,n)
+
+ Moves \a n items \a from one position \a to another.
+
+ The from and to ranges must exist; for example, to move the first 3 items
+ to the end of the list:
+
+ \code
+ FruitModel.move(0,FruitModel.count-3,3)
+ \endcode
+
+ \sa append()
+*/
+void QmlListModel::move(int from, int to, int n)
+{
+ if (from+n > count() || to+n > count() || n==0 || from==to || from < 0 || to < 0)
+ return;
+ int origfrom=from; // preserve actual move, so any animations are correct
+ int origto=to;
+ int orign=n;
+ if (from > to) {
+ // Only move forwards - flip if backwards moving
+ int tfrom = from;
+ int tto = to;
+ from = tto;
+ to = tto+n;
+ n = tfrom-tto;
+ }
+ if (n==1) {
+ _root->values.move(from,to);
+ } else {
+ QList<QVariant> replaced;
+ int i=0;
+ QVariantList::const_iterator it=_root->values.begin(); it += from+n;
+ for (; i<to-from; ++i,++it)
+ replaced.append(*it);
+ i=0;
+ it=_root->values.begin(); it += from;
+ for (; i<n; ++i,++it)
+ replaced.append(*it);
+ QVariantList::const_iterator f=replaced.begin();
+ QVariantList::iterator t=_root->values.begin(); t += from;
+ for (; f != replaced.end(); ++f, ++t)
+ *t = *f;
+ }
+ emit itemsMoved(origfrom,origto,orign);
+}
+
+/*!
+ \qmlmethod ListModel::append(dict)
+
+ Adds a new item to the end of the list model, with the
+ values in \a dict.
+
+ \code
+ FruitModel.append({"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ \sa set() remove()
+*/
+void QmlListModel::append(const QScriptValue& valuemap)
+{
+ if (!valuemap.isObject()) {
+ qWarning("ListModel::append: value is not an object");
+ return;
+ }
+ if (!_root)
+ _root = new ModelNode;
+ ModelNode *mn = new ModelNode;
+ mn->setObjectValue(valuemap);
+ _root->values << qVariantFromValue(mn);
+ emit itemsInserted(count()-1,1);
+}
+
+/*!
+ \qmlmethod ListModel::set(index,dict)
+
+ Changes the item at \a index in the list model to the
+ values in \a dict.
+
+ \code
+ FruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ The \a index must be an element in the list.
+
+ \sa append()
+*/
+void QmlListModel::set(int index, const QScriptValue& valuemap)
+{
+ if (!_root)
+ _root = new ModelNode;
+ if ( index >= _root->values.count()) {
+ qWarning() << "ListModel::set index out of range:" << index;
+ return;
+ }
+ if (index == _root->values.count())
+ append(valuemap);
+ else {
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
+ QList<int> roles;
+ node->setObjectValue(valuemap);
+ QScriptValueIterator it(valuemap);
+ while (it.hasNext()) {
+ it.next();
+ int r = roleStrings.indexOf(it.name());
+ if (r<0) {
+ r = roleStrings.count();
+ roleStrings << it.name();
+ }
+ roles.append(r);
+ }
+ emit itemsChanged(index,1,roles);
+ }
+}
+
+/*!
+ \qmlmethod ListModel::set(index,property,value)
+
+ Changes the \a property of the item at \a index in the list model to \a value.
+
+ \code
+ FruitModel.set(3, "cost", 5.95)
+ \endcode
+
+ The \a index must be an element in the list.
+
+ \sa append()
+*/
+void QmlListModel::set(int index, const QString& property, const QVariant& value)
+{
+ if (!_root)
+ _root = new ModelNode;
+ if ( index >= _root->values.count()) {
+ qWarning() << "ListModel::set index out of range:" << index;
+ return;
+ }
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
+ int r = roleStrings.indexOf(property);
+ if (r<0) {
+ r = roleStrings.count();
+ roleStrings << property;
+ }
+ QList<int> roles;
+ roles.append(r);
+
+ if (node)
+ node->setProperty(property,value);
+ emit itemsChanged(index,1,roles);
+}
+
+
class QmlListModelParser : public QmlCustomParser
{
public:
- QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok);
+ QByteArray compile(const QList<QmlCustomParserProperty> &);
bool compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data);
void setCustomData(QObject *, const QByteArray &);
};
@@ -369,8 +662,14 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL
QList<QmlCustomParserProperty> props = node.properties();
for(int jj = 0; jj < props.count(); ++jj) {
const QmlCustomParserProperty &nodeProp = props.at(jj);
- if(nodeProp.name() == "")
+ if (nodeProp.name() == "") {
+ error(nodeProp, QLatin1String("Cannot use default property in ListModel"));
return false;
+ }
+ if (nodeProp.name() == "id") {
+ error(nodeProp, QLatin1String("Cannot use reserved \"id\" property in ListModel"));
+ return false;
+ }
ListInstruction li;
int ref = data.count();
@@ -416,21 +715,19 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL
return true;
}
-QByteArray QmlListModelParser::compile(const QList<QmlCustomParserProperty> &customProps, bool *ok)
+QByteArray QmlListModelParser::compile(const QList<QmlCustomParserProperty> &customProps)
{
- *ok = true;
QList<ListInstruction> instr;
QByteArray data;
for(int ii = 0; ii < customProps.count(); ++ii) {
const QmlCustomParserProperty &prop = customProps.at(ii);
if(prop.name() != "") { // isn't default property
- *ok = false;
+ error(prop, QLatin1String("Cannot use default property"));
return QByteArray();
}
if(!compileProperty(prop, instr, data)) {
- *ok = false;
return QByteArray();
}
}
@@ -518,7 +815,7 @@ static void dump(ModelNode *node, int ind)
for (int ii = 0; ii < node->values.count(); ++ii) {
ModelNode *subNode = qvariant_cast<ModelNode *>(node->values.at(ii));
if (subNode) {
- qWarning().nospace() << indent << "Sub-node " << ii << ": class " << subNode->className;
+ qWarning().nospace() << indent << "Sub-node " << ii;
dump(subNode, ind + 1);
} else {
qWarning().nospace() << indent << "Sub-node " << ii << ": " << node->values.at(ii).toString();
@@ -543,7 +840,8 @@ ModelNode::~ModelNode()
ModelNode *node = qvariant_cast<ModelNode *>(values.at(ii));
if (node) { delete node; node = 0; }
}
- if (modelCache) { delete modelCache; modelCache = 0; }
+ if (modelCache) { modelCache->_root = 0/* ==this */; delete modelCache; modelCache = 0; }
+ if (objectCache) { delete objectCache; }
}
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmllistmodel.h b/src/declarative/util/qmllistmodel.h
index 39edbe4..7bb94cf 100644
--- a/src/declarative/util/qmllistmodel.h
+++ b/src/declarative/util/qmllistmodel.h
@@ -50,6 +50,8 @@
#include <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qlistmodelinterface.h>
+#include <QtScript/qscriptvalue.h>
+
QT_BEGIN_HEADER
@@ -72,6 +74,14 @@ public:
virtual int count() const;
virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
+ Q_INVOKABLE void clear();
+ Q_INVOKABLE void remove(int index);
+ Q_INVOKABLE void append(const QScriptValue&);
+ Q_INVOKABLE void insert(int index, const QScriptValue&);
+ Q_INVOKABLE void set(int index, const QScriptValue&);
+ Q_INVOKABLE void set(int index, const QString& property, const QVariant& value);
+ Q_INVOKABLE void move(int from, int to, int count);
+
private:
QVariant valueForNode(ModelNode *) const;
mutable QStringList roleStrings;
diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp
index b5e204f..1fe1731 100644
--- a/src/declarative/util/qmlpropertychanges.cpp
+++ b/src/declarative/util/qmlpropertychanges.cpp
@@ -106,7 +106,7 @@ class QmlPropertyChangesParser : public QmlCustomParser
public:
void compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QmlCustomParserProperty &prop);
- virtual QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok);
+ virtual QByteArray compile(const QList<QmlCustomParserProperty> &);
virtual void setCustomData(QObject *, const QByteArray &);
};
@@ -137,11 +137,8 @@ QmlPropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &list,
}
QByteArray
-QmlPropertyChangesParser::compile(const QList<QmlCustomParserProperty> &props,
- bool *ok)
+QmlPropertyChangesParser::compile(const QList<QmlCustomParserProperty> &props)
{
- *ok = true;
-
QList<QPair<QByteArray, QVariant> > data;
for(int ii = 0; ii < props.count(); ++ii)
compileList(data, QByteArray(), props.at(ii));
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlspringfollow.cpp
index fe5303f..8c902aa 100644
--- a/src/declarative/util/qmlfollow.cpp
+++ b/src/declarative/util/qmlspringfollow.cpp
@@ -43,18 +43,18 @@
#include <math.h>
#include <QtCore/qdebug.h>
#include "private/qobject_p.h"
-#include "qmlfollow.h"
+#include "qmlspringfollow.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Follow,QmlFollow)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,SpringFollow,QmlSpringFollow)
-class QmlFollowPrivate : public QObjectPrivate
+class QmlSpringFollowPrivate : public QObjectPrivate
{
- Q_DECLARE_PUBLIC(QmlFollow)
+ Q_DECLARE_PUBLIC(QmlSpringFollow)
public:
- QmlFollowPrivate()
+ QmlSpringFollowPrivate()
: sourceValue(0), maxVelocity(0), lastTime(0)
, mass(1.0), useMass(false), spring(0.), damping(0.), velocity(0), epsilon(0.01)
, modulus(0.0), haveModulus(false), enabled(true), mode(Track), clock(this) {}
@@ -87,12 +87,12 @@ public:
void start();
void stop();
- QTickAnimationProxy<QmlFollowPrivate, &QmlFollowPrivate::tick> clock;
+ QTickAnimationProxy<QmlSpringFollowPrivate, &QmlSpringFollowPrivate::tick> clock;
};
-void QmlFollowPrivate::tick(int time)
+void QmlSpringFollowPrivate::tick(int time)
{
- Q_Q(QmlFollow);
+ Q_Q(QmlSpringFollow);
int elapsed = time - lastTime;
if (!elapsed)
@@ -174,7 +174,7 @@ void QmlFollowPrivate::tick(int time)
emit q->syncChanged();
}
-void QmlFollowPrivate::updateMode()
+void QmlSpringFollowPrivate::updateMode()
{
if (spring == 0. && maxVelocity == 0.)
mode = Track;
@@ -184,13 +184,13 @@ void QmlFollowPrivate::updateMode()
mode = Velocity;
}
-void QmlFollowPrivate::start()
+void QmlSpringFollowPrivate::start()
{
if (!enabled)
return;
- Q_Q(QmlFollow);
- if (mode == QmlFollowPrivate::Track) {
+ Q_Q(QmlSpringFollow);
+ if (mode == QmlSpringFollowPrivate::Track) {
currentValue = sourceValue;
property.write(currentValue);
} else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) {
@@ -201,14 +201,14 @@ void QmlFollowPrivate::start()
}
}
-void QmlFollowPrivate::stop()
+void QmlSpringFollowPrivate::stop()
{
clock.stop();
}
/*!
- \qmlclass Follow QmlFollow
- \brief The Follow element allows a property to track a value.
+ \qmlclass SpringFollow QmlSpringFollow
+ \brief The SpringFollow element allows a property to track a value.
In example below, Rect2 will follow Rect1 moving with a velocity of up to 200:
\code
@@ -233,43 +233,43 @@ void QmlFollowPrivate::stop()
x: Rect1.width
width: 20; height: 20
color: "#ff0000"
- y: Follow { source: Rect1.y; velocity: 200 }
+ y: SpringFollow { source: Rect1.y; velocity: 200 }
}
\endcode
*/
-QmlFollow::QmlFollow(QObject *parent)
-: QObject(*(new QmlFollowPrivate),parent)
+QmlSpringFollow::QmlSpringFollow(QObject *parent)
+: QObject(*(new QmlSpringFollowPrivate),parent)
{
}
-QmlFollow::~QmlFollow()
+QmlSpringFollow::~QmlSpringFollow()
{
}
-void QmlFollow::setTarget(const QmlMetaProperty &property)
+void QmlSpringFollow::setTarget(const QmlMetaProperty &property)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->property = property;
d->currentValue = property.read().toDouble();
}
-qreal QmlFollow::sourceValue() const
+qreal QmlSpringFollow::sourceValue() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->sourceValue;
}
/*!
- \qmlproperty qreal Follow::source
+ \qmlproperty qreal SpringFollow::source
This property holds the source value which will be tracked.
Bind to a property in order to track its changes.
*/
-void QmlFollow::setSourceValue(qreal value)
+void QmlSpringFollow::setSourceValue(qreal value)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
if (d->sourceValue != value) {
d->sourceValue = value;
d->start();
@@ -277,26 +277,26 @@ void QmlFollow::setSourceValue(qreal value)
}
/*!
- \qmlproperty qreal Follow::velocity
+ \qmlproperty qreal SpringFollow::velocity
This property holds the maximum velocity allowed when tracking the source.
*/
-qreal QmlFollow::velocity() const
+qreal QmlSpringFollow::velocity() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->maxVelocity;
}
-void QmlFollow::setVelocity(qreal velocity)
+void QmlSpringFollow::setVelocity(qreal velocity)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->maxVelocity = velocity;
d->velocityms = velocity / 1000.0;
d->updateMode();
}
/*!
- \qmlproperty qreal Follow::spring
+ \qmlproperty qreal SpringFollow::spring
This property holds the spring constant
The spring constant describes how strongly the target is pulled towards the
@@ -305,35 +305,35 @@ void QmlFollow::setVelocity(qreal velocity)
When a spring constant is set and the velocity property is greater than 0,
velocity limits the maximum speed.
*/
-qreal QmlFollow::spring() const
+qreal QmlSpringFollow::spring() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->spring;
}
-void QmlFollow::setSpring(qreal spring)
+void QmlSpringFollow::setSpring(qreal spring)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->spring = spring;
d->updateMode();
}
/*!
- \qmlproperty qreal Follow::damping
+ \qmlproperty qreal SpringFollow::damping
This property holds the spring damping constant
The damping constant describes how quickly a sprung follower comes to rest.
Useful range is 0 - 1.0
*/
-qreal QmlFollow::damping() const
+qreal QmlSpringFollow::damping() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->damping;
}
-void QmlFollow::setDamping(qreal damping)
+void QmlSpringFollow::setDamping(qreal damping)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
if (damping > 1.)
damping = 1.;
@@ -342,7 +342,7 @@ void QmlFollow::setDamping(qreal damping)
/*!
- \qmlproperty qreal Follow::epsilon
+ \qmlproperty qreal SpringFollow::epsilon
This property holds the spring epsilon
The epsilon is the rate and amount of change in the value which is close enough
@@ -351,34 +351,34 @@ void QmlFollow::setDamping(qreal damping)
The default is 0.01. Tuning this value can provide small performance improvements.
*/
-qreal QmlFollow::epsilon() const
+qreal QmlSpringFollow::epsilon() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->epsilon;
}
-void QmlFollow::setEpsilon(qreal epsilon)
+void QmlSpringFollow::setEpsilon(qreal epsilon)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->epsilon = epsilon;
}
/*!
- \qmlproperty qreal Follow::modulus
+ \qmlproperty qreal SpringFollow::modulus
This property holds the modulus value.
Setting a \a modulus forces the target value to "wrap around" at the modulus.
For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10.
*/
-qreal QmlFollow::modulus() const
+qreal QmlSpringFollow::modulus() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->modulus;
}
-void QmlFollow::setModulus(qreal modulus)
+void QmlSpringFollow::setModulus(qreal modulus)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
if (d->modulus != modulus) {
d->haveModulus = modulus != 0.0;
d->modulus = modulus;
@@ -387,21 +387,21 @@ void QmlFollow::setModulus(qreal modulus)
}
/*!
- \qmlproperty qreal Follow::mass
+ \qmlproperty qreal SpringFollow::mass
This property holds the "mass" of the property being moved.
mass is 1.0 by default. Setting a different mass changes the dynamics of
a \l spring follow.
*/
-qreal QmlFollow::mass() const
+qreal QmlSpringFollow::mass() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->mass;
}
-void QmlFollow::setMass(qreal mass)
+void QmlSpringFollow::setMass(qreal mass)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
if (d->mass != mass && mass > 0.0) {
d->useMass = mass != 1.0;
d->mass = mass;
@@ -410,23 +410,23 @@ void QmlFollow::setMass(qreal mass)
}
/*!
- \qmlproperty qreal Follow::value
+ \qmlproperty qreal SpringFollow::value
The current value.
*/
/*!
- \qmlproperty bool Follow::enabled
+ \qmlproperty bool SpringFollow::enabled
This property holds whether the target will track the source.
*/
-bool QmlFollow::enabled() const
+bool QmlSpringFollow::enabled() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->enabled;
}
-void QmlFollow::setEnabled(bool enabled)
+void QmlSpringFollow::setEnabled(bool enabled)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->enabled = enabled;
if (enabled)
d->start();
@@ -435,21 +435,21 @@ void QmlFollow::setEnabled(bool enabled)
}
/*!
- \qmlproperty bool Follow::inSync
+ \qmlproperty bool SpringFollow::inSync
This property is true when target is equal to the source; otherwise
false. If inSync is true the target is not being animated.
If \l enabled is false then inSync will also be false.
*/
-bool QmlFollow::inSync() const
+bool QmlSpringFollow::inSync() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->enabled && d->clock.state() != QAbstractAnimation::Running;
}
-qreal QmlFollow::value() const
+qreal QmlSpringFollow::value() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->currentValue;
}
diff --git a/src/declarative/util/qmlfollow.h b/src/declarative/util/qmlspringfollow.h
index 1f6376a..1b77861 100644
--- a/src/declarative/util/qmlfollow.h
+++ b/src/declarative/util/qmlspringfollow.h
@@ -51,14 +51,13 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QmlFollowPrivate;
-class Q_DECLARATIVE_EXPORT QmlFollow : public QObject, public QmlPropertyValueSource,
- public QmlParserStatus
+class QmlSpringFollowPrivate;
+class Q_DECLARATIVE_EXPORT QmlSpringFollow : public QObject,
+ public QmlPropertyValueSource
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QmlFollow)
+ Q_DECLARE_PRIVATE(QmlSpringFollow)
Q_INTERFACES(QmlPropertyValueSource)
- Q_INTERFACES(QmlParserStatus)
Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue)
Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
@@ -73,8 +72,8 @@ class Q_DECLARATIVE_EXPORT QmlFollow : public QObject, public QmlPropertyValueSo
Q_PROPERTY(bool inSync READ inSync NOTIFY syncChanged)
public:
- QmlFollow(QObject *parent=0);
- ~QmlFollow();
+ QmlSpringFollow(QObject *parent=0);
+ ~QmlSpringFollow();
virtual void setTarget(const QmlMetaProperty &);
@@ -107,7 +106,7 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QmlFollow)
+QML_DECLARE_TYPE(QmlSpringFollow)
QT_END_HEADER
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index f1b599f..442380a 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -7,7 +7,8 @@ SOURCES += \
util/qmlscript.cpp \
util/qmlanimation.cpp \
util/qmlsystempalette.cpp \
- util/qmlfollow.cpp \
+ util/qmlspringfollow.cpp \
+ util/qmleasefollow.cpp \
util/qmlstate.cpp\
util/qmltransitionmanager.cpp \
util/qmlstateoperations.cpp \
@@ -32,7 +33,8 @@ HEADERS += \
util/qmlanimation.h \
util/qmlanimation_p.h \
util/qmlsystempalette.h \
- util/qmlfollow.h \
+ util/qmlspringfollow.h \
+ util/qmleasefollow.h \
util/qmlstate.h\
util/qmlstateoperations.h \
util/qmlpropertychanges.h \
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 8bd3648..73ea75e 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -930,7 +930,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent)
}
QGraphicsItem *lastSubFocusItem = subFocusItem;
- if (subFocusItem && !inDestructor) {
+ if (subFocusItem) {
// Update the child focus chain; when reparenting an item that has a
// focus child, ensure that that focus child clears its focus child
// chain from our parents before it's reparented.
@@ -1204,6 +1204,8 @@ QGraphicsItem::~QGraphicsItem()
Q_ASSERT(d_ptr->children.isEmpty());
}
+ d_ptr->subFocusItem = 0;
+
if (d_ptr->scene) {
d_ptr->scene->d_func()->removeItemHelper(this);
} else {
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 52529ff..99e9aeb 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1661,6 +1661,10 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)
EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers);
bool edited = edit(index, trigger, event);
+ //in the case the user presses on no item we might decide to clear the selection
+ if (d->selectionModel && !index.isValid())
+ d->selectionModel->select(QModelIndex(), selectionCommand(index, event));
+
setState(NoState);
if (click) {
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 511c797..a3420da 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -4772,7 +4772,12 @@ void QApplicationPrivate::emitLastWindowClosed()
If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to change focus.
- This feature is available in Qt for Embedded Linux and Symbian only.
+ This feature is available in Qt for Embedded Linux, Symbian and Windows CE
+ only.
+
+ \note On Windows CE this feature is disabled by default for touch device
+ mkspecs. To enable keypad navigation, build Qt with
+ QT_KEYPAD_NAVIGATION defined.
\sa keypadNavigationEnabled()
*/
@@ -4785,7 +4790,12 @@ void QApplication::setKeypadNavigationEnabled(bool enable)
Returns true if Qt is set to use keypad navigation; otherwise returns
false. The default value is true on Symbian, but false on other platforms.
- This feature is available in Qt for Embedded Linux and Symbian only.
+ This feature is available in Qt for Embedded Linux, Symbian and Windows CE
+ only.
+
+ \note On Windows CE this feature is disabled by default for touch device
+ mkspecs. To enable keypad navigation, build Qt with
+ QT_KEYPAD_NAVIGATION defined.
\sa setKeypadNavigationEnabled()
*/
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index e3bd786..ba2e6a6 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -2202,6 +2202,8 @@ void qt_init(QApplicationPrivate *priv, int type)
mouse_double_click_distance = read_int_env_var("QWS_DBLCLICK_DISTANCE", 5);
+ priv->inputContext = 0;
+
int flags = 0;
char *p;
int argc = priv->argc;
@@ -2361,6 +2363,11 @@ void qt_cleanup()
delete mouseInWidget;
mouseInWidget = 0;
+
+#if !defined(QT_NO_IM)
+ delete QApplicationPrivate::inputContext;
+ QApplicationPrivate::inputContext = 0;
+#endif
}
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 8e76715..b3e137d 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -535,6 +535,12 @@ void QPinchGesture::reset()
QGesture::reset();
}
+/*! \enum QPinchGesture::WhatChange
+ \value ScaleFactorChanged
+ \value RotationAngleChanged
+ \value CenterPointChanged
+*/
+
/*!
\property QPinchGesture::whatChanged
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 284558f..bd30cad 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -731,6 +731,7 @@ private:
friend class QGLContext;
friend class QGLWidget;
friend class QGLWindowSurface;
+ friend class QGLWindowSurfaceGLPaintDevice;
friend class QVGWindowSurface;
friend class QX11PaintEngine;
friend class QWin32PaintEngine;
diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp
index f442788..42da637 100644
--- a/src/gui/painting/qpaintengine.cpp
+++ b/src/gui/painting/qpaintengine.cpp
@@ -386,6 +386,7 @@ void QPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDraw
\value User First user type ID
\value MaxUser Last user type ID
\value OpenGL2
+ \value PaintBuffer
*/
/*!
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 3d8dec6..b1fd415 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -1130,10 +1130,10 @@ void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect)
const QStyleSheetBorderImageData *borderImageData = border()->borderImage();
const int *targetBorders = border()->borders;
const int *sourceBorders = borderImageData->cuts;
- QMargins sourceMargins(sourceBorders[TopEdge], sourceBorders[LeftEdge],
- sourceBorders[BottomEdge], sourceBorders[RightEdge]);
- QMargins targetMargins(targetBorders[TopEdge], targetBorders[LeftEdge],
- targetBorders[BottomEdge], targetBorders[RightEdge]);
+ QMargins sourceMargins(sourceBorders[LeftEdge], sourceBorders[TopEdge],
+ sourceBorders[RightEdge], sourceBorders[BottomEdge]);
+ QMargins targetMargins(targetBorders[LeftEdge], targetBorders[TopEdge],
+ targetBorders[RightEdge], targetBorders[BottomEdge]);
bool wasSmoothPixmapTransform = p->renderHints() & QPainter::SmoothPixmapTransform;
p->setRenderHint(QPainter::SmoothPixmapTransform);
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index b150f50..60e5296 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1589,27 +1589,54 @@ void QTextLine::setNumColumns(int numColumns, qreal alignmentWidth)
#define LB_DEBUG if (0) qDebug
#endif
-static inline bool checkFullOtherwiseExtend(QScriptLine &line, QScriptLine &tmpData, QScriptLine &spaceData,
- int glyphCount, int maxGlyphs, QFixed &minw, bool manualWrap,
- QFixed softHyphenWidth = QFixed())
-{
+namespace {
+
+ struct LineBreakHelper
+ {
+ LineBreakHelper() : glyphCount(0), maxGlyphs(0), manualWrap(false) {}
+
+ QScriptLine tmpData;
+ QScriptLine spaceData;
+
+ int glyphCount;
+ int maxGlyphs;
+
+ QFixed minw;
+ QFixed softHyphenWidth;
+ QFixed rightBearing;
+
+ bool manualWrap;
+
+ bool checkFullOtherwiseExtend(QScriptLine &line);
+ };
+
+inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line)
+{
LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal());
- if (line.length && !manualWrap &&
- (line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth > line.width || glyphCount > maxGlyphs))
+
+ QFixed newWidth = line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + rightBearing;
+ if (line.length && !manualWrap && (newWidth > line.width || glyphCount > maxGlyphs))
return true;
+
minw = qMax(minw, tmpData.textWidth);
line += tmpData;
line.textWidth += spaceData.textWidth;
+
line.length += spaceData.length;
tmpData.textWidth = 0;
tmpData.length = 0;
spaceData.textWidth = 0;
spaceData.length = 0;
+
return false;
}
+} // anonymous namespace
+
+
static inline void addNextCluster(int &pos, int end, QScriptLine &line, int &glyphCount,
- const QScriptItem &current, const unsigned short *logClusters, const QGlyphLayout &glyphs)
+ const QScriptItem &current, const unsigned short *logClusters,
+ const QGlyphLayout &glyphs)
{
int glyphPosition = logClusters[pos];
do { // got to the first next cluster
@@ -1642,9 +1669,13 @@ void QTextLine::layout_helper(int maxGlyphs)
Q_ASSERT(line.from < eng->layoutData->string.length());
+ LineBreakHelper lbh;
+
+ lbh.maxGlyphs = maxGlyphs;
+
QTextOption::WrapMode wrapMode = eng->option.wrapMode();
bool breakany = (wrapMode == QTextOption::WrapAnywhere);
- bool manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap);
+ lbh.manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap);
// #### binary search!
int item = -1;
@@ -1654,12 +1685,7 @@ void QTextLine::layout_helper(int maxGlyphs)
break;
}
- QFixed minw = 0;
- int glyphCount = 0;
-
LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal());
- QScriptLine tmpData;
- QScriptLine spaceData;
Qt::Alignment alignment = eng->option.alignment();
@@ -1668,7 +1694,10 @@ void QTextLine::layout_helper(int maxGlyphs)
int end = 0;
QGlyphLayout glyphs;
const unsigned short *logClusters = eng->layoutData->logClustersPtr;
+
while (newItem < eng->layoutData->items.size()) {
+ lbh.rightBearing = 0;
+ lbh.softHyphenWidth = 0;
if (newItem != item) {
item = newItem;
const QScriptItem &current = eng->layoutData->items[item];
@@ -1683,57 +1712,60 @@ void QTextLine::layout_helper(int maxGlyphs)
}
const QScriptItem &current = eng->layoutData->items[item];
- tmpData.ascent = qMax(tmpData.ascent, current.ascent);
- tmpData.descent = qMax(tmpData.descent, current.descent);
+ lbh.tmpData.ascent = qMax(lbh.tmpData.ascent, current.ascent);
+ lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent);
if (current.analysis.flags == QScriptAnalysis::Tab && (alignment & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignCenter | Qt::AlignJustify))) {
- if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap))
+ if (lbh.checkFullOtherwiseExtend(line))
goto found;
- QFixed x = line.x + line.textWidth + tmpData.textWidth + spaceData.textWidth;
- spaceData.textWidth += eng->calculateTabWidth(item, x);
- spaceData.length++;
+ QFixed x = line.x + line.textWidth + lbh.tmpData.textWidth + lbh.spaceData.textWidth;
+ lbh.spaceData.textWidth += eng->calculateTabWidth(item, x);
+ lbh.spaceData.length++;
newItem = item + 1;
- ++glyphCount;
- if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap))
+ ++lbh.glyphCount;
+ if (lbh.checkFullOtherwiseExtend(line))
goto found;
} else if (current.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator) {
// if the line consists only of the line separator make sure
// we have a sane height
- if (!line.length && !tmpData.length)
+ if (!line.length && !lbh.tmpData.length)
line.setDefaultHeight(eng);
if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators) {
- addNextCluster(pos, end, tmpData, glyphCount, current, logClusters, glyphs);
+ addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount,
+ current, logClusters, glyphs);
} else {
- tmpData.length++;
+ lbh.tmpData.length++;
}
- line += tmpData;
+ line += lbh.tmpData;
goto found;
} else if (current.analysis.flags == QScriptAnalysis::Object) {
- tmpData.length++;
+ lbh.tmpData.length++;
QTextFormat format = eng->formats()->format(eng->formatIndex(&eng->layoutData->items[item]));
if (eng->block.docHandle())
eng->docLayout()->positionInlineObject(QTextInlineObject(item, eng), eng->block.position() + current.position, format);
- tmpData.textWidth += current.width;
+ lbh.tmpData.textWidth += current.width;
newItem = item + 1;
- ++glyphCount;
- if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap))
+ ++lbh.glyphCount;
+ if (lbh.checkFullOtherwiseExtend(line))
goto found;
} else if (attributes[pos].whiteSpace) {
while (pos < end && attributes[pos].whiteSpace)
- addNextCluster(pos, end, spaceData, glyphCount, current, logClusters, glyphs);
+ addNextCluster(pos, end, lbh.spaceData, lbh.glyphCount,
+ current, logClusters, glyphs);
- if (!manualWrap && spaceData.textWidth > line.width) {
- spaceData.textWidth = line.width; // ignore spaces that fall out of the line.
+ if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) {
+ lbh.spaceData.textWidth = line.width; // ignore spaces that fall out of the line.
goto found;
}
} else {
bool sb_or_ws = false;
do {
- addNextCluster(pos, end, tmpData, glyphCount, current, logClusters, glyphs);
+ addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount,
+ current, logClusters, glyphs);
if (attributes[pos].whiteSpace || attributes[pos-1].lineBreakType != HB_NoBreak) {
sb_or_ws = true;
@@ -1742,9 +1774,8 @@ void QTextLine::layout_helper(int maxGlyphs)
break;
}
} while (pos < end);
- minw = qMax(tmpData.textWidth, minw);
+ lbh.minw = qMax(lbh.tmpData.textWidth, lbh.minw);
- QFixed softHyphenWidth;
if (pos && attributes[pos - 1].lineBreakType == HB_SoftHyphen) {
// if we are splitting up a word because of
// a soft hyphen then we ...
@@ -1763,16 +1794,29 @@ void QTextLine::layout_helper(int maxGlyphs)
// and thus become invisible again.
//
if (line.length)
- softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]];
+ lbh.softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]];
else if (breakany)
- tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]];
+ lbh.tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]];
}
- if ((sb_or_ws|breakany)
- && checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap, softHyphenWidth)) {
+ // The actual width of the text needs to take the right bearing into account. The
+ // right bearing is left-ward, which means that if the rightmost pixel is to the right
+ // of the advance of the glyph, the bearing will be negative. We flip the sign
+ // for the code to be more readable. Logic borrowed from qfontmetrics.cpp.
+ if (pos) {
+ QFontEngine *fontEngine = eng->fontEngine(current);
+ glyph_t glyph = glyphs.glyphs[logClusters[pos - 1]];
+ glyph_metrics_t gi = fontEngine->boundingBox(glyph);
+ lbh.rightBearing = -qRound(gi.xoff - gi.x - gi.width);
+ }
+
+ if ((sb_or_ws|breakany) && lbh.checkFullOtherwiseExtend(line)) {
if (!breakany) {
- line.textWidth += softHyphenWidth;
+ line.textWidth += lbh.softHyphenWidth;
}
+
+ line.textWidth += lbh.rightBearing;
+
goto found;
}
}
@@ -1780,45 +1824,48 @@ void QTextLine::layout_helper(int maxGlyphs)
newItem = item + 1;
}
LB_DEBUG("reached end of line");
- checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap);
-found:
+ lbh.checkFullOtherwiseExtend(line);
+ line.textWidth += lbh.rightBearing;
+
+found:
if (line.length == 0) {
LB_DEBUG("no break available in line, adding temp: length %d, width %f, space: length %d, width %f",
- tmpData.length, tmpData.textWidth.toReal(), spaceData.length, spaceData.textWidth.toReal());
- line += tmpData;
+ lbh.tmpData.length, lbh.tmpData.textWidth.toReal(),
+ lbh.spaceData.length, lbh.spaceData.textWidth.toReal());
+ line += lbh.tmpData;
}
LB_DEBUG("line length = %d, ascent=%f, descent=%f, textWidth=%f (spacew=%f)", line.length, line.ascent.toReal(),
- line.descent.toReal(), line.textWidth.toReal(), spaceData.width.toReal());
+ line.descent.toReal(), line.textWidth.toReal(), lbh.spaceData.width.toReal());
LB_DEBUG(" : '%s'", eng->layoutData->string.mid(line.from, line.length).toUtf8().data());
- if (manualWrap) {
+ if (lbh.manualWrap) {
eng->minWidth = qMax(eng->minWidth, line.textWidth);
eng->maxWidth = qMax(eng->maxWidth, line.textWidth);
} else {
- eng->minWidth = qMax(eng->minWidth, minw);
+ eng->minWidth = qMax(eng->minWidth, lbh.minw);
eng->maxWidth += line.textWidth;
}
if (line.textWidth > 0 && item < eng->layoutData->items.size())
- eng->maxWidth += spaceData.textWidth;
+ eng->maxWidth += lbh.spaceData.textWidth;
if (eng->option.flags() & QTextOption::IncludeTrailingSpaces)
- line.textWidth += spaceData.textWidth;
- line.length += spaceData.length;
- if (spaceData.length)
+ line.textWidth += lbh.spaceData.textWidth;
+ line.length += lbh.spaceData.length;
+ if (lbh.spaceData.length)
line.hasTrailingSpaces = true;
line.justified = false;
line.gridfitted = false;
if (eng->option.wrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere) {
- if ((maxGlyphs != INT_MAX && glyphCount > maxGlyphs)
- || (maxGlyphs == INT_MAX && line.textWidth > line.width)) {
+ if ((lbh.maxGlyphs != INT_MAX && lbh.glyphCount > lbh.maxGlyphs)
+ || (lbh.maxGlyphs == INT_MAX && line.textWidth > line.width)) {
eng->option.setWrapMode(QTextOption::WrapAnywhere);
line.length = 0;
line.textWidth = 0;
- layout_helper(maxGlyphs);
+ layout_helper(lbh.maxGlyphs);
eng->option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
}
}
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index a81f138..f46abf1 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -109,6 +109,7 @@ public:
int width() const;
int height() const;
int ascent() const;
+ qreal naturalTextWidth() const;
void setSelection(int start, int length);
@@ -410,6 +411,11 @@ inline int QLineControl::width() const
return qRound(m_textLayout.lineAt(0).width()) + 1;
}
+inline qreal QLineControl::naturalTextWidth() const
+{
+ return m_textLayout.lineAt(0).naturalTextWidth();
+}
+
inline int QLineControl::height() const
{
return qRound(m_textLayout.lineAt(0).height()) + 1;
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 3065c7f..9571860 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1808,7 +1808,7 @@ void QLineEdit::paintEvent(QPaintEvent *)
// (cix).
int minLB = qMax(0, -fm.minLeftBearing());
int minRB = qMax(0, -fm.minRightBearing());
- int widthUsed = d->control->width() + minRB;
+ int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB;
if ((minLB + widthUsed) <= lineRect.width()) {
// text fits in lineRect; use hscroll for alignment
switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
index d8d974f..5de5c27 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
@@ -341,8 +341,6 @@ QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode)
QList<QByteArray> devices;
- devices.append("default");
-
if(mode == QAudio::AudioOutput) {
WAVEOUTCAPS woc;
unsigned long iNumDevs,i;
@@ -365,6 +363,9 @@ QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode)
}
}
+ if(devices.count() > 0)
+ devices.append("default");
+
return devices;
}
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index e24539b..e028e63 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -710,7 +710,7 @@ void QGL2PaintEngineEx::beginNativePainting()
{ mtx.dx(), mtx.dy(), 0, mtx.m33() }
};
- const QSize sz = d->drawable.size();
+ const QSize sz = d->device->size();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -1308,21 +1308,20 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
Q_D(QGL2PaintEngineEx);
// qDebug("QGL2PaintEngineEx::begin()");
- d->drawable.setDevice(pdev);
- d->ctx = d->drawable.context();
-
- if (d->ctx->d_ptr->active_engine) {
- QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(d->ctx->d_ptr->active_engine);
- QGL2PaintEngineExPrivate *p = static_cast<QGL2PaintEngineExPrivate *>(engine->d_ptr.data());
- p->transferMode(BrushDrawingMode);
- p->drawable.doneCurrent();
- }
+ if (pdev->devType() == QInternal::OpenGL)
+ d->device = static_cast<QGLPaintDevice*>(pdev);
+ else
+ d->device = QGLPaintDevice::getDevice(pdev);
+
+ if (!d->device)
+ return false;
+
+ d->ctx = d->device->context();
d->ctx->d_ptr->active_engine = this;
d->last_created_state = 0;
- d->drawable.makeCurrent();
- QSize sz = d->drawable.size();
+ QSize sz = d->device->size();
d->width = sz.width();
d->height = sz.height();
d->mode = BrushDrawingMode;
@@ -1333,8 +1332,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
d->shaderManager = new QGLEngineShaderManager(d->ctx);
- glViewport(0, 0, d->width, d->height);
-
d->brushTextureDirty = true;
d->brushUniformsDirty = true;
d->matrixDirty = true;
@@ -1343,10 +1340,12 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
d->simpleShaderDepthUniformDirty = true;
d->depthUniformDirty = true;
d->opacityUniformDirty = true;
- d->needsSync = false;
-
+ d->needsSync = true;
d->use_system_clip = !systemClip().isEmpty();
+
+ d->device->beginPaint();
+
if (!d->inRenderText) {
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
@@ -1358,30 +1357,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
glDisable(GL_MULTISAMPLE);
#endif
- QGLPixmapData *source = d->drawable.copyOnBegin();
- if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) {
- if (d->drawable.hasTransparentBackground())
- glClearColor(0.0, 0.0, 0.0, 0.0);
- else {
- const QColor &c = d->drawable.backgroundColor();
- float alpha = c.alphaF();
- glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha);
- }
- glClear(GL_COLOR_BUFFER_BIT);
- } else if (source) {
- QGLContext *ctx = d->ctx;
-
- d->transferMode(ImageDrawingMode);
-
- glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
- source->bind(false);
-
- QRect rect(0, 0, source->width(), source->height());
- d->updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false);
- d->drawTexture(QRectF(rect), QRectF(rect), rect.size(), true);
- }
-
- d->systemStateChanged();
return true;
}
@@ -1389,19 +1364,11 @@ bool QGL2PaintEngineEx::end()
{
Q_D(QGL2PaintEngineEx);
QGLContext *ctx = d->ctx;
- if (ctx->d_ptr->active_engine != this) {
- QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(ctx->d_ptr->active_engine);
- if (engine && engine->isActive()) {
- QGL2PaintEngineExPrivate *p = static_cast<QGL2PaintEngineExPrivate *>(engine->d_ptr.data());
- p->transferMode(BrushDrawingMode);
- p->drawable.doneCurrent();
- }
- d->drawable.makeCurrent();
- }
glUseProgram(0);
d->transferMode(BrushDrawingMode);
- d->drawable.swapBuffers();
+ d->device->endPaint();
+
#if defined(Q_WS_X11)
// On some (probably all) drivers, deleting an X pixmap which has been bound to a texture
// before calling glFinish/swapBuffers renders garbage. Presumably this is because X deletes
@@ -1410,7 +1377,6 @@ bool QGL2PaintEngineEx::end()
// them here, after swapBuffers, where they can be safely deleted.
ctx->d_func()->boundPixmaps.clear();
#endif
- d->drawable.doneCurrent();
d->ctx->d_ptr->active_engine = 0;
d->resetGLState();
@@ -1427,21 +1393,12 @@ void QGL2PaintEngineEx::ensureActive()
QGLContext *ctx = d->ctx;
if (isActive() && ctx->d_ptr->active_engine != this) {
- QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(ctx->d_ptr->active_engine);
- if (engine && engine->isActive()) {
- QGL2PaintEngineExPrivate *p = static_cast<QGL2PaintEngineExPrivate *>(engine->d_ptr.data());
- p->transferMode(BrushDrawingMode);
- p->drawable.doneCurrent();
- }
- d->drawable.context()->makeCurrent();
- d->drawable.makeCurrent();
-
ctx->d_ptr->active_engine = this;
d->needsSync = true;
- } else {
- d->drawable.context()->makeCurrent();
}
+ d->device->ensureActiveTarget();
+
if (d->needsSync) {
glViewport(0, 0, d->width, d->height);
glDepthMask(false);
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index cb23b11..2fbee1b 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -58,6 +58,7 @@
#include <private/qpaintengineex_p.h>
#include <private/qglengineshadermanager_p.h>
#include <private/qgl2pexvertexarray_p.h>
+#include <private/qglpaintdevice_p.h>
enum EngineMode {
ImageDrawingMode,
@@ -199,7 +200,7 @@ public:
static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; }
QGL2PaintEngineEx* q;
- QGLDrawable drawable;
+ QGLPaintDevice* device;
int width, height;
QGLContext *ctx;
EngineMode mode;
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index 560d31f..d479c2e 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -22,13 +22,18 @@ HEADERS += qgl.h \
qglpixelbuffer.h \
qglpixelbuffer_p.h \
qglframebufferobject.h \
- qglextensions_p.h
+ qglframebufferobject_p.h \
+ qglextensions_p.h \
+ qglpaintdevice_p.h \
+
SOURCES += qgl.cpp \
qglcolormap.cpp \
qglpixelbuffer.cpp \
qglframebufferobject.cpp \
qglextensions.cpp \
+ qglpaintdevice.cpp \
+
!contains(QT_CONFIG, opengles2) {
HEADERS += qpaintengine_opengl_p.h
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 9e0c5f8..a0b2d3a 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -63,6 +63,7 @@
#include "qpixmap.h"
#include "qimage.h"
+#include "qmatrix4x4.h"
#include "qgl_p.h"
#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
@@ -140,6 +141,48 @@ QGLSignalProxy *QGLSignalProxy::instance()
return theSignalProxy();
}
+
+class QGLEngineSelector
+{
+public:
+ QGLEngineSelector() : engineType(QPaintEngine::MaxUser) { }
+
+ void setPreferredPaintEngine(QPaintEngine::Type type) {
+ if (type == QPaintEngine::OpenGL || type == QPaintEngine::OpenGL2)
+ engineType = type;
+ }
+
+ QPaintEngine::Type preferredPaintEngine() {
+ if (engineType == QPaintEngine::MaxUser) {
+ // No user-set engine - use the defaults
+#if defined(QT_OPENGL_ES_2)
+ engineType = QPaintEngine::OpenGL2;
+#else
+ // We can't do this in the constructor for this object because it
+ // needs to be called *before* the QApplication constructor
+ if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)
+ && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty())
+ engineType = QPaintEngine::OpenGL2;
+ else
+ engineType = QPaintEngine::OpenGL;
+#endif
+ }
+ return engineType;
+ }
+
+private:
+ QPaintEngine::Type engineType;
+};
+
+Q_GLOBAL_STATIC(QGLEngineSelector, qgl_engine_selector)
+
+
+bool qt_gl_preferGL2Engine()
+{
+ return qgl_engine_selector()->preferredPaintEngine() == QPaintEngine::OpenGL2;
+}
+
+
/*!
\namespace QGL
\inmodule QtOpenGL
@@ -180,6 +223,32 @@ QGLSignalProxy *QGLSignalProxy::instance()
\sa {Sample Buffers Example}
*/
+/*!
+ \fn void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType)
+
+ \since 4.6
+
+ Sets the preferred OpenGL paint engine that is used to draw onto
+ QGLWidgets, QGLPixelBuffers and QGLFrameBufferObjects with QPainter
+ in Qt.
+
+ The \a engineType parameter specifies which of the GL engines to
+ use. Only \c QPaintEngine::OpenGL and \c QPaintEngine::OpenGL2 are
+ valid parameters to this function. All other values are ignored.
+
+ By default, the \c QPaintEngine::OpenGL2 engine is used if GL/GLES
+ version 2.0 is available, otherwise \c QPaintEngine::OpenGL is
+ used.
+
+ \warning This function must be called before the QApplication
+ constructor is called.
+*/
+void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType)
+{
+ qgl_engine_selector()->setPreferredPaintEngine(engineType);
+}
+
+
/*****************************************************************************
QGLFormat implementation
*****************************************************************************/
@@ -251,46 +320,24 @@ QGLSignalProxy *QGLSignalProxy::instance()
\sa QGLContext, QGLWidget
*/
-static inline void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4])
-{
-#define M(row,col) m[col*4+row]
- out[0] =
- M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3];
- out[1] =
- M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3];
- out[2] =
- M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3];
- out[3] =
- M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3];
-#undef M
-}
-
-static inline GLint qgluProject(GLdouble objx, GLdouble objy, GLdouble objz,
- const GLdouble model[16], const GLdouble proj[16],
- const GLint viewport[4],
- GLdouble * winx, GLdouble * winy, GLdouble * winz)
+static inline void qgluProject
+ (qreal objx, qreal objy, qreal objz,
+ const QMatrix4x4& model, const QMatrix4x4& proj, const GLint viewport[4],
+ GLfloat *winx, GLfloat *winy, GLfloat* winz)
{
- GLdouble in[4], out[4];
-
- in[0] = objx;
- in[1] = objy;
- in[2] = objz;
- in[3] = 1.0;
- transform_point(out, model, in);
- transform_point(in, proj, out);
+ QVector4D transformed = proj.map(model.map(QVector4D(objx, objy, objz, 1)));
- if (in[3] == 0.0)
- return GL_FALSE;
+ qreal w = transformed.w();
+ if (w == 0.0f)
+ w = 1.0f; // Just in case!
- in[0] /= in[3];
- in[1] /= in[3];
- in[2] /= in[3];
+ qreal x = transformed.x() / w;
+ qreal y = transformed.y() / w;
- *winx = viewport[0] + (1 + in[0]) * viewport[2] / 2;
- *winy = viewport[1] + (1 + in[1]) * viewport[3] / 2;
+ *winx = viewport[0] + (1 + x) * viewport[2] / 2;
+ *winy = viewport[1] + (1 + y) * viewport[3] / 2;
- *winz = (1 + in[2]) / 2;
- return GL_TRUE;
+ *winz = (1 + transformed.z() / w) / 2;
}
/*!
@@ -1352,7 +1399,6 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
crWin = false;
initDone = false;
sharing = false;
- clear_on_painter_begin = true;
max_texture_size = -1;
version_flags_cached = false;
version_flags = QGLFormat::OpenGL_Version_None;
@@ -2073,6 +2119,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
case QImage::Format_RGB16:
pixel_type = GL_UNSIGNED_SHORT_5_6_5;
texture_format = GL_RGB;
+ format = GL_RGB;
break;
case QImage::Format_RGB32:
if (format == GL_RGBA)
@@ -4113,6 +4160,30 @@ static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str,
p->setFont(old_font);
}
+#if defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1)
+
+// OpenGL/ES 1.0 cannot fetch viewports from the GL server.
+// We therefore create a default viewport to simulate the fetch.
+
+static void qt_gl_get_viewport(GLint *view, int deviceWidth, int deviceHeight)
+{
+ view[0] = 0;
+ view[1] = 0;
+ view[2] = deviceWidth;
+ view[3] = deviceHeight;
+}
+
+#else
+
+static void qt_gl_get_viewport(GLint *view, int deviceWidth, int deviceHeight)
+{
+ Q_UNUSED(deviceWidth);
+ Q_UNUSED(deviceHeight);
+ glGetIntegerv(GL_VIEWPORT, view);
+}
+
+#endif
+
/*!
Renders the string \a str into the GL context of this widget.
@@ -4138,13 +4209,19 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font,
GLint view[4];
#ifndef QT_OPENGL_ES
bool use_scissor_testing = glIsEnabled(GL_SCISSOR_TEST);
- if (!use_scissor_testing)
- glGetIntegerv(GL_VIEWPORT, &view[0]);
#else
bool use_scissor_testing = false;
#endif
int width = d->glcx->device()->width();
int height = d->glcx->device()->height();
+ if (!use_scissor_testing) {
+ qt_gl_get_viewport(&view[0], width, height);
+ } else {
+ view[0] = 0;
+ view[1] = 0;
+ view[2] = width;
+ view[3] = height;
+ }
bool auto_swap = autoBufferSwap();
QPaintEngine *engine = paintEngine();
@@ -4176,7 +4253,7 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font,
} else {
setAutoBufferSwap(false);
// disable glClear() as a result of QPainter::begin()
- d->glcx->d_func()->clear_on_painter_begin = false;
+ d->disable_clear_on_painter_begin = true;
if (engine->type() == QPaintEngine::OpenGL2) {
qt_save_gl_state();
#ifndef QT_OPENGL_ES_2
@@ -4206,7 +4283,7 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font,
p->end();
delete p;
setAutoBufferSwap(auto_swap);
- d->glcx->d_func()->clear_on_painter_begin = true;
+ d->disable_clear_on_painter_begin = false;
if (engine->type() == QPaintEngine::OpenGL2)
qt_restore_gl_state();
}
@@ -4216,12 +4293,95 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font,
#endif
}
+#if defined(QT_OPENGL_ES_2) || \
+ (defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1))
+
+// OpenGL/ES 1.0 cannot fetch matrices from the GL server.
+// OpenGL/ES 2.0 does not use fixed-function matrices at all.
+// We therefore create some default matrices to simulate the fetch.
+
+static QMatrix4x4 qt_gl_projection_matrix(int deviceWidth, int deviceHeight)
+{
+ QMatrix4x4 m;
+ m.ortho(0, deviceWidth, deviceHeight, 0, -1, 1);
+ return m;
+}
+
+static QMatrix4x4 qt_gl_modelview_matrix(void)
+{
+ return QMatrix4x4();
+}
+
+#else // !QT_OPENGL_ES_2
+
+static QMatrix4x4 qt_gl_fetch_matrix(GLenum type)
+{
+ QMatrix4x4 matrix;
+#if defined(QT_OPENGL_ES_1_CL)
+ GLfixed mat[16];
+ glGetFixedv(type, mat);
+ qreal *m = matrix.data();
+ for (int index = 0; index < 16; ++index)
+ m[index] = vt2f(mat[index]);
+#else
+ if (sizeof(qreal) == sizeof(GLfloat)) {
+ glGetFloatv(type, reinterpret_cast<GLfloat *>(matrix.data()));
+#if !defined(QT_OPENGL_ES)
+ } else if (sizeof(qreal) == sizeof(GLdouble)) {
+ glGetDoublev(type, reinterpret_cast<GLdouble *>(matrix.data()));
+#endif
+ } else {
+ GLfloat mat[16];
+ glGetFloatv(type, mat);
+ qreal *m = matrix.data();
+ for (int index = 0; index < 16; ++index)
+ m[index] = mat[index];
+ }
+#endif
+ matrix.inferSpecialType();
+ return matrix;
+}
+
+static QMatrix4x4 qt_gl_projection_matrix(int deviceWidth, int deviceHeight)
+{
+ Q_UNUSED(deviceWidth);
+ Q_UNUSED(deviceHeight);
+ return qt_gl_fetch_matrix(GL_PROJECTION_MATRIX);
+}
+
+static QMatrix4x4 qt_gl_modelview_matrix(void)
+{
+ return qt_gl_fetch_matrix(GL_MODELVIEW_MATRIX);
+}
+
+#endif // !QT_OPENGL_ES_2
+
/*! \overload
\a x, \a y and \a z are specified in scene or object coordinates
relative to the currently set projection and model matrices. This
can be useful if you want to annotate models with text labels and
have the labels move with the model as it is rotated etc.
+
+ This function fetches the modelview matrix, projection matrix, and
+ current viewport from the GL server to map (\a x, \a y, \a z)
+ into window co-ordinates. This entails several round-trips to the GL
+ server which will probably impact performance.
+
+ Fetching the modelview and projection matrices is not supported
+ under OpenGL/ES 1.0 and OpenGL/ES 2.0 so a default orthographic
+ projection will be used to map the co-ordinates on those platforms.
+ This probably will not give results that are consistent with desktop
+ and OpenGL/ES 1.1 systems. Fetching the viewport is not supported
+ under OpenGL/ES 1.0, so the full device will be used as the viewport.
+
+ This function is deprecated because it is non-portable. It is
+ recommended that the application map the co-ordinates itself using
+ application-provided matrix data that reflects the desired
+ transformation. Then use QPainter::drawText() to draw \a str at
+ the mapped position.
+
+ \sa QMatrix4x4
*/
void QGLWidget::renderText(double x, double y, double z, const QString &str, const QFont &font, int)
{
@@ -4233,16 +4393,15 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
int width = d->glcx->device()->width();
int height = d->glcx->device()->height();
- GLdouble model[4][4], proj[4][4];
+
+ QMatrix4x4 model = qt_gl_modelview_matrix();
+ QMatrix4x4 proj = qt_gl_projection_matrix(width, height);
GLint view[4];
-#ifndef QT_OPENGL_ES
- glGetDoublev(GL_MODELVIEW_MATRIX, &model[0][0]);
- glGetDoublev(GL_PROJECTION_MATRIX, &proj[0][0]);
- glGetIntegerv(GL_VIEWPORT, &view[0]);
-#endif
- GLdouble win_x = 0, win_y = 0, win_z = 0;
- qgluProject(x, y, z, &model[0][0], &proj[0][0], &view[0],
- &win_x, &win_y, &win_z);
+ qt_gl_get_viewport(view, width, height);
+
+ GLfloat win_x = 0, win_y = 0, win_z = 0;
+ qgluProject(qreal(x), qreal(y), qreal(z),
+ model, proj, &view[0], &win_x, &win_y, &win_z);
win_y = height - win_y; // y is inverted
QPaintEngine *engine = paintEngine();
@@ -4267,7 +4426,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
} else {
setAutoBufferSwap(false);
// disable glClear() as a result of QPainter::begin()
- d->glcx->d_func()->clear_on_painter_begin = false;
+ d->disable_clear_on_painter_begin = true;
if (engine->type() == QPaintEngine::OpenGL2)
qt_save_gl_state();
p = new QPainter(this);
@@ -4295,11 +4454,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
glEnable(GL_ALPHA_TEST);
if (use_depth_testing)
glEnable(GL_DEPTH_TEST);
-#ifndef QT_OPENGL_ES
- glTranslated(0, 0, -win_z);
-#else
glTranslatef(0, 0, -win_z);
-#endif
#endif // !defined(QT_OPENGL_ES_2)
qt_gl_draw_text(p, qRound(win_x), qRound(win_y), str, font);
@@ -4311,7 +4466,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
if (engine->type() == QPaintEngine::OpenGL2)
qt_restore_gl_state();
setAutoBufferSwap(auto_swap);
- d->glcx->d_func()->clear_on_painter_begin = true;
+ d->disable_clear_on_painter_begin = false;
}
#ifndef QT_OPENGL_ES
if (engine->type() == QPaintEngine::OpenGL2)
@@ -4659,6 +4814,8 @@ void QGLWidgetPrivate::initContext(QGLContext *context, const QGLWidget* shareWi
{
Q_Q(QGLWidget);
+ glDevice.setWidget(q);
+
QGLExtensions::init();
glcx = 0;
autoSwap = true;
@@ -4694,242 +4851,6 @@ Q_OPENGL_EXPORT const QString qt_gl_library_name()
}
#endif
-void QGLDrawable::setDevice(QPaintDevice *pdev)
-{
- wasBound = false;
- widget = 0;
- buffer = 0;
- fbo = 0;
-#ifdef Q_WS_QWS
- wsurf = 0;
-#endif
-
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- if (pdev->devType() == QInternal::Pixmap) {
- QPixmapData *data = static_cast<QPixmap *>(pdev)->pixmapData();
- Q_ASSERT(data->classId() == QPixmapData::OpenGLClass);
- pixmapData = static_cast<QGLPixmapData *>(data);
-
- fbo = pixmapData->fbo();
- }
-#else
- Q_ASSERT(pdev->devType() != QInternal::Pixmap);
-#endif
-
- if (pdev->devType() == QInternal::Widget)
- widget = static_cast<QGLWidget *>(pdev);
- else if (pdev->devType() == QInternal::Pbuffer)
- buffer = static_cast<QGLPixelBuffer *>(pdev);
- else if (pdev->devType() == QInternal::FramebufferObject)
- fbo = static_cast<QGLFramebufferObject *>(pdev);
-#ifdef Q_WS_QWS
- else if (pdev->devType() == QInternal::UnknownDevice)
- wsurf = static_cast<QWSGLPaintDevice*>(pdev)->windowSurface();
-#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- else if (pdev->devType() == QInternal::UnknownDevice)
- wsurf = static_cast<QGLWindowSurface *>(pdev);
-#endif
-}
-
-void QGLDrawable::swapBuffers()
-{
- if (widget) {
- if (widget->autoBufferSwap())
- widget->swapBuffers();
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- } else if (pixmapData) {
- pixmapData->swapBuffers();
-#endif
- } else {
- glFlush();
- }
-}
-
-void QGLDrawable::makeCurrent()
-{
- previous_fbo = 0;
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- if (!pixmapData && !fbo) {
-#else
- if (!fbo) {
-#endif
- QGLContext *ctx = context();
- previous_fbo = ctx->d_ptr->current_fbo;
- ctx->d_ptr->current_fbo = 0;
- if (previous_fbo)
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
- }
-
- if (widget)
- widget->makeCurrent();
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- else if (pixmapData)
- pixmapData->makeCurrent();
-#endif
- else if (buffer)
- buffer->makeCurrent();
-#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL))
- else if (wsurf)
- wsurf->context()->makeCurrent();
-#endif
- else if (fbo) {
- wasBound = fbo->isBound();
- if (!wasBound)
- fbo->bind();
- }
-}
-
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
-QGLPixmapData *QGLDrawable::copyOnBegin() const
-{
- if (!pixmapData || pixmapData->isUninitialized())
- return 0;
- return pixmapData;
-}
-#endif
-
-void QGLDrawable::doneCurrent()
-{
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- if (pixmapData) {
- pixmapData->doneCurrent();
- return;
- }
-#endif
-
- if (previous_fbo) {
- QGLContext *ctx = context();
- ctx->d_ptr->current_fbo = previous_fbo;
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, previous_fbo);
- }
-
- if (fbo && !wasBound)
- fbo->release();
-}
-
-QSize QGLDrawable::size() const
-{
- if (widget) {
- return QSize(widget->d_func()->glcx->device()->width(),
- widget->d_func()->glcx->device()->height());
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- } else if (pixmapData) {
- return pixmapData->size();
-#endif
- } else if (buffer) {
- return buffer->size();
- } else if (fbo) {
- return fbo->size();
- }
-#ifdef Q_WS_QWS
- else if (wsurf)
- return wsurf->window()->frameSize();
-#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- else if (wsurf)
- return QSize(wsurf->width(), wsurf->height());
-#endif
- return QSize();
-}
-
-QGLFormat QGLDrawable::format() const
-{
- if (widget)
- return widget->format();
- else if (buffer)
- return buffer->format();
-#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL))
- else if (wsurf)
- return wsurf->context()->format();
-#endif
- else if (fbo && QGLContext::currentContext()) {
- QGLFormat fmt = QGLContext::currentContext()->format();
- fmt.setStencil(fbo->attachment() == QGLFramebufferObject::CombinedDepthStencil);
- fmt.setDepth(fbo->attachment() != QGLFramebufferObject::NoAttachment);
- return fmt;
- }
-
- return QGLFormat();
-}
-
-GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format,
- QGLContext::BindOptions options)
-{
- QGLTexture *texture = 0;
- options |= QGLContext::MemoryManagedBindOption;
- if (widget)
- texture = widget->d_func()->glcx->d_func()->bindTexture(image, target, format, options);
- else if (buffer)
- texture = buffer->d_func()->qctx->d_func()->bindTexture(image, target, format, options);
- else if (fbo && QGLContext::currentContext())
- texture = const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(image, target, format, options);
-#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL))
- else if (wsurf)
- texture = wsurf->context()->d_func()->bindTexture(image, target, format, options);
-#endif
- return texture->id;
-}
-
-GLuint QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint format,
- QGLContext::BindOptions options)
-{
- QGLTexture *texture = 0;
- if (widget)
- texture = widget->d_func()->glcx->d_func()->bindTexture(pixmap, target, format, options);
- else if (buffer)
- texture = buffer->d_func()->qctx->d_func()->bindTexture(pixmap, target, format, options);
- else if (fbo && QGLContext::currentContext())
- texture = const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(pixmap, target, format, options);
-#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL))
- else if (wsurf)
- texture = wsurf->context()->d_func()->bindTexture(pixmap, target, format, options);
-#endif
- return texture->id;
-}
-
-QColor QGLDrawable::backgroundColor() const
-{
- if (widget)
- return widget->palette().brush(widget->backgroundRole()).color();
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- else if (pixmapData)
- return pixmapData->fillColor();
-#endif
- return QApplication::palette().brush(QPalette::Background).color();
-}
-
-bool QGLDrawable::hasTransparentBackground() const
-{
- return widget && widget->testAttribute(Qt::WA_TranslucentBackground);
-}
-
-QGLContext *QGLDrawable::context() const
-{
- if (widget)
- return widget->d_func()->glcx;
- else if (buffer)
- return buffer->d_func()->qctx;
- else if (fbo)
- return const_cast<QGLContext *>(QGLContext::currentContext());
-#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL))
- else if (wsurf)
- return wsurf->context();
-#endif
- return 0;
-}
-
-bool QGLDrawable::autoFillBackground() const
-{
- if (widget)
- return widget->autoFillBackground();
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- else if (pixmapData)
- return pixmapData->needsFill();
-#endif
- else
- return false;
-}
-
-
bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) {
bool sharing = (context1 && context2 && context1->d_ptr->group == context2->d_ptr->group);
return sharing;
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index daac760..151c7c4 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -43,6 +43,7 @@
#define QGL_H
#include <QtGui/qwidget.h>
+#include <QtGui/qpaintengine.h>
#include <QtOpenGL/qglcolormap.h>
#include <QtCore/qmap.h>
#include <QtCore/qscopedpointer.h>
@@ -130,6 +131,8 @@ class QGLContextPrivate;
// Namespace class:
namespace QGL
{
+ Q_OPENGL_EXPORT void setPreferredPaintEngine(QPaintEngine::Type engineType);
+
enum FormatOption {
DoubleBuffer = 0x0001,
DepthBuffer = 0x0002,
@@ -382,7 +385,6 @@ private:
friend class QGLPixelBuffer;
friend class QGLPixelBufferPrivate;
friend class QGLWidget;
- friend class QGLDrawable;
friend class QGLWidgetPrivate;
friend class QGLGlyphCache;
friend class QOpenGLPaintEngine;
@@ -404,6 +406,8 @@ private:
#endif
friend class QGLFramebufferObject;
friend class QGLFramebufferObjectPrivate;
+ friend class QGLFBOGLPaintDevice;
+ friend class QGLPaintDevice;
private:
Q_DISABLE_COPY(QGLContext)
};
@@ -539,6 +543,8 @@ private:
friend class QGLContext;
friend class QGLOverlayWidget;
friend class QOpenGLPaintEngine;
+ friend class QGLPaintDevice;
+ friend class QGLWidgetGLPaintDevice;
};
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index d4b7597..b10d5da 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -62,6 +62,7 @@
#include "QtCore/qatomic.h"
#include "private/qwidget_p.h"
#include "qcache.h"
+#include "qglpaintdevice_p.h"
#ifndef QT_OPENGL_ES_1_CL
#define q_vertexType float
@@ -174,6 +175,7 @@ class QGLWidgetPrivate : public QWidgetPrivate
Q_DECLARE_PUBLIC(QGLWidget)
public:
QGLWidgetPrivate() : QWidgetPrivate()
+ , disable_clear_on_painter_begin(false)
#ifdef Q_WS_QWS
, wsurf(0)
#endif
@@ -190,11 +192,14 @@ public:
void cleanupColormaps();
QGLContext *glcx;
+ QGLWidgetGLPaintDevice glDevice;
bool autoSwap;
QGLColormap cmap;
QMap<QString, int> displayListCache;
+ bool disable_clear_on_painter_begin;
+
#if defined(Q_WS_WIN)
void updateColormap();
QGLContext *olcx;
@@ -293,7 +298,6 @@ public:
uint sharing : 1;
uint initDone : 1;
uint crWin : 1;
- uint clear_on_painter_begin : 1;
uint internal_context : 1;
uint version_flags_cached : 1;
QPaintDevice *paintDevice;
@@ -337,57 +341,6 @@ Q_SIGNALS:
void aboutToDestroyContext(const QGLContext *context);
};
-class QGLPixelBuffer;
-class QGLFramebufferObject;
-class QWSGLWindowSurface;
-class QGLWindowSurface;
-class QGLPixmapData;
-class QGLDrawable {
-public:
- QGLDrawable() : widget(0), buffer(0), fbo(0)
-#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL))
- , wsurf(0)
-#endif
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- , pixmapData(0)
-#endif
- {}
- void setDevice(QPaintDevice *pdev);
- void swapBuffers();
- void makeCurrent();
- void doneCurrent();
- QSize size() const;
- QGLFormat format() const;
- GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA,
- QGLContext::BindOptions = QGLContext::InternalBindOption);
- GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA,
- QGLContext::BindOptions = QGLContext::InternalBindOption);
- QColor backgroundColor() const;
- QGLContext *context() const;
- bool autoFillBackground() const;
- bool hasTransparentBackground() const;
-
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- QGLPixmapData *copyOnBegin() const;
-#endif
-
-private:
- bool wasBound;
- QGLWidget *widget;
- QGLPixelBuffer *buffer;
- QGLFramebufferObject *fbo;
-#ifdef Q_WS_QWS
- QWSGLWindowSurface *wsurf;
-#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- QGLWindowSurface *wsurf;
-#endif
-
-#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
- QGLPixmapData *pixmapData;
-#endif
- int previous_fbo;
-};
-
// GL extension definitions
class QGLExtensions {
public:
@@ -519,15 +472,7 @@ extern QPaintEngine* qt_qgl_paint_engine();
extern EGLDisplay qt_qgl_egl_display();
#endif
-inline bool qt_gl_preferGL2Engine()
-{
-#if defined(QT_OPENGL_ES_2)
- return true;
-#else
- return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)
- && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty();
-#endif
-}
+bool qt_gl_preferGL2Engine();
inline GLenum qt_gl_preferredTextureFormat()
{
diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp
index 81985cd..a7376b2 100644
--- a/src/opengl/qgl_x11.cpp
+++ b/src/opengl/qgl_x11.cpp
@@ -1308,7 +1308,6 @@ void QGLWidget::setContext(QGLContext *context,
QGLContext* oldcx = d->glcx;
d->glcx = context;
-
if (parentWidget()) {
// force creation of delay-created widgets
parentWidget()->winId();
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index c53ed3a..9dbf5c8 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qglframebufferobject.h"
+#include "qglframebufferobject_p.h"
#include <qdebug.h>
#include <private/qgl_p.h>
@@ -74,15 +75,6 @@ extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool);
} \
}
-class QGLFramebufferObjectFormatPrivate
-{
-public:
- int samples;
- QGLFramebufferObject::Attachment attachment;
- GLenum target;
- GLenum internal_format;
-};
-
/*!
\class QGLFramebufferObjectFormat
\brief The QGLFramebufferObjectFormat class specifies the format of an OpenGL
@@ -109,6 +101,20 @@ public:
*/
/*!
+ \internal
+*/
+void QGLFramebufferObjectFormat::detach()
+{
+ if (d->ref != 1) {
+ QGLFramebufferObjectFormatPrivate *newd
+ = new QGLFramebufferObjectFormatPrivate(d);
+ if (!d->ref.deref())
+ delete d;
+ d = newd;
+ }
+}
+
+/*!
Creates a QGLFramebufferObjectFormat object for specifying
the format of an OpenGL framebuffer object.
@@ -118,19 +124,9 @@ public:
\sa samples(), attachment(), target(), internalTextureFormat()
*/
-#ifndef QT_OPENGL_ES
-#define DEFAULT_FORMAT GL_RGBA8
-#else
-#define DEFAULT_FORMAT GL_RGBA
-#endif
-
QGLFramebufferObjectFormat::QGLFramebufferObjectFormat()
{
d = new QGLFramebufferObjectFormatPrivate;
- d->samples = 0;
- d->attachment = QGLFramebufferObject::NoAttachment;
- d->target = GL_TEXTURE_2D;
- d->internal_format = DEFAULT_FORMAT;
}
/*!
@@ -139,8 +135,8 @@ QGLFramebufferObjectFormat::QGLFramebufferObjectFormat()
QGLFramebufferObjectFormat::QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat &other)
{
- d = new QGLFramebufferObjectFormatPrivate;
- *d = *other.d;
+ d = other.d;
+ d->ref.ref();
}
/*!
@@ -149,7 +145,12 @@ QGLFramebufferObjectFormat::QGLFramebufferObjectFormat(const QGLFramebufferObjec
QGLFramebufferObjectFormat &QGLFramebufferObjectFormat::operator=(const QGLFramebufferObjectFormat &other)
{
- *d = *other.d;
+ if (d != other.d) {
+ other.d->ref.ref();
+ if (!d->ref.deref())
+ delete d;
+ d = other.d;
+ }
return *this;
}
@@ -158,7 +159,8 @@ QGLFramebufferObjectFormat &QGLFramebufferObjectFormat::operator=(const QGLFrame
*/
QGLFramebufferObjectFormat::~QGLFramebufferObjectFormat()
{
- delete d;
+ if (!d->ref.deref())
+ delete d;
}
/*!
@@ -176,6 +178,7 @@ QGLFramebufferObjectFormat::~QGLFramebufferObjectFormat()
*/
void QGLFramebufferObjectFormat::setSamples(int samples)
{
+ detach();
d->samples = samples;
}
@@ -197,6 +200,7 @@ int QGLFramebufferObjectFormat::samples() const
*/
void QGLFramebufferObjectFormat::setAttachment(QGLFramebufferObject::Attachment attachment)
{
+ detach();
d->attachment = attachment;
}
@@ -219,6 +223,7 @@ QGLFramebufferObject::Attachment QGLFramebufferObjectFormat::attachment() const
*/
void QGLFramebufferObjectFormat::setTextureTarget(GLenum target)
{
+ detach();
d->target = target;
}
@@ -242,6 +247,7 @@ GLenum QGLFramebufferObjectFormat::textureTarget() const
*/
void QGLFramebufferObjectFormat::setInternalTextureFormat(GLenum internalTextureFormat)
{
+ detach();
d->internal_format = internalTextureFormat;
}
@@ -260,38 +266,71 @@ GLenum QGLFramebufferObjectFormat::internalTextureFormat() const
/*! \internal */
void QGLFramebufferObjectFormat::setTextureTarget(QMacCompatGLenum target)
{
+ detach();
d->target = target;
}
/*! \internal */
void QGLFramebufferObjectFormat::setInternalTextureFormat(QMacCompatGLenum internalTextureFormat)
{
+ detach();
d->internal_format = internalTextureFormat;
}
#endif
-class QGLFramebufferObjectPrivate
+/*!
+ Returns true if all the options of this framebuffer object format
+ are the same as \a other; otherwise returns false.
+*/
+bool QGLFramebufferObjectFormat::operator==(const QGLFramebufferObjectFormat& other) const
+{
+ if (d == other.d)
+ return true;
+ else
+ return d->equals(other.d);
+}
+
+/*!
+ Returns false if all the options of this framebuffer object format
+ are the same as \a other; otherwise returns true.
+*/
+bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& other) const
+{
+ return !(*this == other);
+}
+
+void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f)
{
-public:
- QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), ctx(0), previous_fbo(0), engine(0) {}
- ~QGLFramebufferObjectPrivate() {}
-
- void init(const QSize& sz, QGLFramebufferObject::Attachment attachment,
- GLenum internal_format, GLenum texture_target, GLint samples = 0);
- bool checkFramebufferStatus() const;
- GLuint texture;
- GLuint fbo;
- GLuint depth_stencil_buffer;
- GLuint color_buffer;
- GLenum target;
- QSize size;
- QGLFramebufferObjectFormat format;
- uint valid : 1;
- QGLFramebufferObject::Attachment fbo_attachment;
- QGLContextGroup *ctx; // for Windows extension ptrs
- GLuint previous_fbo;
- mutable QPaintEngine *engine;
-};
+ fbo = f;
+ m_thisFBO = fbo->d_func()->fbo; // This shouldn't be needed
+}
+
+void QGLFBOGLPaintDevice::ensureActiveTarget()
+{
+ QGLContext* ctx = const_cast<QGLContext*>(QGLContext::currentContext());
+ Q_ASSERT(ctx);
+ const GLuint fboId = fbo->d_func()->fbo;
+ if (ctx->d_func()->current_fbo != fboId) {
+ ctx->d_func()->current_fbo = fboId;
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId);
+ }
+}
+
+void QGLFBOGLPaintDevice::beginPaint()
+{
+ // We let QFBO track the previously bound FBO rather than doing it
+ // ourselves here. This has the advantage that begin/release & bind/end
+ // work as expected.
+ wasBound = fbo->isBound();
+ if (!wasBound)
+ fbo->bind();
+}
+
+void QGLFBOGLPaintDevice::endPaint()
+{
+ if (!wasBound)
+ fbo->release();
+}
bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const
{
@@ -337,11 +376,14 @@ bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const
return false;
}
-void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::Attachment attachment,
+void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
+ QGLFramebufferObject::Attachment attachment,
GLenum texture_target, GLenum internal_format, GLint samples)
{
QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext());
ctx = QGLContextPrivate::contextGroup(currentContext);
+ glDevice.setFBO(q);
+
bool ext_detected = (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject);
if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(currentContext)))
return;
@@ -354,6 +396,8 @@ void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::At
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo);
+ glDevice.setFBO(q);
+
QT_CHECK_GLERROR();
// init texture
if (samples == 0) {
@@ -600,7 +644,8 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, GLenum target)
: d_ptr(new QGLFramebufferObjectPrivate)
{
Q_D(QGLFramebufferObject);
- d->init(size, NoAttachment, target, DEFAULT_FORMAT);
+ d->glDevice.setFBO(this);
+ d->init(this, size, NoAttachment, target, DEFAULT_FORMAT);
}
#ifdef Q_MAC_COMPAT_GL_FUNCTIONS
@@ -624,7 +669,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, GLenum target)
: d_ptr(new QGLFramebufferObjectPrivate)
{
Q_D(QGLFramebufferObject);
- d->init(QSize(width, height), NoAttachment, target, DEFAULT_FORMAT);
+ d->init(this, QSize(width, height), NoAttachment, target, DEFAULT_FORMAT);
}
/*! \overload
@@ -637,7 +682,8 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, const QGLFramebuff
: d_ptr(new QGLFramebufferObjectPrivate)
{
Q_D(QGLFramebufferObject);
- d->init(size, format.attachment(), format.textureTarget(), format.internalTextureFormat(), format.samples());
+ d->init(this, size, format.attachment(), format.textureTarget(), format.internalTextureFormat(),
+ format.samples());
}
/*! \overload
@@ -650,7 +696,8 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, const QGLFrame
: d_ptr(new QGLFramebufferObjectPrivate)
{
Q_D(QGLFramebufferObject);
- d->init(QSize(width, height), format.attachment(), format.textureTarget(), format.internalTextureFormat(), format.samples());
+ d->init(this, QSize(width, height), format.attachment(), format.textureTarget(),
+ format.internalTextureFormat(), format.samples());
}
#ifdef Q_MAC_COMPAT_GL_FUNCTIONS
@@ -659,7 +706,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, QMacCompatGLen
: d_ptr(new QGLFramebufferObjectPrivate)
{
Q_D(QGLFramebufferObject);
- d->init(QSize(width, height), NoAttachment, target, DEFAULT_FORMAT);
+ d->init(this, QSize(width, height), NoAttachment, target, DEFAULT_FORMAT);
}
#endif
@@ -680,7 +727,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment att
: d_ptr(new QGLFramebufferObjectPrivate)
{
Q_D(QGLFramebufferObject);
- d->init(QSize(width, height), attachment, target, internal_format);
+ d->init(this, QSize(width, height), attachment, target, internal_format);
}
#ifdef Q_MAC_COMPAT_GL_FUNCTIONS
@@ -690,7 +737,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment att
: d_ptr(new QGLFramebufferObjectPrivate)
{
Q_D(QGLFramebufferObject);
- d->init(QSize(width, height), attachment, target, internal_format);
+ d->init(this, QSize(width, height), attachment, target, internal_format);
}
#endif
@@ -711,7 +758,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachm
: d_ptr(new QGLFramebufferObjectPrivate)
{
Q_D(QGLFramebufferObject);
- d->init(size, attachment, target, internal_format);
+ d->init(this, size, attachment, target, internal_format);
}
#ifdef Q_MAC_COMPAT_GL_FUNCTIONS
@@ -721,7 +768,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachm
: d_ptr(new QGLFramebufferObjectPrivate)
{
Q_D(QGLFramebufferObject);
- d->init(size, attachment, target, internal_format);
+ d->init(this, size, attachment, target, internal_format);
}
#endif
@@ -871,7 +918,7 @@ QSize QGLFramebufferObject::size() const
/*!
Returns the format of this framebuffer object.
*/
-const QGLFramebufferObjectFormat &QGLFramebufferObject::format() const
+QGLFramebufferObjectFormat QGLFramebufferObject::format() const
{
Q_D(const QGLFramebufferObject);
return d->format;
diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h
index ec1ae7d..6efbb73 100644
--- a/src/opengl/qglframebufferobject.h
+++ b/src/opengl/qglframebufferobject.h
@@ -93,7 +93,7 @@ public:
virtual ~QGLFramebufferObject();
- const QGLFramebufferObjectFormat &format() const;
+ QGLFramebufferObjectFormat format() const;
bool isValid() const;
bool isBound() const;
@@ -130,7 +130,8 @@ protected:
private:
Q_DISABLE_COPY(QGLFramebufferObject)
QScopedPointer<QGLFramebufferObjectPrivate> d_ptr;
- friend class QGLDrawable;
+ friend class QGLPaintDevice;
+ friend class QGLFBOGLPaintDevice;
};
class QGLFramebufferObjectFormatPrivate;
@@ -159,8 +160,13 @@ public:
void setInternalTextureFormat(QMacCompatGLenum internalTextureFormat);
#endif
+ bool operator==(const QGLFramebufferObjectFormat& other) const;
+ bool operator!=(const QGLFramebufferObjectFormat& other) const;
+
private:
QGLFramebufferObjectFormatPrivate *d;
+
+ void detach();
};
QT_END_NAMESPACE
diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h
new file mode 100644
index 0000000..58e6505
--- /dev/null
+++ b/src/opengl/qglframebufferobject_p.h
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGLFRAMEBUFFEROBJECT_P_H
+#define QGLFRAMEBUFFEROBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QLibrary class. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+QT_BEGIN_INCLUDE_NAMESPACE
+
+#include <qglframebufferobject.h>
+#include <private/qglpaintdevice_p.h>
+#include <private/qgl_p.h>
+
+QT_END_INCLUDE_NAMESPACE
+
+#ifndef QT_OPENGL_ES
+#define DEFAULT_FORMAT GL_RGBA8
+#else
+#define DEFAULT_FORMAT GL_RGBA
+#endif
+
+class QGLFramebufferObjectFormatPrivate
+{
+public:
+ QGLFramebufferObjectFormatPrivate()
+ : ref(1),
+ samples(0),
+ attachment(QGLFramebufferObject::NoAttachment),
+ target(GL_TEXTURE_2D),
+ internal_format(DEFAULT_FORMAT)
+ {
+ }
+ QGLFramebufferObjectFormatPrivate
+ (const QGLFramebufferObjectFormatPrivate *other)
+ : ref(1),
+ samples(other->samples),
+ attachment(other->attachment),
+ target(other->target),
+ internal_format(other->internal_format)
+ {
+ }
+ bool equals(const QGLFramebufferObjectFormatPrivate *other)
+ {
+ return samples == other->samples &&
+ attachment == other->attachment &&
+ target == other->target &&
+ internal_format == other->internal_format;
+ }
+
+ QAtomicInt ref;
+ int samples;
+ QGLFramebufferObject::Attachment attachment;
+ GLenum target;
+ GLenum internal_format;
+};
+
+class QGLFBOGLPaintDevice : public QGLPaintDevice
+{
+public:
+ virtual QPaintEngine* paintEngine() const {return fbo->paintEngine();}
+ virtual QSize size() const {return fbo->size();}
+ virtual QGLContext* context() const {return const_cast<QGLContext *>(QGLContext::currentContext());}
+ virtual void ensureActiveTarget();
+ virtual void beginPaint();
+ virtual void endPaint();
+
+ void setFBO(QGLFramebufferObject* f);
+
+private:
+ bool wasBound;
+ QGLFramebufferObject* fbo;
+};
+
+class QGLFramebufferObjectPrivate
+{
+public:
+ QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), ctx(0), previous_fbo(0), engine(0) {}
+ ~QGLFramebufferObjectPrivate() {}
+
+ void init(QGLFramebufferObject *q, const QSize& sz,
+ QGLFramebufferObject::Attachment attachment,
+ GLenum internal_format, GLenum texture_target, GLint samples = 0);
+ bool checkFramebufferStatus() const;
+ GLuint texture;
+ GLuint fbo;
+ GLuint depth_stencil_buffer;
+ GLuint color_buffer;
+ GLenum target;
+ QSize size;
+ QGLFramebufferObjectFormat format;
+ uint valid : 1;
+ QGLFramebufferObject::Attachment fbo_attachment;
+ QGLContextGroup *ctx; // for Windows extension ptrs
+ GLuint previous_fbo;
+ mutable QPaintEngine *engine;
+ QGLFBOGLPaintDevice glDevice;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QGLFRAMEBUFFEROBJECT_P_H
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
new file mode 100644
index 0000000..a89b884
--- /dev/null
+++ b/src/opengl/qglpaintdevice.cpp
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qglpaintdevice_p.h>
+#include <private/qgl_p.h>
+#include <private/qglpixelbuffer_p.h>
+#include <private/qglframebufferobject_p.h>
+#include <private/qwindowsurface_gl_p.h>
+#include <private/qpixmapdata_gl_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QGLPaintDevice::QGLPaintDevice()
+ : m_thisFBO(0)
+{
+}
+
+QGLPaintDevice::~QGLPaintDevice()
+{
+}
+
+
+void QGLPaintDevice::beginPaint()
+{
+ // Make sure our context is the current one:
+ QGLContext *ctx = context();
+ if (ctx != QGLContext::currentContext())
+ ctx->makeCurrent();
+
+ // Record the currently bound FBO so we can restore it again
+ // in endPaint() and bind this device's FBO
+ m_previousFBO = ctx->d_func()->current_fbo;
+ if (m_previousFBO != m_thisFBO) {
+ ctx->d_ptr->current_fbo = m_thisFBO;
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO);
+ }
+}
+
+void QGLPaintDevice::ensureActiveTarget()
+{
+ QGLContext* ctx = context();
+ if (ctx != QGLContext::currentContext())
+ ctx->makeCurrent();
+
+ if (ctx->d_ptr->current_fbo != m_thisFBO) {
+ ctx->d_ptr->current_fbo = m_thisFBO;
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO);
+ }
+}
+
+void QGLPaintDevice::endPaint()
+{
+ // Make sure the FBO bound at beginPaint is re-bound again here:
+ QGLContext *ctx = context();
+ if (m_previousFBO != ctx->d_func()->current_fbo) {
+ ctx->d_ptr->current_fbo = m_previousFBO;
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_previousFBO);
+ }
+}
+
+QGLFormat QGLPaintDevice::format() const
+{
+ return context()->format();
+}
+
+
+
+
+////////////////// QGLWidgetGLPaintDevice //////////////////
+
+QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice()
+{
+}
+
+QPaintEngine* QGLWidgetGLPaintDevice::paintEngine() const
+{
+ return glWidget->paintEngine();
+}
+
+void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w)
+{
+ glWidget = w;
+}
+
+void QGLWidgetGLPaintDevice::beginPaint()
+{
+ QGLPaintDevice::beginPaint();
+ if (!glWidget->d_func()->disable_clear_on_painter_begin && glWidget->autoFillBackground()) {
+ if (glWidget->testAttribute(Qt::WA_TranslucentBackground))
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ else {
+ const QColor &c = glWidget->palette().brush(glWidget->backgroundRole()).color();
+ float alpha = c.alphaF();
+ glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha);
+ }
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+}
+
+void QGLWidgetGLPaintDevice::endPaint()
+{
+ if (glWidget->autoBufferSwap())
+ glWidget->swapBuffers();
+ QGLPaintDevice::endPaint();
+}
+
+
+QSize QGLWidgetGLPaintDevice::size() const
+{
+ return glWidget->size();
+}
+
+QGLContext* QGLWidgetGLPaintDevice::context() const
+{
+ return const_cast<QGLContext*>(glWidget->context());
+}
+
+// returns the QGLPaintDevice for the given QPaintDevice
+QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd)
+{
+ QGLPaintDevice* glpd = 0;
+
+ switch(pd->devType()) {
+ case QInternal::Widget:
+ // Should not be called on a non-gl widget:
+ Q_ASSERT(qobject_cast<QGLWidget*>(static_cast<QWidget*>(pd)));
+ glpd = &(static_cast<QGLWidget*>(pd)->d_func()->glDevice);
+ break;
+ case QInternal::Pbuffer:
+ glpd = &(static_cast<QGLPixelBuffer*>(pd)->d_func()->glDevice);
+ break;
+ case QInternal::FramebufferObject:
+ glpd = &(static_cast<QGLFramebufferObject*>(pd)->d_func()->glDevice);
+ break;
+ case QInternal::Pixmap: {
+ QPixmapData* pmd = static_cast<QPixmap*>(pd)->pixmapData();
+ Q_ASSERT(pmd->classId() == QPixmapData::OpenGLClass);
+ glpd = static_cast<QGLPixmapData*>(pmd)->glDevice();
+ break;
+ }
+ default:
+ qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType());
+ break;
+ }
+
+ return glpd;
+}
+
+QT_END_NAMESPACE
diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h
new file mode 100644
index 0000000..32a1275
--- /dev/null
+++ b/src/opengl/qglpaintdevice_p.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGLPAINTDEVICE_P_H
+#define QGLPAINTDEVICE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QtOpenGL module. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+
+#include <qpaintdevice.h>
+#include <qgl.h>
+
+
+QT_BEGIN_NAMESPACE
+
+class QGLPaintDevice : public QPaintDevice
+{
+public:
+ QGLPaintDevice();
+ virtual ~QGLPaintDevice();
+
+ int devType() const {return QInternal::OpenGL;}
+
+ virtual void beginPaint();
+ virtual void ensureActiveTarget();
+ virtual void endPaint();
+
+ virtual QGLContext* context() const = 0;
+ QGLFormat format() const;
+ virtual QSize size() const = 0;
+
+ // returns the QGLPaintDevice for the given QPaintDevice
+ static QGLPaintDevice* getDevice(QPaintDevice*);
+
+protected:
+ GLuint m_previousFBO;
+ GLuint m_thisFBO;
+};
+
+
+// Wraps a QGLWidget
+class QGLWidget;
+class QGLWidgetGLPaintDevice : public QGLPaintDevice
+{
+public:
+ QGLWidgetGLPaintDevice();
+
+ virtual QPaintEngine* paintEngine() const;
+
+ // QGLWidgets need to do swapBufers in endPaint:
+ virtual void beginPaint();
+ virtual void endPaint();
+ virtual QSize size() const;
+ virtual QGLContext* context() const;
+
+ void setWidget(QGLWidget*);
+
+private:
+ friend class QGLWidget;
+ QGLWidget *glWidget;
+};
+
+QT_END_NAMESPACE
+
+#endif // QGLPAINTDEVICE_P_H
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index f082ff0..b6a919c 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -100,6 +100,22 @@ void qgl_cleanup_glyph_cache(QGLContext *) {}
extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool);
+
+QGLContext* QGLPBufferGLPaintDevice::context() const
+{
+ return pbuf->d_func()->qctx;
+}
+
+void QGLPBufferGLPaintDevice::endPaint() {
+ glFlush();
+ QGLPaintDevice::endPaint();
+}
+
+void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb)
+{
+ pbuf = pb;
+}
+
void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget)
{
Q_Q(QGLPixelBuffer);
@@ -115,6 +131,7 @@ void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &form
shareWidget->d_func()->glcx->d_func()->sharing = true;
}
+ glDevice.setPBuffer(q);
qctx->d_func()->paintDevice = q;
qctx->d_func()->valid = true;
#if defined(Q_WS_WIN) && !defined(QT_OPENGL_ES)
diff --git a/src/opengl/qglpixelbuffer.h b/src/opengl/qglpixelbuffer.h
index 5e81ea3..fe313a6 100644
--- a/src/opengl/qglpixelbuffer.h
+++ b/src/opengl/qglpixelbuffer.h
@@ -110,6 +110,8 @@ private:
QScopedPointer<QGLPixelBufferPrivate> d_ptr;
friend class QGLDrawable;
friend class QGLWindowSurface;
+ friend class QGLPaintDevice;
+ friend class QGLPBufferGLPaintDevice;
};
QT_END_NAMESPACE
diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h
index 74cb330..96d41d7 100644
--- a/src/opengl/qglpixelbuffer_p.h
+++ b/src/opengl/qglpixelbuffer_p.h
@@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE
QT_BEGIN_INCLUDE_NAMESPACE
#include "QtOpenGL/qglpixelbuffer.h"
#include <private/qgl_p.h>
+#include <private/qglpaintdevice_p.h>
#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
#include <GL/glx.h>
@@ -135,6 +136,19 @@ QT_END_INCLUDE_NAMESPACE
class QEglContext;
+
+class QGLPBufferGLPaintDevice : public QGLPaintDevice
+{
+public:
+ virtual QPaintEngine* paintEngine() const {return pbuf->paintEngine();}
+ virtual QSize size() const {return pbuf->size();}
+ virtual QGLContext* context() const;
+ virtual void endPaint();
+ void setPBuffer(QGLPixelBuffer* pb);
+private:
+ QGLPixelBuffer* pbuf;
+};
+
class QGLPixelBufferPrivate {
Q_DECLARE_PUBLIC(QGLPixelBuffer)
public:
@@ -154,6 +168,7 @@ public:
QGLPixelBuffer *q_ptr;
bool invalid;
QGLContext *qctx;
+ QGLPBufferGLPaintDevice glDevice;
QGLFormat format;
QGLFormat req_format;
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index bf4d4b9..34fff10 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -49,6 +49,7 @@
#include "qbrush.h"
#include "qgl.h"
#include <private/qgl_p.h>
+#include <private/qglpaintdevice_p.h>
#include <private/qpainter_p.h>
#include "qmap.h"
#include <private/qpaintengine_opengl_p.h>
@@ -75,7 +76,7 @@
#include "qgl_cl_p.h"
#endif
-#define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast<QGLContext *>(drawable.context());
+#define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast<QGLContext *>(device->context());
#include <stdlib.h>
#include "qpaintengine_opengl_p.h"
@@ -286,7 +287,7 @@ public Q_SLOTS:
}
private:
- QGLDrawable drawable;
+ QGLPaintDevice* device;
QGLFramebufferObject *offscreen;
QGLContext *ctx;
@@ -305,7 +306,13 @@ private:
inline void QGLOffscreen::setDevice(QPaintDevice *pdev)
{
- drawable.setDevice(pdev);
+ if (pdev->devType() == QInternal::OpenGL)
+ device = static_cast<QGLPaintDevice*>(pdev);
+ else
+ device = QGLPaintDevice::getDevice(pdev);
+
+ if (!device)
+ return;
drawable_fbo = (pdev->devType() == QInternal::FramebufferObject);
}
@@ -329,12 +336,12 @@ void QGLOffscreen::initialize()
activated = true;
initialized = true;
- int dim = qMax(2048, static_cast<int>(qt_next_power_of_two(qMax(drawable.size().width(), drawable.size().height()))));
+ int dim = qMax(2048, static_cast<int>(qt_next_power_of_two(qMax(device->size().width(), device->size().height()))));
- bool shared_context = qgl_share_reg()->checkSharing(drawable.context(), ctx);
+ bool shared_context = qgl_share_reg()->checkSharing(device->context(), ctx);
bool would_fail = last_failed_size.isValid() &&
- (drawable.size().width() >= last_failed_size.width() ||
- drawable.size().height() >= last_failed_size.height());
+ (device->size().width() >= last_failed_size.width() ||
+ device->size().height() >= last_failed_size.height());
bool needs_refresh = dim > mask_dim || !shared_context;
if (needs_refresh && !would_fail) {
@@ -348,13 +355,13 @@ void QGLOffscreen::initialize()
delete offscreen;
offscreen = 0;
mask_dim = 0;
- last_failed_size = drawable.size();
+ last_failed_size = device->size();
}
}
qt_mask_texture_cache()->setOffscreenSize(offscreenSize());
- qt_mask_texture_cache()->setDrawableSize(drawable.size());
- ctx = drawable.context();
+ qt_mask_texture_cache()->setDrawableSize(device->size());
+ ctx = device->context();
#endif
}
@@ -428,11 +435,11 @@ inline void QGLOffscreen::release()
DEBUG_ONCE_STR("QGLOffscreen: releasing offscreen");
if (drawable_fbo)
- drawable.makeCurrent();
+ device->ensureActiveTarget(); //###
else
offscreen->release();
- QSize sz(drawable.size());
+ QSize sz(device->size());
glViewport(0, 0, sz.width(), sz.height());
glMatrixMode(GL_PROJECTION);
@@ -455,7 +462,7 @@ inline bool QGLOffscreen::isBound() const
inline QSize QGLOffscreen::drawableSize() const
{
- return drawable.size();
+ return device->size();
}
inline QSize QGLOffscreen::offscreenSize() const
@@ -757,7 +764,7 @@ public:
GLubyte pen_color[4];
GLubyte brush_color[4];
QTransform::TransformationType txop;
- QGLDrawable drawable;
+ QGLPaintDevice* device;
QGLOffscreen offscreen;
qreal inverseScale;
@@ -1167,7 +1174,7 @@ void QOpenGLPaintEnginePrivate::createGradientPaletteTexture(const QGradient& g)
#ifdef QT_OPENGL_ES //###
Q_UNUSED(g);
#else
- GLuint texId = qt_opengl_gradient_cache()->getBuffer(g, opacity, drawable.context());
+ GLuint texId = qt_opengl_gradient_cache()->getBuffer(g, opacity, device->context());
glBindTexture(GL_TEXTURE_1D, texId);
grad_palette = texId;
if (g.spread() == QGradient::RepeatSpread || g.type() == QGradient::ConicalGradient)
@@ -1236,12 +1243,19 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev)
{
Q_D(QOpenGLPaintEngine);
- d->drawable.setDevice(pdev);
+ if (pdev->devType() == QInternal::OpenGL)
+ d->device = static_cast<QGLPaintDevice*>(pdev);
+ else
+ d->device = QGLPaintDevice::getDevice(pdev);
+
+ if (!d->device)
+ return false;
+
d->offscreen.setDevice(pdev);
d->has_fast_pen = false;
d->inverseScale = 1;
d->opacity = 1;
- d->drawable.makeCurrent();
+ d->device->beginPaint();
d->matrix = QTransform();
d->has_antialiasing = false;
d->high_quality_antialiasing = false;
@@ -1256,7 +1270,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev)
bool has_frag_program = (QGLExtensions::glExtensions & QGLExtensions::FragmentProgram)
&& (pdev->devType() != QInternal::Pixmap);
- QGLContext *ctx = const_cast<QGLContext *>(d->drawable.context());
+ QGLContext *ctx = const_cast<QGLContext *>(d->device->context());
if (!ctx) {
qWarning() << "QOpenGLPaintEngine: paint device doesn't have a valid GL context.";
return false;
@@ -1265,9 +1279,9 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev)
if (has_frag_program)
has_frag_program = qt_resolve_frag_program_extensions(ctx) && qt_resolve_version_1_3_functions(ctx);
- d->use_stencil_method = d->drawable.format().stencil()
+ d->use_stencil_method = d->device->format().stencil()
&& (QGLExtensions::glExtensions & QGLExtensions::StencilWrap);
- if (d->drawable.format().directRendering()
+ if (d->device->format().directRendering()
&& (d->use_stencil_method && QGLExtensions::glExtensions & QGLExtensions::StencilTwoSide))
d->has_stencil_face_ext = qt_resolve_stencil_face_extension(ctx);
@@ -1333,23 +1347,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev)
d->offscreen.begin();
- if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) {
-
- if (d->drawable.hasTransparentBackground())
- glClearColor(0.0, 0.0, 0.0, 0.0);
- else {
- const QColor &c = d->drawable.backgroundColor();
- glClearColor(c.redF(), c.greenF(), c.blueF(), 1.0);
- }
-
- GLbitfield clearBits = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
-#ifndef QT_OPENGL_ES
- clearBits |= GL_ACCUM_BUFFER_BIT;
-#endif
- glClear(clearBits);
- }
-
- QSize sz(d->drawable.size());
+ QSize sz(d->device->size());
glViewport(0, 0, sz.width(), sz.height()); // XXX (Embedded): We need a solution for GLWidgets that draw in a part or a bigger surface...
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -1366,7 +1364,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev)
#ifdef QT_OPENGL_ES
d->max_texture_size = ctx->d_func()->maxTextureSize();
#else
- bool shared_ctx = qgl_share_reg()->checkSharing(d->drawable.context(), d->shader_ctx);
+ bool shared_ctx = qgl_share_reg()->checkSharing(d->device->context(), d->shader_ctx);
if (shared_ctx) {
d->max_texture_size = d->shader_ctx->d_func()->maxTextureSize();
@@ -1382,7 +1380,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev)
glDeleteTextures(1, &d->drawable_texture);
ctx->makeCurrent();
}
- d->shader_ctx = d->drawable.context();
+ d->shader_ctx = d->device->context();
glGenTextures(1, &d->grad_palette);
qt_mask_texture_cache()->clearCache();
@@ -1417,7 +1415,7 @@ bool QOpenGLPaintEngine::end()
Q_D(QOpenGLPaintEngine);
d->flushDrawQueue();
d->offscreen.end();
- QGLContext *ctx = const_cast<QGLContext *>(d->drawable.context());
+ QGLContext *ctx = const_cast<QGLContext *>(d->device->context());
if (!ctx->d_ptr->internal_context) {
glMatrixMode(GL_TEXTURE);
glPopMatrix();
@@ -1434,8 +1432,7 @@ bool QOpenGLPaintEngine::end()
glPopClientAttrib();
}
#endif
- d->drawable.swapBuffers();
- d->drawable.doneCurrent();
+ d->device->endPaint();
qt_mask_texture_cache()->maintainCache();
return true;
@@ -1961,7 +1958,7 @@ void QOpenGLPaintEnginePrivate::fillVertexArray(Qt::FillRule fillRule)
const int left = rect.left();
const int width = rect.width();
- const int bottom = drawable.size().height() - (rect.bottom() + 1);
+ const int bottom = device->size().height() - (rect.bottom() + 1);
const int height = rect.height();
glScissor(left, bottom, width, height);
@@ -2242,7 +2239,7 @@ void QOpenGLPaintEnginePrivate::updateDepthClip()
const int left = fastClip.left();
const int width = fastClip.width();
- const int bottom = drawable.size().height() - (fastClip.bottom() + 1);
+ const int bottom = device->size().height() - (fastClip.bottom() + 1);
const int height = fastClip.height();
glScissor(left, bottom, width, height);
@@ -2325,7 +2322,7 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe
// clipping is only supported when a stencil or depth buffer is
// available
- if (!d->drawable.format().depth())
+ if (!d->device->format().depth())
return;
d->use_system_clip = false;
@@ -2362,7 +2359,7 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe
path.addRect(untransformedRects[0]);
path = d->matrix.map(path);
- if (path.contains(QRectF(QPointF(), d->drawable.size())))
+ if (path.contains(QRectF(QPointF(), d->device->size())))
isScreenClip = true;
}
}
@@ -3369,7 +3366,7 @@ void QOpenGLPaintEnginePrivate::drawOffscreenPath(const QPainterPath &path)
disableClipping();
- GLuint program = qt_gl_program_cache()->getProgram(drawable.context(),
+ GLuint program = qt_gl_program_cache()->getProgram(device->context(),
FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true);
QGLPathMaskGenerator maskGenerator(path, matrix, offscreen, program);
addItem(qt_mask_texture_cache()->getMask(maskGenerator, this));
@@ -3506,7 +3503,7 @@ void QOpenGLPaintEngine::drawRects(const QRectF *rects, int rectCount)
if (d->has_brush) {
d->disableClipping();
- GLuint program = qt_gl_program_cache()->getProgram(d->drawable.context(),
+ GLuint program = qt_gl_program_cache()->getProgram(d->device->context(),
FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true);
if (d->matrix.type() >= QTransform::TxProject) {
@@ -3916,7 +3913,7 @@ void QOpenGLPaintEnginePrivate::strokeLines(const QPainterPath &path)
qreal penWidth = cpen.widthF();
- GLuint program = qt_gl_program_cache()->getProgram(drawable.context(),
+ GLuint program = qt_gl_program_cache()->getProgram(device->context(),
FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true);
QGLLineMaskGenerator maskGenerator(path, matrix, penWidth == 0 ? 1.0 : penWidth,
offscreen, program);
@@ -4302,7 +4299,7 @@ void QOpenGLPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QR
else {
GLenum target = qt_gl_preferredTextureTarget();
d->flushDrawQueue();
- d->drawable.bindTexture(pm, target);
+ d->device->context()->bindTexture(pm, target);
drawTextureRect(pm.width(), pm.height(), r, sr, target);
}
}
@@ -4336,9 +4333,9 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con
d->flushDrawQueue();
if (scaled.isNull())
- d->drawable.bindTexture(pm);
+ d->device->context()->bindTexture(pm);
else
- d->drawable.bindTexture(scaled);
+ d->device->context()->bindTexture(scaled);
updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, d->use_smooth_pixmap_transform);
#ifndef QT_OPENGL_ES
@@ -4404,7 +4401,7 @@ void QOpenGLPaintEngine::drawImage(const QRectF &r, const QImage &image, const Q
else {
GLenum target = qt_gl_preferredTextureTarget();
d->flushDrawQueue();
- d->drawable.bindTexture(image, target);
+ d->device->context()->bindTexture(image, target);
drawTextureRect(image.width(), image.height(), r, sr, target);
}
}
@@ -4871,7 +4868,7 @@ void QOpenGLPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
// make sure the glyphs we want to draw are in the cache
- qt_glyph_cache()->cacheGlyphs(d->drawable.context(), ti, glyphs);
+ qt_glyph_cache()->cacheGlyphs(d->device->context(), ti, glyphs);
d->setGradientOps(Qt::SolidPattern, QRectF()); // turns off gradient ops
qt_glColor4ubv(d->pen_color);
@@ -4949,7 +4946,7 @@ void QOpenGLPaintEngine::drawEllipse(const QRectF &rect)
glPushMatrix();
glLoadIdentity();
- GLuint program = qt_gl_program_cache()->getProgram(d->drawable.context(),
+ GLuint program = qt_gl_program_cache()->getProgram(d->device->context(),
FRAGMENT_PROGRAM_MASK_ELLIPSE_AA, 0, true);
QGLEllipseMaskGenerator maskGenerator(rect,
d->matrix,
@@ -5084,10 +5081,10 @@ void QOpenGLPaintEnginePrivate::copyDrawable(const QRectF &rect)
QRectF screen_rect = rect.adjusted(-1, -1, 1, 1);
int left = qMax(0, static_cast<int>(screen_rect.left()));
- int width = qMin(drawable.size().width() - left, static_cast<int>(screen_rect.width()) + 1);
+ int width = qMin(device->size().width() - left, static_cast<int>(screen_rect.width()) + 1);
- int bottom = qMax(0, static_cast<int>(drawable.size().height() - screen_rect.bottom()));
- int height = qMin(drawable.size().height() - bottom, static_cast<int>(screen_rect.height()) + 1);
+ int bottom = qMax(0, static_cast<int>(device->size().height() - screen_rect.bottom()));
+ int height = qMin(device->size().height() - bottom, static_cast<int>(screen_rect.height()) + 1);
glBindTexture(GL_TEXTURE_2D, drawable_texture);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, left, bottom, left, bottom, width, height);
@@ -5181,9 +5178,9 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType *
glActiveTexture(GL_TEXTURE0 + brush_texture_location);
if (current_style == Qt::TexturePattern)
- drawable.bindTexture(cbrush.textureImage());
+ device->context()->bindTexture(cbrush.textureImage());
else
- drawable.bindTexture(qt_imageForBrush(current_style, true));
+ device->context()->bindTexture(qt_imageForBrush(current_style, true));
updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, use_smooth_pixmap_transform);
}
@@ -5191,7 +5188,7 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType *
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
- GLuint program = qt_gl_program_cache()->getProgram(drawable.context(),
+ GLuint program = qt_gl_program_cache()->getProgram(device->context(),
fragment_brush,
fragment_composition_mode, false);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program);
@@ -5263,7 +5260,7 @@ void QOpenGLPaintEnginePrivate::drawItem(const QDrawQueueItem &item)
setGradientOps(item.brush, item.location.screen_rect);
composite(item.location.screen_rect, item.location.rect.topLeft() - item.location.screen_rect.topLeft()
- - QPoint(0, offscreen.offscreenSize().height() - drawable.size().height()));
+ - QPoint(0, offscreen.offscreenSize().height() - device->size().height()));
}
void QOpenGLPaintEnginePrivate::flushDrawQueue()
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index d63d2ad..ae616a8 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -80,12 +80,7 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize
for (int i = 0; !chosen && i < m_fbos.size(); ++i) {
QGLFramebufferObject *fbo = m_fbos.at(i);
- QGLFramebufferObjectFormat format = fbo->format();
- if (format.samples() == requestFormat.samples()
- && format.attachment() == requestFormat.attachment()
- && format.textureTarget() == requestFormat.textureTarget()
- && format.internalTextureFormat() == requestFormat.internalTextureFormat())
- {
+ if (fbo->format() == requestFormat) {
// choose the fbo with a matching format and the closest size
if (!candidate || areaDiff(requestSize, candidate) > areaDiff(requestSize, fbo))
candidate = fbo;
@@ -132,6 +127,76 @@ void QGLFramebufferObjectPool::release(QGLFramebufferObject *fbo)
m_fbos << fbo;
}
+
+QPaintEngine* QGLPixmapGLPaintDevice::paintEngine() const
+{
+ return data->paintEngine();
+}
+
+void QGLPixmapGLPaintDevice::beginPaint()
+{
+ if (!data->isValid())
+ return;
+
+ // QGLPaintDevice::beginPaint will store the current binding and replace
+ // it with m_thisFBO:
+ m_thisFBO = data->m_renderFbo->handle();
+ QGLPaintDevice::beginPaint();
+
+ Q_ASSERT(data->paintEngine()->type() == QPaintEngine::OpenGL2);
+
+ // QPixmap::fill() is deferred until now, where we actually need to do the fill:
+ if (data->needsFill()) {
+ const QColor &c = data->fillColor();
+ float alpha = c.alphaF();
+ glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+ else if (!data->isUninitialized()) {
+ // If the pixmap (GL Texture) has valid content (it has been
+ // uploaded from an image or rendered into before), we need to
+ // copy it from the texture to the render FBO.
+
+ // Pass false to tell bind to _not_ copy the FBO into the texture!
+ GLuint texId = data->bind(false);
+
+ QGL2PaintEngineEx* pe = static_cast<QGL2PaintEngineEx*>(data->paintEngine());
+ QRect rect(0, 0, data->width(), data->height());
+ pe->drawTexture(QRectF(rect), texId, rect.size(), QRectF(rect));
+ }
+}
+
+void QGLPixmapGLPaintDevice::endPaint()
+{
+ if (!data->isValid())
+ return;
+
+ data->copyBackFromRenderFbo(false);
+
+ data->m_renderFbo->release();
+ qgl_fbo_pool()->release(data->m_renderFbo);
+ data->m_renderFbo = 0;
+
+ // Base's endPaint will restore the previous FBO binding
+ QGLPaintDevice::endPaint();
+}
+
+QGLContext* QGLPixmapGLPaintDevice::context() const
+{
+ data->ensureCreated();
+ return data->m_ctx;
+}
+
+QSize QGLPixmapGLPaintDevice::size() const
+{
+ return data->size();
+}
+
+void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d)
+{
+ data = d;
+}
+
static int qt_gl_pixmap_serial = 0;
QGLPixmapData::QGLPixmapData(PixelType type)
@@ -144,6 +209,7 @@ QGLPixmapData::QGLPixmapData(PixelType type)
, m_hasAlpha(false)
{
setSerialNumber(++qt_gl_pixmap_serial);
+ m_glDevice.setPixmapData(this);
}
QGLPixmapData::~QGLPixmapData()
@@ -237,11 +303,6 @@ void QGLPixmapData::ensureCreated() const
m_texture.options &= ~QGLContext::MemoryManagedBindOption;
}
-QGLFramebufferObject *QGLPixmapData::fbo() const
-{
- return m_renderFbo;
-}
-
void QGLPixmapData::fromImage(const QImage &image,
Qt::ImageConversionFlags)
{
@@ -417,31 +478,6 @@ void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const
glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
}
-void QGLPixmapData::swapBuffers()
-{
- if (!isValid())
- return;
-
- copyBackFromRenderFbo(false);
- m_renderFbo->release();
-
- qgl_fbo_pool()->release(m_renderFbo);
-
- m_renderFbo = 0;
-}
-
-void QGLPixmapData::makeCurrent()
-{
- if (isValid() && m_renderFbo)
- m_renderFbo->bind();
-}
-
-void QGLPixmapData::doneCurrent()
-{
- if (isValid() && m_renderFbo)
- m_renderFbo->release();
-}
-
bool QGLPixmapData::useFramebufferObjects()
{
return QGLFramebufferObject::hasOpenGLFramebufferObjects()
@@ -490,6 +526,10 @@ QPaintEngine* QGLPixmapData::paintEngine() const
return m_source.paintEngine();
}
+
+// If copyBack is true, bind will copy the contents of the render
+// FBO to the texture (which is not bound to the texture, as it's
+// a multisample FBO).
GLuint QGLPixmapData::bind(bool copyBack) const
{
if (m_renderFbo && copyBack) {
@@ -509,12 +549,6 @@ GLuint QGLPixmapData::bind(bool copyBack) const
return id;
}
-GLuint QGLPixmapData::textureId() const
-{
- ensureCreated();
- return m_texture.id;
-}
-
QGLTexture* QGLPixmapData::texture() const
{
return &m_texture;
@@ -553,4 +587,9 @@ int QGLPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
}
}
+QGLPaintDevice *QGLPixmapData::glDevice() const
+{
+ return &m_glDevice;
+}
+
QT_END_NAMESPACE
diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h
index ab1ff47..31ae7c7 100644
--- a/src/opengl/qpixmapdata_gl_p.h
+++ b/src/opengl/qpixmapdata_gl_p.h
@@ -57,12 +57,14 @@
#include "qgl.h"
#include "private/qpixmapdata_p.h"
+#include "private/qglpaintdevice_p.h"
QT_BEGIN_NAMESPACE
class QPaintEngine;
class QGLFramebufferObject;
class QGLFramebufferObjectFormat;
+class QGLPixmapData;
class QGLFramebufferObjectPool
{
@@ -76,31 +78,50 @@ private:
QGLFramebufferObjectPool* qgl_fbo_pool();
+
+class QGLPixmapGLPaintDevice : public QGLPaintDevice
+{
+public:
+ QPaintEngine* paintEngine() const;
+
+ void beginPaint();
+ void endPaint();
+ QGLContext* context() const;
+ QSize size() const;
+
+ void setPixmapData(QGLPixmapData*);
+private:
+ QGLPixmapData *data;
+};
+
+
class QGLPixmapData : public QPixmapData
{
public:
QGLPixmapData(PixelType type);
~QGLPixmapData();
- bool isValid() const;
-
+ // Re-implemented from QPixmapData:
void resize(int width, int height);
- void fromImage(const QImage &image,
- Qt::ImageConversionFlags flags);
+ void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
void copy(const QPixmapData *data, const QRect &rect);
-
bool scroll(int dx, int dy, const QRect &rect);
-
void fill(const QColor &color);
bool hasAlphaChannel() const;
QImage toImage() const;
QPaintEngine *paintEngine() const;
+ int metric(QPaintDevice::PaintDeviceMetric metric) const;
+ // For accessing as a target:
+ QGLPaintDevice *glDevice() const;
+
+ // For accessing as a source:
+ bool isValidContext(const QGLContext *ctx) const;
GLuint bind(bool copyBack = true) const;
- GLuint textureId() const;
QGLTexture *texture() const;
- bool isValidContext(const QGLContext *ctx) const;
+private:
+ bool isValid() const;
void ensureCreated() const;
@@ -109,22 +130,13 @@ public:
bool needsFill() const { return m_hasFillColor; }
QColor fillColor() const { return m_fillColor; }
- QSize size() const { return QSize(w, h); }
-
- QGLFramebufferObject *fbo() const;
- void makeCurrent();
- void doneCurrent();
- void swapBuffers();
-protected:
- int metric(QPaintDevice::PaintDeviceMetric metric) const;
-
-private:
QGLPixmapData(const QGLPixmapData &other);
QGLPixmapData &operator=(const QGLPixmapData &other);
void copyBackFromRenderFbo(bool keepCurrentFboBound) const;
+ QSize size() const { return QSize(w, h); }
static bool useFramebufferObjects();
@@ -145,6 +157,10 @@ private:
mutable bool m_hasFillColor;
mutable bool m_hasAlpha;
+
+ mutable QGLPixmapGLPaintDevice m_glDevice;
+
+ friend class QGLPixmapGLPaintDevice;
};
QT_END_NAMESPACE
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index a85b9ae..3a6ed06 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -229,6 +229,7 @@ QGLWidget* qt_gl_share_widget()
return _qt_gl_share_widget()->shareWidget();
}
+
struct QGLWindowSurfacePrivate
{
QGLFramebufferObject *fbo;
@@ -248,10 +249,49 @@ struct QGLWindowSurfacePrivate
QSize size;
QList<QImage> buffers;
+ QGLWindowSurfaceGLPaintDevice glDevice;
+ QGLWindowSurface* q_ptr;
};
QGLFormat QGLWindowSurface::surfaceFormat;
+void QGLWindowSurfaceGLPaintDevice::endPaint()
+{
+ glFlush();
+ QGLPaintDevice::endPaint();
+}
+
+QSize QGLWindowSurfaceGLPaintDevice::size() const
+{
+ return d->size;
+}
+
+QGLContext* QGLWindowSurfaceGLPaintDevice::context() const
+{
+ return d->ctx;
+}
+
+
+int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const
+{
+ return d->q_ptr->window()->metric(m);
+}
+
+Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine)
+
+#if !defined (QT_OPENGL_ES_2)
+Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine)
+#endif
+
+QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
+{
+#if !defined(QT_OPENGL_ES_2)
+ if (!qt_gl_preferGL2Engine())
+ return qt_gl_window_surface_engine();
+#endif
+ return qt_gl_window_surface_2_engine();
+}
+
QGLWindowSurface::QGLWindowSurface(QWidget *window)
: QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
{
@@ -263,6 +303,8 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window)
d_ptr->tried_fbo = false;
d_ptr->tried_pb = false;
d_ptr->destructive_swap_buffers = qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull();
+ d_ptr->glDevice.d = d_ptr;
+ d_ptr->q_ptr = this;
}
QGLWindowSurface::~QGLWindowSurface()
@@ -320,27 +362,6 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size();
}
-Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine)
-
-#if !defined (QT_OPENGL_ES_2)
-Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine)
-#endif
-
-/*! \reimp */
-QPaintEngine *QGLWindowSurface::paintEngine() const
-{
-#if !defined(QT_OPENGL_ES_2)
- if (!qt_gl_preferGL2Engine())
- return qt_gl_window_surface_engine();
-#endif
- return qt_gl_window_surface_2_engine();
-}
-
-int QGLWindowSurface::metric(PaintDeviceMetric m) const
-{
- return window()->metric(m);
-}
-
QGLContext *QGLWindowSurface::context() const
{
return d_ptr->ctx;
@@ -354,7 +375,7 @@ QPaintDevice *QGLWindowSurface::paintDevice()
return d_ptr->pb;
if (d_ptr->ctx)
- return this;
+ return &d_ptr->glDevice;
QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
ctx->makeCurrent();
diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h
index ad583b2..7b18f2e 100644
--- a/src/opengl/qwindowsurface_gl_p.h
+++ b/src/opengl/qwindowsurface_gl_p.h
@@ -56,6 +56,7 @@
#include <qglobal.h>
#include <qgl.h>
#include <private/qwindowsurface_p.h>
+#include <private/qglpaintdevice_p.h>
QT_BEGIN_NAMESPACE
@@ -65,7 +66,18 @@ class QRegion;
class QWidget;
struct QGLWindowSurfacePrivate;
-class QGLWindowSurface : public QObject, public QWindowSurface, public QPaintDevice
+class QGLWindowSurfaceGLPaintDevice : public QGLPaintDevice
+{
+public:
+ QPaintEngine* paintEngine() const;
+ void endPaint();
+ QSize size() const;
+ int metric(PaintDeviceMetric m) const;
+ QGLContext* context() const;
+ QGLWindowSurfacePrivate* d;
+};
+
+class QGLWindowSurface : public QObject, public QWindowSurface // , public QPaintDevice
{
Q_OBJECT
public:
@@ -87,11 +99,6 @@ public:
static QGLFormat surfaceFormat;
- QPaintEngine *paintEngine() const;
-
-protected:
- int metric(PaintDeviceMetric metric) const;
-
private slots:
void deleted(QObject *object);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index 6550683..f88055e 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -330,17 +330,17 @@ bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescripti
#endif
-void QDirectFBPixmapData::fromImage(const QImage &image,
+void QDirectFBPixmapData::fromImage(const QImage &img,
Qt::ImageConversionFlags flags)
{
- if (image.depth() == 1) {
- fromImage(image.convertToFormat(screen->alphaPixmapFormat()), flags);
+ if (img.depth() == 1) {
+ fromImage(img.convertToFormat(screen->alphaPixmapFormat()), flags);
return;
}
- if (image.hasAlphaChannel()
+ if (img.hasAlphaChannel()
#ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION
- && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(image))
+ && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img))
#endif
) {
alpha = true;
@@ -349,13 +349,37 @@ void QDirectFBPixmapData::fromImage(const QImage &image,
alpha = false;
imageFormat = screen->pixelFormat();
}
+ QImage image;
+ if (flags != Qt::AutoColor) {
+ image = img.convertToFormat(imageFormat, flags);
+ flags = Qt::AutoColor;
+ } else {
+ image = img;
+ }
+
+ IDirectFBSurface *imageSurface = screen->createDFBSurface(image, image.format(), QDirectFBScreen::DontTrackSurface);
+ if (!imageSurface) {
+ qWarning("QDirectFBPixmapData::fromImage()");
+ invalidate();
+ return;
+ }
- dfbSurface = screen->createDFBSurface(image, imageFormat, QDirectFBScreen::TrackSurface|QDirectFBScreen::NoPreallocated);
+ dfbSurface = screen->createDFBSurface(image.size(), imageFormat, QDirectFBScreen::TrackSurface);
if (!dfbSurface) {
qWarning("QDirectFBPixmapData::fromImage()");
invalidate();
return;
}
+
+ if (image.hasAlphaChannel()) {
+ dfbSurface->Clear(dfbSurface, 0, 0, 0, 0);
+ dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL);
+ } else {
+ dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
+ }
+ dfbSurface->Blit(dfbSurface, imageSurface, 0, 0, 0);
+ imageSurface->Release(imageSurface);
+
w = image.width();
h = image.height();
is_null = (w <= 0 || h <= 0);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
index 46d06ef..5955f27 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
@@ -66,7 +66,7 @@ QT_MODULE(Gui)
#if !defined QT_DIRECTFB_IMAGECACHE && !defined QT_NO_DIRECTFB_IMAGECACHE
#define QT_NO_DIRECTFB_IMAGECACHE
#endif
-#if !defined QT_DIRECTFB_NO_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER
+#if !defined QT_NO_DIRECTFB_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER
#define QT_DIRECTFB_IMAGEPROVIDER
#endif
#if !defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && !defined QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index b1ffe69..82c2f81 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -127,6 +127,8 @@ void QDirectFBWindowSurface::createWindow(const QRect &rect)
qFatal("QDirectFBWindowSurface: Unable to get primary display layer!");
DFBWindowDescription description;
+ memset(&description, 0, sizeof(DFBWindowDescription));
+
description.caps = DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER;
description.flags = DWDESC_CAPS|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY;
diff --git a/src/scripttools/debugging/qscriptdebuggerbackend.cpp b/src/scripttools/debugging/qscriptdebuggerbackend.cpp
index 2efff04..feaea63 100644
--- a/src/scripttools/debugging/qscriptdebuggerbackend.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerbackend.cpp
@@ -805,13 +805,7 @@ int QScriptDebuggerBackend::contextCount() const
{
if (!engine())
return 0;
- int count = 0;
- QScriptContext *ctx = engine()->currentContext();
- while (ctx) {
- ++count;
- ctx = ctx->parentContext();
- }
- return count;
+ return contextIds().count();
}
/*!
diff --git a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
index 67cff02..556912e 100644
--- a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
+++ b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
@@ -2,6 +2,7 @@
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmldatetimeformatter.h>
+#include <QDebug>
class tst_datetimeformatter : public QObject
{
@@ -18,8 +19,11 @@ private slots:
void tst_datetimeformatter::date()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "DateTimeFormatter { date: \"2008-12-24\" }");
+ QmlComponent formatterComponent(&engine, QByteArray("import Qt 4.6\n DateTimeFormatter { date: \"2008-12-24\" }"),
+ QUrl("file://"));
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
QVERIFY(formatter != 0);
QDate date(2008,12,24);
@@ -38,8 +42,10 @@ void tst_datetimeformatter::date()
void tst_datetimeformatter::time()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "DateTimeFormatter { time: \"14:15:38.200\" }");
+ QmlComponent formatterComponent(&engine, "import Qt 4.6\n DateTimeFormatter { time: \"14:15:38.200\" }", QUrl("file://"));
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
QVERIFY(formatter != 0);
QTime time(14,15,38,200);
@@ -64,8 +70,10 @@ void tst_datetimeformatter::time()
void tst_datetimeformatter::dateTime()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }");
+ QmlComponent formatterComponent(&engine, "import Qt 4.6\n DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }", QUrl("file://"));
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
QVERIFY(formatter != 0);
QDateTime dateTime(QDate(1978,03,04),QTime(9,13,54));
diff --git a/tests/auto/declarative/layouts/data/grid-spacing.qml b/tests/auto/declarative/layouts/data/grid-spacing.qml
index f9ae204..5b4a30d 100644
--- a/tests/auto/declarative/layouts/data/grid-spacing.qml
+++ b/tests/auto/declarative/layouts/data/grid-spacing.qml
@@ -6,32 +6,32 @@ Item {
Grid {
columns: 3
spacing: 4
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "green"
width: 20
height: 50
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "blue"
width: 50
height: 20
}
- Rect {
- id: four
+ Rectangle {
+ objectName: "four"
color: "cyan"
width: 50
height: 50
}
- Rect {
- id: five
+ Rectangle {
+ objectName: "five"
color: "magenta"
width: 10
height: 10
diff --git a/tests/auto/declarative/layouts/data/grid.qml b/tests/auto/declarative/layouts/data/grid.qml
index 3861f63..830df6a 100644
--- a/tests/auto/declarative/layouts/data/grid.qml
+++ b/tests/auto/declarative/layouts/data/grid.qml
@@ -5,32 +5,32 @@ Item {
height: 480
Grid {
columns: 3
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "green"
width: 20
height: 50
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "blue"
width: 50
height: 20
}
- Rect {
- id: four
+ Rectangle {
+ objectName: "four"
color: "cyan"
width: 50
height: 50
}
- Rect {
- id: five
+ Rectangle {
+ objectName: "five"
color: "magenta"
width: 10
height: 10
diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing.qml b/tests/auto/declarative/layouts/data/horizontal-spacing.qml
index 8594ee6..32bf775 100644
--- a/tests/auto/declarative/layouts/data/horizontal-spacing.qml
+++ b/tests/auto/declarative/layouts/data/horizontal-spacing.qml
@@ -5,20 +5,20 @@ Item {
height: 480
Row {
spacing: 10
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/data/horizontal.qml b/tests/auto/declarative/layouts/data/horizontal.qml
index 673e77e..06ae151 100644
--- a/tests/auto/declarative/layouts/data/horizontal.qml
+++ b/tests/auto/declarative/layouts/data/horizontal.qml
@@ -4,20 +4,20 @@ Item {
width: 640
height: 480
Row {
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/data/vertical-spacing.qml b/tests/auto/declarative/layouts/data/vertical-spacing.qml
index 49bd8c6..69a8256 100644
--- a/tests/auto/declarative/layouts/data/vertical-spacing.qml
+++ b/tests/auto/declarative/layouts/data/vertical-spacing.qml
@@ -5,20 +5,20 @@ Item {
height: 480
Column {
spacing: 10
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/data/vertical.qml b/tests/auto/declarative/layouts/data/vertical.qml
index c8d3a11..856c180 100644
--- a/tests/auto/declarative/layouts/data/vertical.qml
+++ b/tests/auto/declarative/layouts/data/vertical.qml
@@ -4,20 +4,20 @@ Item {
width: 640
height: 480
Column {
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
index cd4678e..3416b2e 100644
--- a/tests/auto/declarative/layouts/tst_layouts.cpp
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -20,8 +20,6 @@ private slots:
private:
QFxView *createView(const QString &filename);
- template<typename T>
- T *findItem(QFxItem *parent, const QString &id, int index=-1);
};
tst_QFxLayouts::tst_QFxLayouts()
@@ -35,13 +33,13 @@ void tst_QFxLayouts::test_horizontal()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -59,13 +57,13 @@ void tst_QFxLayouts::test_horizontal_spacing()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -83,13 +81,13 @@ void tst_QFxLayouts::test_vertical()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -107,13 +105,13 @@ void tst_QFxLayouts::test_vertical_spacing()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -131,15 +129,15 @@ void tst_QFxLayouts::test_grid()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
- QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QFxRect *four = canvas->root()->findChild<QFxRect*>("four");
QVERIFY(four != 0);
- QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QFxRect *five = canvas->root()->findChild<QFxRect*>("five");
QVERIFY(five != 0);
QCOMPARE(one->x(), 0.0);
@@ -161,15 +159,15 @@ void tst_QFxLayouts::test_grid_spacing()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
- QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QFxRect *four = canvas->root()->findChild<QFxRect*>("four");
QVERIFY(four != 0);
- QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QFxRect *five = canvas->root()->findChild<QFxRect*>("five");
QVERIFY(five != 0);
QCOMPARE(one->x(), 0.0);
@@ -196,36 +194,6 @@ QFxView *tst_QFxLayouts::createView(const QString &filename)
return canvas;
}
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
-*/
-template<typename T>
-T *tst_QFxLayouts::findItem(QFxItem *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) {
- QFxItem *item = qobject_cast<QFxItem*>(parent->QGraphicsObject::children().at(i));
- if(!item)
- continue;
- //qDebug() << item << item->objectName();
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QmlExpression e(qmlContext(item), "index", item);
- e.setTrackChange(false);
- if (e.value().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
QTEST_MAIN(tst_QFxLayouts)
diff --git a/tests/auto/declarative/listview/data/listview.qml b/tests/auto/declarative/listview/data/listview.qml
index 7a3d76f..1a241eb 100644
--- a/tests/auto/declarative/listview/data/listview.qml
+++ b/tests/auto/declarative/listview/data/listview.qml
@@ -9,6 +9,7 @@ Rectangle {
id: Delegate
Item {
id: wrapper
+ objectName: "wrapper"
height: 20
width: 240
Text {
@@ -17,11 +18,13 @@ Rectangle {
Text {
x: 30
id: textName
+ objectName: "textName"
text: name
}
Text {
x: 120
id: textNumber
+ objectName: "textNumber"
text: number
}
Text {
@@ -33,6 +36,7 @@ Rectangle {
]
ListView {
id: list
+ objectName: "list"
width: 240
height: 320
model: testModel
diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp
index 8bf9c8a..ebc3053 100644
--- a/tests/auto/declarative/listview/tst_listview.cpp
+++ b/tests/auto/declarative/listview/tst_listview.cpp
@@ -188,7 +188,7 @@ void tst_QFxListView::items()
QFxItem *viewport = listview->viewport();
QVERIFY(viewport != 0);
- QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible
for (int i = 0; i < model.count(); ++i) {
QFxText *name = findItem<QFxText>(viewport, "textName", i);
@@ -262,7 +262,7 @@ void tst_QFxListView::inserted()
// let transitions settle.
QTest::qWait(1000);
- QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible
QFxText *name = findItem<QFxText>(viewport, "textName", 1);
QVERIFY(name != 0);
@@ -282,7 +282,7 @@ void tst_QFxListView::inserted()
// let transitions settle.
QTest::qWait(1000);
- QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible
name = findItem<QFxText>(viewport, "textName", 0);
QVERIFY(name != 0);
@@ -336,7 +336,7 @@ void tst_QFxListView::removed()
QCOMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QVERIFY(item->y() == i*20);
}
@@ -355,7 +355,7 @@ void tst_QFxListView::removed()
QCOMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QCOMPARE(item->y(),i*20.0 + 20.0);
}
@@ -366,13 +366,13 @@ void tst_QFxListView::removed()
QTest::qWait(1000);
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QCOMPARE(item->y(),i*20.0+20.0);
}
// Remove items before visible
- listview->setYPosition(80);
+ listview->setViewportY(80);
listview->setCurrentIndex(10);
model.removeItem(1); // post: top item will be at 40
@@ -385,12 +385,12 @@ void tst_QFxListView::removed()
QCOMPARE(item->y(),40+i*20.0);
}
- listview->setYPosition(40); // That's the top now
+ listview->setViewportY(40); // That's the top now
// let transitions settle.
QTest::qWait(1000);
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QCOMPARE(item->y(),40+i*20.0);
}
@@ -459,10 +459,12 @@ template<typename T>
T *tst_QFxListView::findItem(QFxItem *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
- qDebug() << parent->children()->count() << "children";
- for (int i = 0; i < parent->children()->count(); ++i) {
- QFxItem *item = parent->children()->at(i);
- qDebug() << "try" << item;
+ //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) {
+ QFxItem *item = qobject_cast<QFxItem*>(parent->QGraphicsObject::children().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QmlExpression e(qmlContext(item), "index", item);
diff --git a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
index 9a2f4f3..78ec347 100644
--- a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
+++ b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
@@ -166,11 +166,15 @@ void tst_numberformat::number()
QFETCH(QString, string);
QFETCH(float, number);
- QString componentStr = QString("NumberFormatter { number: \"") + string + QString("\" }");
+ QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: \"") + string + QString("\" }");
QmlEngine engine;
- QmlComponent formatterComponent(&engine, componentStr.toAscii());
+ QmlComponent formatterComponent(&engine, componentStr.toAscii(), QUrl("file://"));
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatterComponent.isReady());
QmlNumberFormatter *formatter = qobject_cast<QmlNumberFormatter*>(formatterComponent.create());
+ QVERIFY(formatterComponent.isReady());
QVERIFY(formatter != 0);
QCOMPARE((float)formatter->number(), number);
//qDebug() << formatter->format() << formatter->text();
@@ -201,10 +205,13 @@ void tst_numberformat::text()
QFETCH(QString, format);
QFETCH(QString, text);
- QString componentStr = QString("NumberFormatter { number: \"") + string + QString("\"; format: \"") + format + QString("\" }");
+ QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: \"") + string + QString("\"; format: \"") + format + QString("\" }");
QmlEngine engine;
- QmlComponent formatterComponent(&engine, componentStr.toAscii());
+ QmlComponent formatterComponent(&engine, componentStr.toAscii(), QUrl("file://"));
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatterComponent.isReady());
QmlNumberFormatter *formatter = qobject_cast<QmlNumberFormatter*>(formatterComponent.create());
QVERIFY(formatter != 0);
diff --git a/tests/auto/declarative/pathview/data/pathview.qml b/tests/auto/declarative/pathview/data/pathview.qml
index 7040e4c..be5673c 100644
--- a/tests/auto/declarative/pathview/data/pathview.qml
+++ b/tests/auto/declarative/pathview/data/pathview.qml
@@ -1,14 +1,15 @@
import Qt 4.6
-Rect {
+Rectangle {
width: 240
height: 320
color: "#ffffff"
resources: [
Component {
id: Delegate
- Rect {
+ Rectangle {
id: wrapper
+ objectName: "wrapper"
height: 20
width: 60
color: "white"
@@ -19,11 +20,13 @@ Rect {
Text {
x: 20
id: textName
+ objectName: "textName"
text: name
}
Text {
x: 40
id: textNumber
+ objectName: "textNumber"
text: number
}
}
@@ -31,11 +34,12 @@ Rect {
]
PathView {
id: view
+ objectName: "view"
width: 240
height: 320
model: testModel
delegate: Delegate
- snapPos: 0.01
+ snapPosition: 0.01
path: Path {
startY: 120
startX: 160
diff --git a/tests/auto/declarative/pathview/tst_pathview.cpp b/tests/auto/declarative/pathview/tst_pathview.cpp
index 9cae961..2933323 100644
--- a/tests/auto/declarative/pathview/tst_pathview.cpp
+++ b/tests/auto/declarative/pathview/tst_pathview.cpp
@@ -117,7 +117,7 @@ void tst_QFxPathView::items()
QFxPathView *pathview = findItem<QFxPathView>(canvas->root(), "view");
QVERIFY(pathview != 0);
- QCOMPARE(pathview->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible
for (int i = 0; i < model.count(); ++i) {
QFxText *name = findItem<QFxText>(pathview, "textName", i);
@@ -234,8 +234,10 @@ template<typename T>
T *tst_QFxPathView::findItem(QFxItem *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->children()->count(); ++i) {
- QFxItem *item = parent->children()->at(i);
+ for (int i = 0; i < parent->children().count(); ++i) {
+ QFxItem *item = qobject_cast<QFxItem*>(parent->children().at(i));
+ if(!item)
+ continue;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QmlExpression e(qmlContext(item), "index", item);
diff --git a/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp b/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
index a8046e6..c9c37ab 100644
--- a/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
+++ b/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
@@ -59,7 +59,9 @@ void tst_QBindableMap::changed()
QmlEngine engine;
QmlContext *ctxt = engine.rootContext();
ctxt->setContextProperty(QLatin1String("data"), &map);
- QmlComponent component(&engine, "Script { script: \"data.key1 = 'Hello World';\" }");
+ QmlComponent component(&engine, "import Qt 4.6\nScript { script: \"data.key1 = 'Hello World';\" }",
+ QUrl("file://"));
+ QVERIFY(component.isReady());
component.create();
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
diff --git a/tests/auto/declarative/qfxloader/NoResize.qml b/tests/auto/declarative/qfxloader/NoResize.qml
new file mode 100644
index 0000000..cfbb55a
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/NoResize.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Loader {
+ resizeMode: "NoResize"
+ width: 200; height: 80
+ source: "Rect120x60.qml"
+}
diff --git a/tests/auto/declarative/qfxloader/Rect120x60.qml b/tests/auto/declarative/qfxloader/Rect120x60.qml
new file mode 100644
index 0000000..aa4b0c2
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/Rect120x60.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Rectangle {
+ width: 120
+ height:60
+}
diff --git a/tests/auto/declarative/qfxloader/SetSourceComponent.qml b/tests/auto/declarative/qfxloader/SetSourceComponent.qml
new file mode 100644
index 0000000..c5dd7ff
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/SetSourceComponent.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Item {
+ Component { id: Comp; Rectangle { width: 120; height: 60 } }
+ Loader { sourceComponent: Comp }
+}
diff --git a/tests/auto/declarative/qfxloader/SizeToItem.qml b/tests/auto/declarative/qfxloader/SizeToItem.qml
new file mode 100644
index 0000000..b52fa03
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/SizeToItem.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Loader {
+ resizeMode: "SizeLoaderToItem"
+ source: "Rect120x60.qml"
+}
diff --git a/tests/auto/declarative/qfxloader/SizeToLoader.qml b/tests/auto/declarative/qfxloader/SizeToLoader.qml
new file mode 100644
index 0000000..1a107e1
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/SizeToLoader.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Loader {
+ resizeMode: "SizeItemToLoader"
+ width: 200; height: 80
+ source: "Rect120x60.qml"
+}
diff --git a/tests/auto/declarative/qfxloader/qfxloader.pro b/tests/auto/declarative/qfxloader/qfxloader.pro
new file mode 100644
index 0000000..643c18c
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/qfxloader.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+SOURCES += tst_qfxloader.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp
new file mode 100644
index 0000000..2109898
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp
@@ -0,0 +1,103 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qfxloader.h>
+
+class tst_qfxloader : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qfxloader();
+
+private slots:
+ void url();
+ void component();
+ void sizeLoaderToItem();
+ void sizeItemToLoader();
+ void noResize();
+
+private:
+ QmlEngine engine;
+};
+
+/*
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
+*/
+
+tst_qfxloader::tst_qfxloader()
+{
+}
+
+void tst_qfxloader::url()
+{
+ QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), QUrl("file://" SRCDIR "/"));
+ QFxLoader *loader = qobject_cast<QFxLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+}
+
+void tst_qfxloader::component()
+{
+ QmlComponent component(&engine, QUrl("file://" SRCDIR "/SetSourceComponent.qml"));
+ QFxItem *item = qobject_cast<QFxItem*>(component.create());
+ QVERIFY(item);
+
+ QFxLoader *loader = qobject_cast<QFxLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+}
+
+void tst_qfxloader::sizeLoaderToItem()
+{
+ QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToItem.qml"));
+ QFxLoader *loader = qobject_cast<QFxLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+}
+
+void tst_qfxloader::sizeItemToLoader()
+{
+ QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToLoader.qml"));
+ QFxLoader *loader = qobject_cast<QFxLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QFxItem *rect = loader->item();
+ QVERIFY(rect);
+ QCOMPARE(rect->width(), 200.0);
+ QCOMPARE(rect->height(), 80.0);
+}
+
+void tst_qfxloader::noResize()
+{
+ QmlComponent component(&engine, QUrl("file://" SRCDIR "/NoResize.qml"));
+ QFxLoader *loader = qobject_cast<QFxLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QFxItem *rect = loader->item();
+ QVERIFY(rect);
+ QCOMPARE(rect->width(), 120.0);
+ QCOMPARE(rect->height(), 60.0);
+}
+
+QTEST_MAIN(tst_qfxloader)
+
+#include "tst_qfxloader.moc"
diff --git a/tests/auto/declarative/qfxtext/tst_qfxtext.cpp b/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
index 0eb9f97..cae85a4 100644
--- a/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
+++ b/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
@@ -19,8 +19,8 @@ private slots:
void elide();
// ### these tests may be trivial
- void hAlign();
- void vAlign();
+ void horizontalAlignment();
+ void verticalAlignment();
void font();
void style();
void color();
@@ -29,11 +29,11 @@ private:
QStringList standard;
QStringList richText;
- QStringList hAlignmentStrings;
- QStringList vAlignmentStrings;
+ QStringList horizontalAlignmentmentStrings;
+ QStringList verticalAlignmentmentStrings;
- QList<Qt::Alignment> vAlignments;
- QList<Qt::Alignment> hAlignments;
+ QList<Qt::Alignment> verticalAlignmentments;
+ QList<Qt::Alignment> horizontalAlignmentments;
QStringList styleStrings;
QList<QFxText::TextStyle> styles;
@@ -51,19 +51,19 @@ tst_qfxtext::tst_qfxtext()
richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
<< "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
- hAlignmentStrings << "AlignLeft"
+ horizontalAlignmentmentStrings << "AlignLeft"
<< "AlignRight"
<< "AlignHCenter";
- vAlignmentStrings << "AlignTop"
+ verticalAlignmentmentStrings << "AlignTop"
<< "AlignBottom"
<< "AlignVCenter";
- hAlignments << Qt::AlignLeft
+ horizontalAlignmentments << Qt::AlignLeft
<< Qt::AlignRight
<< Qt::AlignHCenter;
- vAlignments << Qt::AlignTop
+ verticalAlignmentments << Qt::AlignTop
<< Qt::AlignBottom
<< Qt::AlignVCenter;
@@ -99,7 +99,7 @@ tst_qfxtext::tst_qfxtext()
void tst_qfxtext::text()
{
{
- QmlComponent textComponent(&engine, "Text { text: \"\" }");
+ QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"\" }", QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QVERIFY(textObject != 0);
@@ -108,8 +108,8 @@ void tst_qfxtext::text()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "Text { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QVERIFY(textObject != 0);
@@ -118,8 +118,8 @@ void tst_qfxtext::text()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "Text { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QVERIFY(textObject != 0);
@@ -132,7 +132,7 @@ void tst_qfxtext::width()
{
// uses Font metrics to find the width for standard and document to find the width for rich
{
- QmlComponent textComponent(&engine, "Text { text: \"\" }");
+ QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"\" }", QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 0.);
@@ -144,8 +144,8 @@ void tst_qfxtext::width()
QFontMetrics fm(f);
int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- QString componentStr = "Text { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), qreal(metricWidth));
@@ -159,8 +159,8 @@ void tst_qfxtext::width()
int documentWidth = document.idealWidth();
- QString componentStr = "Text { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), qreal(documentWidth));
@@ -173,7 +173,7 @@ void tst_qfxtext::wrap()
// for specified width and wrap set true
{
- QmlComponent textComponent(&engine, "Text { text: \"\"; wrap: true; width: 300 }");
+ QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"\"; wrap: true; width: 300 }", QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -181,8 +181,8 @@ void tst_qfxtext::wrap()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "Text { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -190,8 +190,8 @@ void tst_qfxtext::wrap()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "Text { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -208,7 +208,7 @@ void tst_qfxtext::elide()
// XXX Poor coverage.
{
- QmlComponent textComponent(&engine, ("Text { text: \"\"; "+elide+" width: 300 }").toLatin1());
+ QmlComponent textComponent(&engine, ("import Qt 4.6\nText { text: \"\"; "+elide+" width: 300 }").toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -216,8 +216,8 @@ void tst_qfxtext::elide()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "Text { "+elide+" width: 300; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 300; text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -226,8 +226,8 @@ void tst_qfxtext::elide()
// richtext - does nothing
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "Text { "+elide+" width: 300; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 300; text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -236,61 +236,61 @@ void tst_qfxtext::elide()
}
//the alignment tests may be trivial o.oa
-void tst_qfxtext::hAlign()
+void tst_qfxtext::horizontalAlignment()
{
//test one align each, and then test if two align fails.
for (int i = 0; i < standard.size(); i++)
{
- for (int j=0; j < hAlignmentStrings.size(); j++)
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
{
- QString componentStr = "Text { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE((int)textObject->hAlign(), (int)hAlignments.at(j));
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
}
}
for (int i = 0; i < richText.size(); i++)
{
- for (int j=0; j < hAlignmentStrings.size(); j++)
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
{
- QString componentStr = "Text { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE((int)textObject->hAlign(), (int)hAlignments.at(j));
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
}
}
}
-void tst_qfxtext::vAlign()
+void tst_qfxtext::verticalAlignment()
{
//test one align each, and then test if two align fails.
for (int i = 0; i < standard.size(); i++)
{
- for (int j=0; j < vAlignmentStrings.size(); j++)
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
{
- QString componentStr = "Text { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE((int)textObject->vAlign(), (int)vAlignments.at(j));
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
}
}
for (int i = 0; i < richText.size(); i++)
{
- for (int j=0; j < vAlignmentStrings.size(); j++)
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
{
- QString componentStr = "Text { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE((int)textObject->vAlign(), (int)vAlignments.at(j));
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
}
}
@@ -300,49 +300,49 @@ void tst_qfxtext::font()
{
//test size, then bold, then italic, then family
{
- QString componentStr = "Text { font.size: 40; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.pointSize: 40; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->size(), qreal(40));
- QCOMPARE(textObject->font()->bold(), false);
- QCOMPARE(textObject->font()->italic(), false);
+ QCOMPARE(textObject->font().pointSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
}
{
- QString componentStr = "Text { font.bold: true; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.bold: true; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->bold(), true);
- QCOMPARE(textObject->font()->italic(), false);
+ QCOMPARE(textObject->font().bold(), true);
+ QCOMPARE(textObject->font().italic(), false);
}
{
- QString componentStr = "Text { font.italic: true; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.italic: true; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->italic(), true);
- QCOMPARE(textObject->font()->bold(), false);
+ QCOMPARE(textObject->font().italic(), true);
+ QCOMPARE(textObject->font().bold(), false);
}
-
+
{
- QString componentStr = "Text { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->family(), QString("Helvetica"));
- QCOMPARE(textObject->font()->bold(), false);
- QCOMPARE(textObject->font()->italic(), false);
+ QCOMPARE(textObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
}
{
- QString componentStr = "Text { font.family: \"\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.family: \"\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->family(), QString(""));
+ QCOMPARE(textObject->font().family(), QString(""));
}
}
@@ -351,8 +351,8 @@ void tst_qfxtext::style()
//test style
for (int i = 0; i < styles.size(); i++)
{
- QString componentStr = "Text { style: \"" + styleStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { style: \"" + styleStrings.at(i) + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE((int)textObject->style(), (int)styles.at(i));
@@ -365,8 +365,8 @@ void tst_qfxtext::color()
//test style
for (int i = 0; i < colorStrings.size(); i++)
{
- QString componentStr = "Text { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
@@ -375,8 +375,8 @@ void tst_qfxtext::color()
for (int i = 0; i < colorStrings.size(); i++)
{
- QString componentStr = "Text { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
@@ -388,8 +388,8 @@ void tst_qfxtext::color()
{
for (int j = 0; j < colorStrings.size(); j++)
{
- QString componentStr = "Text { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
@@ -401,8 +401,8 @@ void tst_qfxtext::color()
QColor testColor("#001234");
testColor.setAlpha(170);
- QString componentStr = "Text { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->color(), testColor);
diff --git a/tests/auto/declarative/qfxtextedit/data/cursorTest.qml b/tests/auto/declarative/qfxtextedit/data/cursorTest.qml
index 25e53d0..e5df8f1 100644
--- a/tests/auto/declarative/qfxtextedit/data/cursorTest.qml
+++ b/tests/auto/declarative/qfxtextedit/data/cursorTest.qml
@@ -1,8 +1,8 @@
import Qt 4.6
-Rect { width: 300; height: 300; color: "white"
- TextEdit { text: "Hello world!"; focusable: true; id: textEditObject
- resources: [ Component { id:cursor; Item { id:cursorInstance } } ]
+Rectangle { width: 300; height: 300; color: "white"
+ TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject"
+ resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance" } } ]
cursorDelegate: cursor
}
}
diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
index 241dbad..c4fc506 100644
--- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
+++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
@@ -89,7 +89,7 @@ tst_qfxtextedit::tst_qfxtextedit()
void tst_qfxtextedit::text()
{
{
- QmlComponent texteditComponent(&engine, "TextEdit { text: \"\" }", QUrl());
+ QmlComponent texteditComponent(&engine, "import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -98,7 +98,7 @@ void tst_qfxtextedit::text()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "TextEdit { text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -108,7 +108,7 @@ void tst_qfxtextedit::text()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "TextEdit { text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -126,7 +126,7 @@ void tst_qfxtextedit::width()
{
// uses Font metrics to find the width for standard and document to find the width for rich
{
- QmlComponent texteditComponent(&engine, "TextEdit { text: \"\" }", QUrl());
+ QmlComponent texteditComponent(&engine, "import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -139,7 +139,7 @@ void tst_qfxtextedit::width()
QFontMetrics fm(f);
int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- QString componentStr = "TextEdit { text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -155,7 +155,7 @@ void tst_qfxtextedit::width()
int documentWidth = document.idealWidth();
- QString componentStr = "TextEdit { text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -168,7 +168,7 @@ void tst_qfxtextedit::wrap()
{
// for specified width and wrap set true
{
- QmlComponent texteditComponent(&engine, "TextEdit { text: \"\"; wrap: true; width: 300 }", QUrl());
+ QmlComponent texteditComponent(&engine, "import Qt 4.6\nTextEdit { text: \"\"; wrap: true; width: 300 }", QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -177,7 +177,7 @@ void tst_qfxtextedit::wrap()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "TextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -187,7 +187,7 @@ void tst_qfxtextedit::wrap()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "TextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -206,7 +206,7 @@ void tst_qfxtextedit::hAlign()
{
for (int j=0; j < hAlignmentStrings.size(); j++)
{
- QString componentStr = "TextEdit { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -219,7 +219,7 @@ void tst_qfxtextedit::hAlign()
{
for (int j=0; j < hAlignmentStrings.size(); j++)
{
- QString componentStr = "TextEdit { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -238,7 +238,7 @@ void tst_qfxtextedit::vAlign()
{
for (int j=0; j < vAlignmentStrings.size(); j++)
{
- QString componentStr = "TextEdit { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -251,7 +251,7 @@ void tst_qfxtextedit::vAlign()
{
for (int j=0; j < vAlignmentStrings.size(); j++)
{
- QString componentStr = "TextEdit { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -266,54 +266,54 @@ void tst_qfxtextedit::font()
{
//test size, then bold, then italic, then family
{
- QString componentStr = "TextEdit { font.size: 40; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->size(), qreal(40));
- QCOMPARE(textEditObject->font()->bold(), false);
- QCOMPARE(textEditObject->font()->italic(), false);
+ QCOMPARE(textEditObject->font().pointSize(), 40);
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
}
{
- QString componentStr = "TextEdit { font.bold: true; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.bold: true; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->bold(), true);
- QCOMPARE(textEditObject->font()->italic(), false);
+ QCOMPARE(textEditObject->font().bold(), true);
+ QCOMPARE(textEditObject->font().italic(), false);
}
{
- QString componentStr = "TextEdit { font.italic: true; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.italic: true; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->italic(), true);
- QCOMPARE(textEditObject->font()->bold(), false);
+ QCOMPARE(textEditObject->font().italic(), true);
+ QCOMPARE(textEditObject->font().bold(), false);
}
{
- QString componentStr = "TextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->family(), QString("Helvetica"));
- QCOMPARE(textEditObject->font()->bold(), false);
- QCOMPARE(textEditObject->font()->italic(), false);
+ QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
}
{
- QString componentStr = "TextEdit { font.family: \"\"; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->family(), QString(""));
+ QCOMPARE(textEditObject->font().family(), QString(""));
}
}
@@ -322,7 +322,7 @@ void tst_qfxtextedit::color()
//test style
for (int i = 0; i < colorStrings.size(); i++)
{
- QString componentStr = "TextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
//qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
@@ -335,7 +335,7 @@ void tst_qfxtextedit::color()
QColor testColor("#001234");
testColor.setAlpha(170);
- QString componentStr = "TextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -347,7 +347,7 @@ void tst_qfxtextedit::color()
void tst_qfxtextedit::selection()
{
QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
- QString componentStr = "TextEdit { text: \""+ testStr +"\"; }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \""+ testStr +"\"; }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
diff --git a/tests/auto/declarative/qfxtextinput/data/navigation.qml b/tests/auto/declarative/qfxtextinput/data/navigation.qml
index c1a6162..282c52c 100644
--- a/tests/auto/declarative/qfxtextinput/data/navigation.qml
+++ b/tests/auto/declarative/qfxtextinput/data/navigation.qml
@@ -6,11 +6,11 @@ Rectangle {
width: 800; height: 600; color: "blue"
Item {
- id: FirstItem
+ id: FirstItem;
KeyNavigation.right: Input
}
- TextInput { id: Input; focus: true;
+ TextInput { id: Input; focus: true
KeyNavigation.left: FirstItem
KeyNavigation.right: LastItem
KeyNavigation.up: FirstItem
diff --git a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
index 852a868..c883aa3 100644
--- a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
+++ b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
@@ -1,8 +1,9 @@
#include <qtest.h>
+#include "../../../shared/util.h"
#include <QtDeclarative/qmlengine.h>
#include <QFile>
#include <QtDeclarative/qfxview.h>
-#include <qfxtextinput.h>
+#include <QFxTextInput>
#include <QDebug>
class tst_qfxtextinput : public QObject
@@ -13,6 +14,17 @@ public:
tst_qfxtextinput();
private slots:
+ void text();
+ void width();
+ void font();
+ void color();
+ void selection();
+
+ void maxLength();
+ void masks();
+ void validators();
+
+ void cursorDelegate();
void navigation();
private:
@@ -20,10 +32,280 @@ private:
QFxView *createView(const QString &filename);
QmlEngine engine;
+ QStringList standard;
+ QStringList colorStrings;
};
tst_qfxtextinput::tst_qfxtextinput()
{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "It's supercalifragisiticexpialidocious!"
+ << "Hello, world!";
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+}
+
+void tst_qfxtextinput::text()
+{
+ {
+ QmlComponent textinputComponent(&engine, "import Qt 4.6\nTextInput { text: \"\" }", QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), QString(""));
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), standard.at(i));
+ }
+
+}
+
+void tst_qfxtextinput::width()
+{
+ // uses Font metrics to find the width for standard
+ {
+ QmlComponent textinputComponent(&engine, "import Qt 4.6\nTextInput { text: \"\" }", QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), 1.);//1 for the cursor
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QFont f;
+ QFontMetrics fm(f);
+ int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+
+ QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor
+ }
+}
+
+void tst_qfxtextinput::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().pointSize(), 40);
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.bold: true; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().bold(), true);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.italic: true; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().italic(), true);
+ QCOMPARE(textinputObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.family: \"\"; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString(""));
+ }
+}
+
+void tst_qfxtextinput::color()
+{
+ //test style
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+ //qDebug() << "textinputObject: " << textinputObject->color() << "vs. " << QColor(colorStrings.at(i));
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), testColor);
+ }
+}
+
+void tst_qfxtextinput::selection()
+{
+ QString testStr = standard[0];
+ QString componentStr = "import Qt 4.6\nTextInput { text: \""+ testStr +"\"; }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+
+
+ //Test selection follows cursor
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setCursorPosition(i);
+ QCOMPARE(textinputObject->cursorPosition(), i);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ QVERIFY(textinputObject->selectedText().isNull());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ //Test selection
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
+ }
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setSelectionStart(i);
+ QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ for(int i=0; i< testStr.size(); i++) {
+ textinputObject->setSelectionStart(i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
+ textinputObject->setSelectionEnd(i+1);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(testStr.mid(i,1), textinputObject->selectedText());
+ }
+
+ for(int i= testStr.size() - 1; i>0; i--) {
+ textinputObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
+ textinputObject->setSelectionStart(i-1);
+ QCOMPARE(testStr.mid(i-1,1), textinputObject->selectedText());
+ }
+
+ //Test Error Ignoring behaviour
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionEnd(-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionEnd(100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(0);
+ textinputObject->setSelectionEnd(10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionStart(-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionStart(100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionEnd(-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionEnd(100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+}
+
+void tst_qfxtextinput::maxLength()
+{
+ QFxView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->execute();
+ canvas->show();
+
+ QVERIFY(canvas->root() != 0);
+
+ QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+
+ QVERIFY(input != 0);
+ //TODO: Me
+}
+
+void tst_qfxtextinput::masks()
+{
+ QFxView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->execute();
+ canvas->show();
+
+ QVERIFY(canvas->root() != 0);
+
+ QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+
+ QVERIFY(input != 0);
+ //TODO: Me
+}
+
+void tst_qfxtextinput::validators()
+{
+ QFxView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->execute();
+ canvas->show();
+
+ QVERIFY(canvas->root() != 0);
+
+ QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+
+ QVERIFY(input != 0);
+ //TODO: Me
}
/*
@@ -41,7 +323,7 @@ void tst_qfxtextinput::navigation()
QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
QVERIFY(input != 0);
- QVERIFY(input->hasFocus() == true);
+ QTRY_VERIFY(input->hasFocus() == true);
simulateKey(canvas, Qt::Key_Left);
QVERIFY(input->hasFocus() == false);
simulateKey(canvas, Qt::Key_Right);
@@ -52,6 +334,11 @@ void tst_qfxtextinput::navigation()
QVERIFY(input->hasFocus() == true);
}
+void tst_qfxtextinput::cursorDelegate()
+{
+ //TODO:Get the QFxTextInput test passing first
+}
+
void tst_qfxtextinput::simulateKey(QFxView *view, int key)
{
QKeyEvent press(QKeyEvent::KeyPress, key, 0);
diff --git a/tests/auto/declarative/qmlparser/Alias.qml b/tests/auto/declarative/qmlparser/Alias.qml
new file mode 100644
index 0000000..8264e0d
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/Alias.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+Object {
+ id: Root
+ property int value: 1892
+ property alias aliasValue: Root.value
+}
+
diff --git a/tests/auto/declarative/qmlparser/alias.1.qml b/tests/auto/declarative/qmlparser/alias.1.qml
new file mode 100644
index 0000000..492d99a
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/alias.1.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+import Qt 4.6
+
+Object {
+ id: Root
+ property int value: 10
+ property alias valueAlias: Root.value
+}
diff --git a/tests/auto/declarative/qmlparser/alias.2.qml b/tests/auto/declarative/qmlparser/alias.2.qml
new file mode 100644
index 0000000..aa4d103
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/alias.2.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyQmlObject {
+ id: Root
+ property alias aliasObject: Root.qmlobjectProperty
+
+ qmlobjectProperty: MyQmlObject { value : 10 }
+}
diff --git a/tests/auto/declarative/qmlparser/alias.3.qml b/tests/auto/declarative/qmlparser/alias.3.qml
new file mode 100644
index 0000000..e25fbae
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/alias.3.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Object {
+ property var other
+ other: Alias { id: MyAliasObject }
+
+ property alias value: MyAliasObject.aliasValue
+ property alias value2: MyAliasObject.value
+}
+
diff --git a/tests/auto/declarative/qmlparser/customParserIdNotAllowed.errors.txt b/tests/auto/declarative/qmlparser/customParserIdNotAllowed.errors.txt
new file mode 100644
index 0000000..d28c0bd
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/customParserIdNotAllowed.errors.txt
@@ -0,0 +1 @@
+4:19:Cannot use reserved "id" property in ListModel
diff --git a/tests/auto/declarative/qmlparser/customParserIdNotAllowed.qml b/tests/auto/declarative/qmlparser/customParserIdNotAllowed.qml
new file mode 100644
index 0000000..e607768
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/customParserIdNotAllowed.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+ListModel {
+ ListElement { a: 10 }
+ ListElement { id: Foo; a: 12 }
+}
diff --git a/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml b/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml
new file mode 100644
index 0000000..fa2e831
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml
@@ -0,0 +1,38 @@
+import Qt 4.6
+
+Item {
+ ListModel {
+ id: FruitModel
+ ListElement {
+ name: "Apple"
+ cost: 2.45
+ }
+ ListElement {
+ name: "Orange"
+ cost: 3.25
+ }
+ ListElement {
+ name: "Banana"
+ cost: 1.95
+ }
+ }
+
+ Component {
+ id: FruitDelegate
+ Item {
+ width: 200; height: 50
+ Text { text: name }
+ Text { text: '$'+cost; anchors.right: parent.right }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: FruitModel.remove(index)
+ }
+ }
+ }
+
+ ListView {
+ model: FruitModel
+ delegate: FruitDelegate
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/declarative/qmlparser/testtypes.h b/tests/auto/declarative/qmlparser/testtypes.h
index 3b5d3ae..e3e9aae 100644
--- a/tests/auto/declarative/qmlparser/testtypes.h
+++ b/tests/auto/declarative/qmlparser/testtypes.h
@@ -59,9 +59,11 @@ class MyQmlObject : public QObject, public MyInterface, public QmlParserStatus
Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface)
Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal);
Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType);
+ Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
+
Q_INTERFACES(MyInterface QmlParserStatus)
public:
- MyQmlObject() : m_value(-1), m_interface(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
+ MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
int value() const { return m_value; }
void setValue(int v) { m_value = v; }
@@ -88,6 +90,9 @@ public:
int onLiteralSignal() const { return m_value; }
void setOnLiteralSignal(int v) { m_value = v; }
+ MyQmlObject *qmlobject() const { return m_qmlobject; }
+ void setQmlobject(MyQmlObject *o) { m_qmlobject = o; }
+
MyCustomVariantType customType() const { return m_custom; }
void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
public slots:
@@ -100,6 +105,7 @@ private:
friend class tst_qmlparser;
int m_value;
MyInterface *m_interface;
+ MyQmlObject *m_qmlobject;
MyCustomVariantType m_custom;
};
QML_DECLARE_TYPE(MyQmlObject);
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
index e3735e7..b8bd0e7 100644
--- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -48,6 +48,7 @@ private slots:
void customVariantTypes();
void valueTypes();
void cppnamespace();
+ void aliasProperties();
void importsBuiltin_data();
void importsBuiltin();
@@ -159,6 +160,8 @@ void tst_qmlparser::errors_data()
QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
+
+ QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
}
void tst_qmlparser::errors()
@@ -311,7 +314,7 @@ void tst_qmlparser::assignTypeExtremes()
QCOMPARE(object->intProperty(), -0x77359400);
}
-// Tests that custom parser tyeps can be instantiated
+// Tests that custom parser types can be instantiated
void tst_qmlparser::customParserTypes()
{
QmlComponent component(&engine, TEST_FILE("customParserTypes.qml"));
@@ -517,6 +520,76 @@ void tst_qmlparser::cppnamespace()
delete object;
}
+void tst_qmlparser::aliasProperties()
+{
+ // Simple "int" alias
+ {
+ QmlComponent component(&engine, TEST_FILE("alias.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ QCOMPARE(object->property("valueAlias").toInt(), 10);
+ object->setProperty("value", QVariant(13));
+ QCOMPARE(object->property("valueAlias").toInt(), 13);
+
+ // Write throught alias
+ object->setProperty("valueAlias", QVariant(19));
+ QCOMPARE(object->property("valueAlias").toInt(), 19);
+ QCOMPARE(object->property("value").toInt(), 19);
+
+ delete object;
+ }
+
+ // Complex object alias
+ {
+ QmlComponent component(&engine, TEST_FILE("alias.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ MyQmlObject *v =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v != 0);
+ QCOMPARE(v->value(), 10);
+
+ // Write through alias
+ MyQmlObject *v2 = new MyQmlObject();
+ v2->setParent(object);
+ object->setProperty("aliasObject", qVariantFromValue(v2));
+ MyQmlObject *v3 =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v3 != 0);
+ QCOMPARE(v3, v2);
+
+ delete object;
+ }
+
+ // Nested aliases
+ {
+ QmlComponent component(&engine, TEST_FILE("alias.3.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 1892);
+ QCOMPARE(object->property("value2").toInt(), 1892);
+
+ object->setProperty("value", QVariant(1313));
+ QCOMPARE(object->property("value").toInt(), 1313);
+ QCOMPARE(object->property("value2").toInt(), 1313);
+
+ object->setProperty("value2", QVariant(8080));
+ QCOMPARE(object->property("value").toInt(), 8080);
+ QCOMPARE(object->property("value2").toInt(), 8080);
+
+ delete object;
+ }
+
+}
+
class TestType : public QObject {
Q_OBJECT
public:
diff --git a/tests/auto/declarative/repeater/data/repeater.qml b/tests/auto/declarative/repeater/data/repeater.qml
index 57b1183..57ba9dc 100644
--- a/tests/auto/declarative/repeater/data/repeater.qml
+++ b/tests/auto/declarative/repeater/data/repeater.qml
@@ -1,15 +1,17 @@
import Qt 4.6
-Rect {
+Rectangle {
id: container
+ objectName: "container"
width: 240
height: 320
color: "white"
Repeater {
id: repeater
+ objectName: "repeater"
width: 240
height: 320
- dataSource: testData
+ model: testData
Component {
Text {
y: index*20
diff --git a/tests/auto/declarative/repeater/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp
index 0e7c187..08f9154 100644
--- a/tests/auto/declarative/repeater/tst_repeater.cpp
+++ b/tests/auto/declarative/repeater/tst_repeater.cpp
@@ -17,7 +17,7 @@ private slots:
private:
QFxView *createView(const QString &filename);
template<typename T>
- T *findItem(QFxItem *parent, const QString &id);
+ T *findItem(QObject *parent, const QString &id);
};
tst_QFxRepeater::tst_QFxRepeater()
@@ -26,7 +26,7 @@ tst_QFxRepeater::tst_QFxRepeater()
void tst_QFxRepeater::stringList()
{
- QFxView *canvas = createView(SRCDIR "/data/repeater.xml");
+ QFxView *canvas = createView(SRCDIR "/data/repeater.qml");
QStringList data;
data << "One";
@@ -35,7 +35,7 @@ void tst_QFxRepeater::stringList()
data << "Four";
QmlContext *ctxt = canvas->rootContext();
- ctxt->setProperty("testData", data);
+ ctxt->setContextProperty("testData", data);
canvas->execute();
qApp->processEvents();
@@ -46,10 +46,10 @@ void tst_QFxRepeater::stringList()
QFxItem *container = findItem<QFxItem>(canvas->root(), "container");
QVERIFY(container != 0);
- QCOMPARE(container->children()->count(), data.count() + 1);
+ QCOMPARE(container->childItems().count(), data.count() + 1);
- for (int i = 1; i < container->children()->count(); ++i) {
- QFxText *name = qobject_cast<QFxText*>(container->children()->at(i));
+ for (int i = 1; i < container->childItems().count(); ++i) {
+ QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
QVERIFY(name != 0);
QCOMPARE(name->text(), data.at(i-1));
}
@@ -65,20 +65,20 @@ QFxView *tst_QFxRepeater::createView(const QString &filename)
QFile file(filename);
file.open(QFile::ReadOnly);
- QString xml = file.readAll();
- canvas->setQml(xml, filename);
+ QString qml = file.readAll();
+ canvas->setQml(qml, filename);
return canvas;
}
template<typename T>
-T *tst_QFxRepeater::findItem(QFxItem *parent, const QString &objectName)
+T *tst_QFxRepeater::findItem(QObject *parent, const QString &objectName)
{
const QMetaObject &mo = T::staticMetaObject;
if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName))
return static_cast<T*>(parent);
- for (int i = 0; i < parent->children()->count(); ++i) {
- QFxItem *item = findItem<T>(parent->children()->at(i), objectName);
+ for (int i = 0; i < parent->children().count(); ++i) {
+ QFxItem *item = findItem<T>(parent->children().at(i), objectName);
if (item)
return static_cast<T*>(item);
}
diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
index 075fa01..46d5b9d 100644
--- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
+++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
@@ -462,22 +462,62 @@ struct Integer
int Integer::instanceCount = 0;
-template <template<typename T> class Container>
+struct IntegerMoveable
+ {
+ IntegerMoveable(int value = 42)
+ : val(value)
+ {
+ delete new int;
+ ++instanceCount;
+ }
+
+ IntegerMoveable(const IntegerMoveable &other)
+ : val(other.val)
+ {
+ delete new int;
+ ++instanceCount;
+ }
+
+ IntegerMoveable &operator=(const IntegerMoveable &other)
+ {
+ delete new int;
+ val = other.val;
+ return *this;
+ }
+
+ ~IntegerMoveable()
+ {
+ --instanceCount;
+ }
+
+ int value() const
+ {
+ return val;
+ }
+
+ int val;
+ static int instanceCount;
+ };
+
+int IntegerMoveable::instanceCount = 0;
+Q_DECLARE_TYPEINFO(IntegerMoveable, Q_MOVABLE_TYPE);
+
+template <typename T, template<typename> class Container >
void containerInsertTest(QObject*)
{
- Container<Integer> container;
+ Container<T> container;
// insert an item in an empty container
try {
container.insert(container.begin(), 41);
} catch (...) {
QVERIFY(container.isEmpty());
- QCOMPARE(Integer::instanceCount, 0);
+ QCOMPARE(T::instanceCount, 0);
return;
}
QCOMPARE(container.size(), 1);
- QCOMPARE(Integer::instanceCount, 1);
+ QCOMPARE(T::instanceCount, 1);
// insert an item before another item
try {
@@ -485,11 +525,11 @@ void containerInsertTest(QObject*)
} catch (...) {
QCOMPARE(container.size(), 1);
QCOMPARE(container.first().value(), 41);
- QCOMPARE(Integer::instanceCount, 1);
+ QCOMPARE(T::instanceCount, 1);
return;
}
- QCOMPARE(Integer::instanceCount, 2);
+ QCOMPARE(T::instanceCount, 2);
// insert an item in between
try {
@@ -498,24 +538,24 @@ void containerInsertTest(QObject*)
QCOMPARE(container.size(), 2);
QCOMPARE(container.first().value(), 41);
QCOMPARE((container.begin() + 1)->value(), 42);
- QCOMPARE(Integer::instanceCount, 2);
+ QCOMPARE(T::instanceCount, 2);
return;
}
- QCOMPARE(Integer::instanceCount, 3);
+ QCOMPARE(T::instanceCount, 3);
}
-template <template<typename T> class Container>
+template <typename T, template<typename> class Container>
void containerAppendTest(QObject*)
{
- Container<Integer> container;
+ Container<T> container;
// append to an empty container
try {
container.append(42);
} catch (...) {
QCOMPARE(container.size(), 0);
- QCOMPARE(Integer::instanceCount, 0);
+ QCOMPARE(T::instanceCount, 0);
return;
}
@@ -525,15 +565,38 @@ void containerAppendTest(QObject*)
} catch (...) {
QCOMPARE(container.size(), 1);
QCOMPARE(container.first().value(), 42);
- QCOMPARE(Integer::instanceCount, 1);
+ QCOMPARE(T::instanceCount, 1);
return;
}
+
+ Container<T> container2;
+
+ try {
+ container2.append(44);
+ } catch (...) {
+ // don't care
+ return;
+ }
+ QCOMPARE(T::instanceCount, 3);
+
+ // append another container with one item
+ try {
+ container += container2;
+ } catch (...) {
+ QCOMPARE(container.size(), 2);
+ QCOMPARE(container.first().value(), 42);
+ QCOMPARE((container.begin() + 1)->value(), 43);
+ QCOMPARE(T::instanceCount, 3);
+ return;
+ }
+
+ QCOMPARE(T::instanceCount, 4);
}
-template <template<typename T> class Container>
+template <typename T, template<typename> class Container>
void containerEraseTest(QObject*)
{
- Container<Integer> container;
+ Container<T> container;
try {
container.append(42);
@@ -548,7 +611,7 @@ void containerEraseTest(QObject*)
// sanity checks
QCOMPARE(container.size(), 5);
- QCOMPARE(Integer::instanceCount, 5);
+ QCOMPARE(T::instanceCount, 5);
// delete the first one
try {
@@ -556,20 +619,20 @@ void containerEraseTest(QObject*)
} catch (...) {
QCOMPARE(container.size(), 5);
QCOMPARE(container.first().value(), 42);
- QCOMPARE(Integer::instanceCount, 5);
+ QCOMPARE(T::instanceCount, 5);
return;
}
QCOMPARE(container.size(), 4);
QCOMPARE(container.first().value(), 43);
- QCOMPARE(Integer::instanceCount, 4);
+ QCOMPARE(T::instanceCount, 4);
// delete the last one
try {
container.erase(container.end() - 1);
} catch (...) {
QCOMPARE(container.size(), 4);
- QCOMPARE(Integer::instanceCount, 4);
+ QCOMPARE(T::instanceCount, 4);
return;
}
@@ -577,7 +640,7 @@ void containerEraseTest(QObject*)
QCOMPARE(container.first().value(), 43);
QCOMPARE((container.begin() + 1)->value(), 44);
QCOMPARE((container.begin() + 2)->value(), 45);
- QCOMPARE(Integer::instanceCount, 3);
+ QCOMPARE(T::instanceCount, 3);
// delete the middle one
try {
@@ -587,14 +650,14 @@ void containerEraseTest(QObject*)
QCOMPARE(container.first().value(), 43);
QCOMPARE((container.begin() + 1)->value(), 44);
QCOMPARE((container.begin() + 2)->value(), 45);
- QCOMPARE(Integer::instanceCount, 3);
+ QCOMPARE(T::instanceCount, 3);
return;
}
QCOMPARE(container.size(), 2);
QCOMPARE(container.first().value(), 43);
QCOMPARE((container.begin() + 1)->value(), 45);
- QCOMPARE(Integer::instanceCount, 2);
+ QCOMPARE(T::instanceCount, 2);
}
template <template<typename T> class Container>
@@ -602,9 +665,12 @@ static void containerData()
{
QTest::addColumn<TestFunction>("testFunction");
- QTest::newRow("insert") << static_cast<TestFunction>(containerInsertTest<Container>);
- QTest::newRow("append") << static_cast<TestFunction>(containerAppendTest<Container>);
- QTest::newRow("erase") << static_cast<TestFunction>(containerEraseTest<Container>);
+ QTest::newRow("insert static") << static_cast<TestFunction>(containerInsertTest<Integer, Container>);
+ QTest::newRow("append static") << static_cast<TestFunction>(containerAppendTest<Integer, Container>);
+ QTest::newRow("erase static") << static_cast<TestFunction>(containerEraseTest<Integer, Container>);
+ QTest::newRow("insert moveable") << static_cast<TestFunction>(containerInsertTest<IntegerMoveable, Container>);
+ QTest::newRow("append moveable") << static_cast<TestFunction>(containerAppendTest<IntegerMoveable, Container>);
+ QTest::newRow("erase moveable") << static_cast<TestFunction>(containerEraseTest<IntegerMoveable, Container>);
}
void tst_ExceptionSafetyObjects::vector_data()
@@ -616,7 +682,8 @@ void tst_ExceptionSafetyObjects::vector()
{
QFETCH(TestFunction, testFunction);
- if (QLatin1String(QTest::currentDataTag()) == QLatin1String("insert"))
+ if (QLatin1String(QTest::currentDataTag()) == QLatin1String("insert static")
+ || QLatin1String(QTest::currentDataTag()) == QLatin1String("insert moveable"))
QSKIP("QVector::insert is currently not strongly exception safe", SkipSingle);
doOOMTest(testFunction, 0);
diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h
index 144f7b3..a770f8e 100644
--- a/tests/auto/network-settings.h
+++ b/tests/auto/network-settings.h
@@ -328,3 +328,19 @@ QByteArray QtNetworkSettings::imapExpectedReplySsl;
#else
#define Q_SET_DEFAULT_IAP
#endif
+
+#ifdef QT_NETWORK_LIB
+class QtNetworkSettingsInitializerCode {
+public:
+ QtNetworkSettingsInitializerCode() {
+ QHostInfo testServerResult = QHostInfo::fromName(QtNetworkSettings::serverName());
+ if (testServerResult.error() != QHostInfo::NoError) {
+ qWarning() << "Could not lookup" << QtNetworkSettings::serverName();
+ qWarning() << "Please configure the test environment!";
+ qWarning() << "See /etc/hosts or network-settings.h";
+ qFatal("Exiting");
+ }
+ }
+};
+QtNetworkSettingsInitializerCode qtNetworkSettingsInitializer;
+#endif
diff --git a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp
index de2d9f4..7ee52ad 100644
--- a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp
+++ b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp
@@ -550,6 +550,7 @@ void tst_QAbstractButton::setShortcut()
{
QKeySequence seq( Qt::Key_A );
testWidget->setShortcut( seq );
+ QApplication::setActiveWindow(testWidget);
// must be active to get shortcuts
for (int i = 0; !testWidget->isActiveWindow() && i < 100; ++i) {
@@ -557,8 +558,8 @@ void tst_QAbstractButton::setShortcut()
QApplication::instance()->processEvents();
QTest::qWait(100);
}
- QVERIFY(testWidget->isActiveWindow());
-
+ QVERIFY(testWidget->isActiveWindow());
+
QTest::keyClick( testWidget, 'A' );
QTest::qWait(300); // Animate click takes time
QCOMPARE(click_count, (uint)1);
diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
index f49568d..82969b9 100644
--- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
@@ -100,7 +100,7 @@ private slots:
#if QT_VERSION >= 0x040600
void autoIncrementId();
#endif
-
+
void task209485_removeFromGroupInEventHandler_data();
void task209485_removeFromGroupInEventHandler();
};
@@ -333,12 +333,12 @@ void tst_QButtonGroup::testSignals()
QCOMPARE(clickedSpy.count(), 1);
QCOMPARE(clickedIdSpy.count(), 1);
-
- int expectedId = -1;
+
+ int expectedId = -1;
#if QT_VERSION >= 0x040600
expectedId = -2;
#endif
-
+
QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId);
QCOMPARE(pressedSpy.count(), 1);
QCOMPARE(pressedIdSpy.count(), 1);
diff --git a/tests/auto/qbytearray/qbytearray.pro b/tests/auto/qbytearray/qbytearray.pro
index d14534b..a0c143e 100644
--- a/tests/auto/qbytearray/qbytearray.pro
+++ b/tests/auto/qbytearray/qbytearray.pro
@@ -4,16 +4,17 @@ SOURCES += tst_qbytearray.cpp
QT = core
-wince*|symbian: {
+wince*|symbian {
addFile.sources = rfc3252.txt
addFile.path = .
DEPLOYMENT += addFile
}
-wince: {
- DEFINES += SRCDIR=\\\"\\\"
-} symbian: {
+wince* {
+ DEFINES += SRCDIR=\\\"./\\\"
+} else:symbian {
TARGET.EPOCHEAPSIZE="0x100 0x800000"
} else {
- DEFINES += SRCDIR=\\\"$$PWD/\\\"
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
+
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 928d826..7eefb26 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -1025,6 +1025,7 @@ void tst_QCompleter::multipleWidgets()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&window);
#endif
+ QApplication::setActiveWindow(&window);
QTest::qWait(50);
QTRY_VERIFY(qApp->focusWidget() == comboBox);
comboBox->lineEdit()->setText("it");
@@ -1058,6 +1059,7 @@ void tst_QCompleter::focusIn()
window.show();
QTest::qWait(100);
window.activateWindow();
+ QApplication::setActiveWindow(&window);
QTest::qWait(100);
QTRY_COMPARE(qApp->activeWindow(), &window);
@@ -1322,8 +1324,10 @@ void tst_QCompleter::task253125_lineEditCompletion()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&edit);
#endif
+ QTest::qWait(10);
+ QApplication::setActiveWindow(&edit);
+ QTRY_COMPARE(QApplication::activeWindow(), &edit);
- QTest::qWait(100);
QTest::keyClick(&edit, 'i');
QCOMPARE(edit.completer()->currentCompletion(), QString("iota"));
QTest::keyClick(edit.completer()->popup(), Qt::Key_Down);
@@ -1358,7 +1362,9 @@ void tst_QCompleter::task247560_keyboardNavigation()
qt_x11_wait_for_window_manager(&edit);
#endif
- QTest::qWait(100);
+ QTest::qWait(10);
+ QApplication::setActiveWindow(&edit);
+ QTRY_COMPARE(QApplication::activeWindow(), &edit);
QTest::keyClick(&edit, 'r');
QTest::keyClick(edit.completer()->popup(), Qt::Key_Down);
diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp
index 6162be0..aa3ccb7 100644
--- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp
+++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -52,6 +52,9 @@
#include <qlineedit.h>
#include <qdebug.h>
+
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=gui/widgets/qspinbox.h gui/widgets/qspinbox.cpp gui/widgets/qabstractspinbox.cpp gui/widgets/qabstractspinbox_p.h gui/widgets/qabstractspinbox.h
@@ -772,8 +775,8 @@ void tst_QDoubleSpinBox::editingFinished()
layout->addWidget(box2);
testFocusWidget->show();
- QTest::qWait(100);
- QVERIFY(box->isActiveWindow());
+ QTest::qWait(10);
+ QTRY_VERIFY(box->isActiveWindow());
box->setFocus();
QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index d951a86..076934c 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -411,6 +411,10 @@ void tst_QFileInfo::absolutePath_data()
QString drivePrefix;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
drivePrefix = QDir::currentPath().left(2);
+
+ // Make sure drive-relative paths return correct absolute paths (task 255326)
+ QTest::newRow("c:my.dll") << "c:my.dll" << QDir::currentPath() << "my.dll";
+ QTest::newRow("x:my.dll") << "x:my.dll" << "X:/" << "my.dll";
#endif
QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << "";
QTest::newRow("1") << "/machine/share/dir1" << drivePrefix + "/machine/share" << "dir1";
@@ -449,6 +453,10 @@ void tst_QFileInfo::absFilePath_data()
curr.remove(0, 2); // Make it a absolute path with no drive specifier: \depot\qt-4.2\tests\auto\qfileinfo
QTest::newRow(".") << curr << QDir::currentPath();
QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "C:/home/andy/tmp.txt";
+
+ // Make sure drive-relative paths return correct absolute paths (task 255326)
+ QTest::newRow("c:my.dll") << "c:temp/my.dll" << QDir::currentPath() + "/temp/my.dll";
+ QTest::newRow("x:my.dll") << "x:temp/my.dll" << "X:/temp/my.dll";
#else
QTest::newRow("absFilePath") << "/home/andy/tmp.txt" << "/home/andy/tmp.txt";
#endif
@@ -1052,19 +1060,19 @@ void tst_QFileInfo::isHidden_data()
QFile file(hiddenFileName);
if (file.open(QIODevice::WriteOnly)) {
QTextStream t(&file);
- t << "foobar";
+ t << "foobar";
} else {
qWarning("Failed to create hidden file");
}
QFile file2(notHiddenFileName);
if (file2.open(QIODevice::WriteOnly)) {
QTextStream t(&file);
- t << "foobar";
+ t << "foobar";
} else {
qWarning("Failed to create non-hidden file");
}
}
-
+
RFs rfs;
TInt err = rfs.Connect();
if (err == KErrNone) {
diff --git a/tests/auto/qfocusevent/tst_qfocusevent.cpp b/tests/auto/qfocusevent/tst_qfocusevent.cpp
index 662f115..5ad78de 100644
--- a/tests/auto/qfocusevent/tst_qfocusevent.cpp
+++ b/tests/auto/qfocusevent/tst_qfocusevent.cpp
@@ -56,6 +56,8 @@
#include <qlineedit.h>
#include <QBoxLayout>
+#include "../../shared/util.h"
+
QT_FORWARD_DECLARE_CLASS(QWidget)
//TESTED_CLASS=
@@ -168,6 +170,7 @@ void tst_QFocusEvent::initWidget()
{
// On X11 we have to ensure the event was processed before doing any checking, on Windows
// this is processed straight away.
+ QApplication::setActiveWindow(childFocusWidgetOne);
for (int i = 0; i < 1000; ++i) {
if (childFocusWidgetOne->isActiveWindow() && childFocusWidgetOne->hasFocus())
@@ -243,9 +246,9 @@ void tst_QFocusEvent::checkReason_BackTab()
// Now test the backtab key
QTest::keyClick( childFocusWidgetOne, Qt::Key_Backtab );
- QTest::qWait(2000);
+ QTest::qWait(200);
- QVERIFY(childFocusWidgetOne->focusOutEventRecieved);
+ QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved);
QVERIFY(childFocusWidgetTwo->focusInEventRecieved);
QVERIFY(childFocusWidgetOne->focusOutEventLostFocus);
QVERIFY(childFocusWidgetTwo->focusInEventGotFocus);
@@ -265,9 +268,9 @@ void tst_QFocusEvent::checkReason_Popup()
Q3PopupMenu* popupMenu = new Q3PopupMenu( testFocusWidget );
popupMenu->insertItem( "Test" );
popupMenu->popup( QPoint(0,0) );
- QTest::qWait(500);
+ QTest::qWait(50);
- QVERIFY(childFocusWidgetOne->focusOutEventLostFocus);
+ QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus);
QVERIFY( childFocusWidgetOne->hasFocus() );
QVERIFY( !childFocusWidgetOne->focusInEventRecieved );
@@ -290,11 +293,11 @@ void tst_QFocusEvent::checkReason_Popup()
QMenu* popupMenu = new QMenu( testFocusWidget );
popupMenu->addMenu( "Test" );
popupMenu->popup( QPoint(0,0) );
- QTest::qWait(500);
+ QTest::qWait(50);
- QVERIFY(childFocusWidgetOne->focusOutEventLostFocus);
+ QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus);
- QVERIFY( childFocusWidgetOne->hasFocus() );
+ QTRY_VERIFY( childFocusWidgetOne->hasFocus() );
QVERIFY( !childFocusWidgetOne->focusInEventRecieved );
QVERIFY( childFocusWidgetOne->focusOutEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusInEventRecieved );
@@ -368,13 +371,13 @@ void tst_QFocusEvent::checkReason_focusWidget()
QLineEdit edit1;
QLineEdit edit2;
- QVBoxLayout outerLayout;
+ QVBoxLayout outerLayout;
outerLayout.addWidget(&frame1);
outerLayout.addWidget(&frame2);
window1.setLayout(&outerLayout);
-
- QVBoxLayout leftLayout;
- QVBoxLayout rightLayout;
+
+ QVBoxLayout leftLayout;
+ QVBoxLayout rightLayout;
leftLayout.addWidget(&edit1);
rightLayout.addWidget(&edit2);
frame1.setLayout(&leftLayout);
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 650c1ca..43f4227 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -1432,6 +1432,55 @@ void tst_QGL::fboFormat()
QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil);
QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D));
QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16));
+
+ // operator== and operator!= for QGLFramebufferObjectFormat.
+ QGLFramebufferObjectFormat format1c;
+ QGLFramebufferObjectFormat format2c;
+
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+ format1c.setSamples(8);
+ QVERIFY(!(format1c == format2c));
+ QVERIFY(format1c != format2c);
+ format2c.setSamples(8);
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+
+ format1c.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ QVERIFY(!(format1c == format2c));
+ QVERIFY(format1c != format2c);
+ format2c.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+
+ format1c.setTextureTarget(GL_TEXTURE_3D);
+ QVERIFY(!(format1c == format2c));
+ QVERIFY(format1c != format2c);
+ format2c.setTextureTarget(GL_TEXTURE_3D);
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+
+ format1c.setInternalTextureFormat(GL_RGB16);
+ QVERIFY(!(format1c == format2c));
+ QVERIFY(format1c != format2c);
+ format2c.setInternalTextureFormat(GL_RGB16);
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+
+ QGLFramebufferObjectFormat format3c(format1c);
+ QGLFramebufferObjectFormat format4c;
+ QVERIFY(format1c == format3c);
+ QVERIFY(!(format1c != format3c));
+ format3c.setInternalTextureFormat(DEFAULT_FORMAT);
+ QVERIFY(!(format1c == format3c));
+ QVERIFY(format1c != format3c);
+
+ format4c = format1c;
+ QVERIFY(format1c == format4c);
+ QVERIFY(!(format1c != format4c));
+ format4c.setInternalTextureFormat(DEFAULT_FORMAT);
+ QVERIFY(!(format1c == format4c));
+ QVERIFY(format1c != format4c);
}
QTEST_MAIN(tst_QGL)
diff --git a/tests/auto/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp
index 13d79b1..590bafa 100644
--- a/tests/auto/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp
@@ -51,6 +51,8 @@
#include <QtGui/QWindowsStyle>
#include <QStyleFactory>
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h
@@ -788,8 +790,8 @@ void tst_QGridLayout::minMaxSize_data()
QTest::addColumn<QSize>("fixedSize");
//input and expected output
QTest::addColumn<SizeInfoList>("sizeinfos");
-
- QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1
+
+ QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1
<< int(QSizePolicy::Minimum) << QSize(152, 50) << (SizeInfoList()
<< SizeInfo(QRect(10, 10, 43, 30), QSize( 75, 75), QSize(0,0))
<< SizeInfo(QRect(10 + 45, 10, 43, 30), QSize(75, 75), QSize( 0, 0))
@@ -917,13 +919,14 @@ void tst_QGridLayout::minMaxSize()
#if defined(Q_WS_X11)
qt_x11_wait_for_window_manager(m_toplevel); // wait for the show
#endif
+ QTest::qWait(20);
m_toplevel->adjustSize();
- QTest::qWait(200); // wait for the implicit adjustSize
+ QTest::qWait(20); // wait for the implicit adjustSize
// If the following fails we might have to wait longer.
// If that does not help there is likely a problem with the implicit adjustSize in show()
if (!fixedSize.isValid()) {
// Note that this can fail if the desktop has large fonts on windows.
- QCOMPARE(m_toplevel->size(), m_toplevel->sizeHint());
+ QTRY_COMPARE(m_toplevel->size(), m_toplevel->sizeHint());
}
// We are relying on the order here...
for (int pi = 0; pi < sizehinters.count(); ++pi) {
diff --git a/tests/auto/qgroupbox/tst_qgroupbox.cpp b/tests/auto/qgroupbox/tst_qgroupbox.cpp
index 94b70e6..7346700 100644
--- a/tests/auto/qgroupbox/tst_qgroupbox.cpp
+++ b/tests/auto/qgroupbox/tst_qgroupbox.cpp
@@ -49,6 +49,8 @@
#include "qgroupbox.h"
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -81,7 +83,7 @@ private slots:
void toggledVsClicked();
void childrenAreDisabled();
void propagateFocus();
-
+
private:
bool checked;
qint64 timeStamp;
@@ -467,7 +469,7 @@ void tst_QGroupBox::propagateFocus()
box.show();
box.setFocus();
QTest::qWait(250);
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit));
+ QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit));
}
QTEST_MAIN(tst_QGroupBox)
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 1ef77c0..9871da3 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -63,6 +63,8 @@
#include <QPlainTextEdit>
#include <QDialog>
+#include "../../shared/util.h"
+
Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint)
//TESTED_CLASS=
@@ -862,6 +864,8 @@ void tst_QItemDelegate::decoration()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&table);
#endif
+ QApplication::setActiveWindow(&table);
+ QTRY_COMPARE(QApplication::activeWindow(), &table);
QVariant value;
switch ((QVariant::Type)type) {
@@ -1164,10 +1168,7 @@ void tst_QItemDelegate::task257859_finalizeEdit()
QDialog dialog;
QTimer::singleShot(100, &dialog, SLOT(close()));
dialog.exec();
-
- QTest::qWait(100);
-
- QVERIFY(!editor);
+ QTRY_VERIFY(!editor);
}
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 6bbdf5d..47f0730 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -343,6 +343,7 @@ void tst_QLineEdit::initTestCase()
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(testWidget);
#endif
+ QTRY_VERIFY(testWidget->hasFocus());
changed_count = 0;
edited_count = 0;
@@ -1601,8 +1602,7 @@ void tst_QLineEdit::passwordEchoOnEdit()
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
testWidget->setFocus();
testWidget->raise();
- QTest::qWait(250);
- QVERIFY(testWidget->hasFocus());
+ QTRY_VERIFY(testWidget->hasFocus());
QTest::keyPress(testWidget, '0');
QTest::keyPress(testWidget, '1');
@@ -1614,6 +1614,7 @@ void tst_QLineEdit::passwordEchoOnEdit()
QVERIFY(!testWidget->hasFocus());
QCOMPARE(testWidget->displayText(), QString(5, fillChar));
testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
QCOMPARE(testWidget->displayText(), QString(5, fillChar));
QTest::keyPress(testWidget, '0');
@@ -3397,7 +3398,7 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion()
qt_x11_wait_for_window_manager(&lineEdit);
#endif
lineEdit.setFocus();
- QTest::qWait(200);
+ QTRY_VERIFY(lineEdit.hasFocus());
QTest::keyPress(&lineEdit, 'a');
QTest::keyPress(&lineEdit, Qt::Key_Return);
QCOMPARE(lineEdit.text(), completion);
@@ -3491,7 +3492,7 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
testWidget->setFocus();
- QTest::qWait(250);
+ QTRY_VERIFY(testWidget->hasFocus());
QTest::keyPress(testWidget, '0');
QCOMPARE(testWidget->displayText(), QString("0"));
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index 2be1a03..2831747 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -113,6 +113,7 @@ private slots:
void task254449_draggingItemToNegativeCoordinates();
void keyboardSearch();
void shiftSelectionWithNonUniformItemSizes();
+ void clickOnViewportClearsSelection();
};
// Testing get/set functions
@@ -1733,5 +1734,34 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
}
}
+void tst_QListView::clickOnViewportClearsSelection()
+{
+ QStringList items;
+ items << "Text1";
+ QStringListModel model(items);
+ QListView view;
+ view.setModel(&model);
+ view.setSelectionMode(QListView::ExtendedSelection);
+
+ view.selectAll();
+ QModelIndex index = model.index(0);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QVERIFY(view.selectionModel()->isSelected(index));
+
+ //we try to click outside of the index
+ const QPoint point = view.visualRect(index).bottomRight() + QPoint(10,10);
+
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, point);
+ //at this point, the selection shouldn't have changed
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QVERIFY(view.selectionModel()->isSelected(index));
+
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, point);
+ //now the selection should be cleared
+ QVERIFY(!view.selectionModel()->hasSelection());
+
+}
+
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/qmdiarea/tst_qmdiarea.cpp b/tests/auto/qmdiarea/tst_qmdiarea.cpp
index 65dab48..246410d 100644
--- a/tests/auto/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/qmdiarea/tst_qmdiarea.cpp
@@ -62,6 +62,8 @@
#endif
#include <QMacStyle>
+#include "../../shared/util.h"
+
static const Qt::WindowFlags DefaultWindowFlags
= Qt::SubWindow | Qt::WindowSystemMenuHint
| Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint;
@@ -467,7 +469,7 @@ void tst_QMdiArea::subWindowActivated2()
qt_x11_wait_for_window_manager(&mdiArea);
#endif
- QCOMPARE(spy.count(), 5);
+ QTRY_COMPARE(spy.count(), 5);
QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().back());
spy.clear();
@@ -493,7 +495,7 @@ void tst_QMdiArea::subWindowActivated2()
qt_x11_wait_for_window_manager(&mdiArea);
#endif
QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QVERIFY(!mdiArea.activeSubWindow());
QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow);
spy.clear();
@@ -503,7 +505,7 @@ void tst_QMdiArea::subWindowActivated2()
qt_x11_wait_for_window_manager(&mdiArea);
#endif
QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
spy.clear();
@@ -516,14 +518,14 @@ void tst_QMdiArea::subWindowActivated2()
if (!macHasAccessToWindowsServer())
QEXPECT_FAIL("", "showMinimized doesn't really minimize if you don't have access to the server", Abort);
#endif
- QTest::qWait(100);
+ QTest::qWait(10);
#if defined(Q_WS_QWS)
QEXPECT_FAIL("", "task 168682", Abort);
#endif
#ifdef Q_OS_WINCE
QSKIP("Not fixed yet. See Task 197453", SkipAll);
#endif
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QVERIFY(!mdiArea.activeSubWindow());
QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow);
spy.clear();
@@ -533,7 +535,7 @@ void tst_QMdiArea::subWindowActivated2()
qt_x11_wait_for_window_manager(&mdiArea);
#endif
QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
spy.clear();
}
@@ -1734,6 +1736,7 @@ void tst_QMdiArea::tileSubWindows()
qt_x11_wait_for_window_manager(&workspace);
#endif
qApp->processEvents();
+ QTRY_COMPARE(workspace.size(), QSize(350, 150));
const QSize minSize(300, 100);
foreach (QMdiSubWindow *subWindow, workspace.subWindowList())
@@ -1885,7 +1888,7 @@ void tst_QMdiArea::resizeMaximizedChildWindows()
workspace.resize(workspaceSize + QSize(increment, increment));
QTest::qWait(100);
qApp->processEvents();
- QCOMPARE(workspace.size(), workspaceSize + QSize(increment, increment));
+ QTRY_COMPARE(workspace.size(), workspaceSize + QSize(increment, increment));
QCOMPARE(window->size(), windowSize + QSize(increment, increment));
workspaceSize = workspace.size();
}
diff --git a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
index 78ba46b..4d5160b 100644
--- a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -63,6 +63,9 @@
#include <QMacStyle>
#endif
+#include "../../shared/util.h"
+
+
QT_BEGIN_NAMESPACE
#if defined(Q_WS_X11)
extern void qt_x11_wait_for_window_manager(QWidget *w);
@@ -1004,15 +1007,16 @@ void tst_QMdiSubWindow::setSystemMenu()
qt_x11_wait_for_window_manager(&mainWindow);
#endif
- QVERIFY(subWindow->isVisible());
- QPoint globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft());
+ QTRY_VERIFY(subWindow->isVisible());
+ QPoint globalPopupPos;
// Show system menu
QVERIFY(!qApp->activePopupWidget());
subWindow->showSystemMenu();
- QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTest::qWait(25);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)),
+ (globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft())) );
systemMenu->hide();
QVERIFY(!qApp->activePopupWidget());
@@ -1034,9 +1038,9 @@ void tst_QMdiSubWindow::setSystemMenu()
// Show the new system menu
QVERIFY(!qApp->activePopupWidget());
subWindow->showSystemMenu();
- QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTest::qWait(25);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
systemMenu->hide();
QVERIFY(!qApp->activePopupWidget());
@@ -1048,12 +1052,12 @@ void tst_QMdiSubWindow::setSystemMenu()
QWidget *menuLabel = subWindow->maximizedSystemMenuIconWidget();
QVERIFY(menuLabel);
subWindow->showSystemMenu();
- QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
- globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height()));
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTest::qWait(25);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)),
+ (globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height()))));
systemMenu->hide();
- QVERIFY(!qApp->activePopupWidget());
+ QTRY_VERIFY(!qApp->activePopupWidget());
subWindow->showNormal();
#endif
@@ -1064,11 +1068,11 @@ void tst_QMdiSubWindow::setSystemMenu()
subWindow->showSystemMenu();
QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
// + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top())
globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topRight()) + QPoint(1, 0);
globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0);
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
systemMenu->hide();
QVERIFY(!qApp->activePopupWidget());
@@ -1081,10 +1085,10 @@ void tst_QMdiSubWindow::setSystemMenu()
QVERIFY(menuLabel);
subWindow->showSystemMenu();
QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
globalPopupPos = menuLabel->mapToGlobal(QPoint(menuLabel->width(), menuLabel->y() + menuLabel->height()));
globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0);
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
#endif
delete systemMenu;
@@ -1902,7 +1906,7 @@ void tst_QMdiSubWindow::task_182852()
mainWindow.show();
mainWindow.menuBar()->setVisible(true);
qApp->setActiveWindow(&mainWindow);
-
+
QString originalWindowTitle = QString::fromLatin1("MainWindow - [foo]");
mainWindow.setWindowTitle(originalWindowTitle);
@@ -1917,7 +1921,7 @@ void tst_QMdiSubWindow::task_182852()
window->showMaximized();
qApp->processEvents();
QVERIFY(window->isMaximized());
-
+
QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
.arg(originalWindowTitle, window->widget()->windowTitle()));
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index ab8dd48..4a4231a 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -55,6 +55,9 @@
#include <qmenu.h>
#include <qstyle.h>
#include <qdebug.h>
+
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -437,15 +440,16 @@ void tst_QMenu::overrideMenuAction()
m->addAction(aQuit);
w.show();
- QTest::qWait(200);
+ w.setFocus();
+ QTRY_VERIFY(w.hasFocus());
//test of the action inside the menu
QTest::keyClick(&w, Qt::Key_X, Qt::ControlModifier);
- QCOMPARE(activated, aQuit);
+ QTRY_COMPARE(activated, aQuit);
//test if the menu still pops out
QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier);
- QVERIFY(m->isVisible());
+ QTRY_VERIFY(m->isVisible());
delete aFileMenu;
@@ -703,12 +707,12 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition()
};
QMenu sub;
-
+
if (sub.style()->styleHint(QStyle::SH_Menu_Scrollable, 0, &sub)) {
//the style prevents the menus from getting columns
QSKIP("the style doesn't support multiple columns, it makes the menu scrollable", SkipSingle);
}
-
+
sub.addAction("Sub-Item1");
QAction *subAction = sub.addAction("Sub-Item2");
diff --git a/tests/auto/qmultiscreen/qmultiscreen.pro b/tests/auto/qmultiscreen/qmultiscreen.pro
index 4e92a65..30666d7 100644
--- a/tests/auto/qmultiscreen/qmultiscreen.pro
+++ b/tests/auto/qmultiscreen/qmultiscreen.pro
@@ -1,6 +1,5 @@
load(qttest_p4)
SOURCES += tst_qmultiscreen.cpp
-QT = core
requires(embedded)
diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp
index 5059578..2013258 100644
--- a/tests/auto/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp
@@ -54,6 +54,8 @@
#include <QStyleFactory>
#include <QTabWidget>
+#include "../../shared/util.h"
+
Q_DECLARE_METATYPE(QPushButton*)
//TESTED_CLASS=
@@ -413,6 +415,7 @@ void tst_QPushButton::setAccel()
// The shortcut will not be activated unless the button is in a active
// window and has focus
+ QApplication::setActiveWindow(testWidget);
testWidget->setFocus();
for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) {
testWidget->activateWindow();
@@ -421,8 +424,8 @@ void tst_QPushButton::setAccel()
}
QVERIFY(testWidget->isActiveWindow());
QTest::keyClick( testWidget, 'A', Qt::AltModifier );
- QTest::qWait( 500 );
- QVERIFY( click_count == 1 );
+ QTest::qWait( 50 );
+ QTRY_VERIFY( click_count == 1 );
QVERIFY( press_count == 1 );
QVERIFY( release_count == 1 );
QVERIFY( toggle_count == 0 );
@@ -430,6 +433,7 @@ void tst_QPushButton::setAccel()
// wait 200 ms because setAccel uses animateClick.
// if we don't wait this may screw up a next test.
QTest::qWait(200);
+ QTRY_VERIFY( !testWidget->isDown() );
}
void tst_QPushButton::animateClick()
diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp
index 73d25a2..f4d70d1 100644
--- a/tests/auto/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/qspinbox/tst_qspinbox.cpp
@@ -140,7 +140,7 @@ private slots:
void removeAll();
void startWithDash();
void undoRedo();
-
+
void specialValue();
void textFromValue();
@@ -750,11 +750,13 @@ void tst_QSpinBox::editingFinished()
QSpinBox *box2 = new QSpinBox(testFocusWidget);
layout->addWidget(box2);
+ testFocusWidget->show();
+ QApplication::setActiveWindow(testFocusWidget);
box->activateWindow();
- QTest::qWait(1000);//qApp->processEvents();
+ QTest::qWait(100);//qApp->processEvents();
box->setFocus();
- QTRY_VERIFY(qApp->focusWidget() == box);
+ QTRY_COMPARE(qApp->focusWidget(), box);
QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished()));
@@ -910,7 +912,7 @@ void tst_QSpinBox::undoRedo()
void tst_QSpinBox::specialValue()
{
QString specialText="foo";
-
+
QWidget topWidget;
QVBoxLayout layout(&topWidget);
SpinBox spin(&topWidget);
@@ -937,7 +939,7 @@ void tst_QSpinBox::specialValue()
QCOMPARE(spin.text(), QString("0"));
QTest::keyClick(&spin, Qt::Key_Return);
QCOMPARE(spin.text(), specialText);
-
+
spin.setValue(50);
QTest::keyClick(&spin, Qt::Key_Return);
QTest::keyClick(&spin, '0');
@@ -987,17 +989,17 @@ void tst_QSpinBox::sizeHint()
QVERIFY(spinBox->sizeHintRequests > 0);
// Suffix
- spinBox->sizeHintRequests = 0;
+ spinBox->sizeHintRequests = 0;
spinBox->setSuffix(QLatin1String("abcdefghij"));
qApp->processEvents();
- QVERIFY(spinBox->sizeHintRequests > 0);
+ QVERIFY(spinBox->sizeHintRequests > 0);
// Range
- spinBox->sizeHintRequests = 0;
+ spinBox->sizeHintRequests = 0;
spinBox->setRange(0, 1234567890);
spinBox->setValue(spinBox->maximum());
qApp->processEvents();
- QVERIFY(spinBox->sizeHintRequests > 0);
+ QVERIFY(spinBox->sizeHintRequests > 0);
}
QTEST_MAIN(tst_QSpinBox)
diff --git a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp
index c6a30a5..481ee2c 100644
--- a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp
+++ b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp
@@ -47,6 +47,8 @@
#include <qwidget.h>
#include <QPushButton>
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h
@@ -149,7 +151,7 @@ void tst_QStackedLayout::testCase()
QStackedLayout onStack(testWidget);
QStackedLayout *testLayout = &onStack;
testWidget->setLayout(testLayout);
-
+
QSignalSpy spy(testLayout,SIGNAL(currentChanged(int)));
// Nothing in layout
@@ -350,12 +352,15 @@ void tst_QStackedLayout::keepFocusAfterSetCurrent()
stackLayout->setCurrentIndex(0);
+ testWidget->show();
+ QTest::qWait(25);
+ QApplication::setActiveWindow(testWidget);
+
edit1->setFocus();
- QTest::qWait(250);
edit1->activateWindow();
- QTest::qWait(100);
+ QTest::qWait(25);
- QVERIFY(edit1->hasFocus());
+ QTRY_VERIFY(edit1->hasFocus());
stackLayout->setCurrentIndex(1);
QVERIFY(!edit1->hasFocus());
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 6fe2963..51d0e33 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -2334,8 +2334,10 @@ void tst_QTableView::scrollTo()
QtTestTableView view;
view.show();
- view.resize(columnWidth * 2, rowHeight * 2);
+ QSize forcedSize(columnWidth * 2, rowHeight * 2);
+ view.resize(forcedSize);
QTest::qWait(0);
+ QTRY_COMPARE(view.size(), forcedSize);
view.setModel(&model);
view.setSpan(row, column, rowSpan, columnSpan);
@@ -2910,6 +2912,7 @@ void tst_QTableView::tabFocus()
window.setFocus();
QTest::qWait(100);
window.activateWindow();
+ QApplication::setActiveWindow(&window);
QTest::qWait(100);
qApp->processEvents();
@@ -2926,43 +2929,43 @@ void tst_QTableView::tabFocus()
for (int i = 0; i < 2; ++i) {
// tab to view
QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab);
- QVERIFY(!window.hasFocus());
+ QTRY_VERIFY(!window.hasFocus());
QVERIFY(view->hasFocus());
QVERIFY(!edit->hasFocus());
// tab to edit
QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab);
+ QTRY_VERIFY(edit->hasFocus());
QVERIFY(!window.hasFocus());
QVERIFY(!view->hasFocus());
- QVERIFY(edit->hasFocus());
}
// backtab to view
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(view->hasFocus());
QVERIFY(!window.hasFocus());
- QVERIFY(view->hasFocus());
QVERIFY(!edit->hasFocus());
// backtab to edit
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(edit->hasFocus());
QVERIFY(!window.hasFocus());
QVERIFY(!view->hasFocus());
- QVERIFY(edit->hasFocus());
QStandardItemModel *model = new QStandardItemModel;
view->setModel(model);
// backtab to view
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(view->hasFocus());
QVERIFY(!window.hasFocus());
- QVERIFY(view->hasFocus());
QVERIFY(!edit->hasFocus());
// backtab to edit
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(edit->hasFocus());
QVERIFY(!window.hasFocus());
QVERIFY(!view->hasFocus());
- QVERIFY(edit->hasFocus());
model->insertRow(0, new QStandardItem("Hei"));
model->insertRow(0, new QStandardItem("Hei"));
@@ -2970,8 +2973,8 @@ void tst_QTableView::tabFocus()
// backtab to view
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(view->hasFocus());
QVERIFY(!window.hasFocus());
- QVERIFY(view->hasFocus());
QVERIFY(!edit->hasFocus());
// backtab to edit doesn't work
@@ -2984,14 +2987,14 @@ void tst_QTableView::tabFocus()
// backtab to edit
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(edit->hasFocus());
QVERIFY(!window.hasFocus());
QVERIFY(!view->hasFocus());
- QVERIFY(edit->hasFocus());
QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab);
- QVERIFY(view->hasFocus());
+ QTRY_VERIFY(view->hasFocus());
QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab);
- QVERIFY(edit->hasFocus());
+ QTRY_VERIFY(edit->hasFocus());
delete model;
}
diff --git a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp
index 0311900..966e9c9 100644
--- a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp
+++ b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp
@@ -49,6 +49,8 @@
#include <qtextbrowser.h>
#include <qtextobject.h>
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -64,9 +66,11 @@ public:
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(this);
#endif
+ QApplication::setActiveWindow(this);
activateWindow();
setFocus();
- QTest::qWait(100);
+ QTest::qWait(50);
+ QTRY_VERIFY(hasFocus());
}
virtual QVariant loadResource(int type, const QUrl &name);
diff --git a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp
index 6f8dd2b..61f4456 100644
--- a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp
+++ b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp
@@ -772,7 +772,9 @@ void tst_QTextPieceTable::blockRemoval1()
QVERIFY(table->blocksFind(6).position() == 5);
QVERIFY(table->blocksFind(11).position() == 10);
+ table->beginEditBlock();
table->remove(5, 5);
+ table->endEditBlock();
QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(5).blockFormat() == fmt2);
QVERIFY(table->blocksFind(4).position() == 0);
@@ -864,7 +866,10 @@ void tst_QTextPieceTable::blockRemoval3()
QVERIFY(table->blocksFind(6).position() == 5);
QVERIFY(table->blocksFind(11).position() == 10);
+ table->beginEditBlock();
table->remove(3, 4);
+ table->endEditBlock();
+
QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(1).position() == 0);
@@ -958,7 +963,10 @@ void tst_QTextPieceTable::blockRemoval5()
QVERIFY(table->blocksFind(6).position() == 5);
QVERIFY(table->blocksFind(11).position() == 10);
+ table->beginEditBlock();
table->remove(3, 8);
+ table->endEditBlock();
+
QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(1).position() == 0);
diff --git a/tests/auto/qtransformedscreen/qtransformedscreen.pro b/tests/auto/qtransformedscreen/qtransformedscreen.pro
index 39e3700..6914054 100644
--- a/tests/auto/qtransformedscreen/qtransformedscreen.pro
+++ b/tests/auto/qtransformedscreen/qtransformedscreen.pro
@@ -1,6 +1,5 @@
load(qttest_p4)
SOURCES += tst_qtransformedscreen.cpp
-QT = core
embedded:!contains(gfx-drivers, transformed) {
LIBS += ../../../plugins/gfxdrivers/libqgfxtransformed.so
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index fae4b26..f42d5f6 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -3354,7 +3354,7 @@ void tst_QTreeView::task246536_scrollbarsNotWorking()
o.count = 0;
tree.verticalScrollBar()->setValue(50);
QTest::qWait(100);
- QVERIFY(o.count > 0);
+ QTRY_VERIFY(o.count > 0);
}
void tst_QTreeView::task250683_wrongSectionSize()
@@ -3404,8 +3404,9 @@ void tst_QTreeView::task239271_addRowsWithFirstColumnHidden()
QStandardItem sub1("sub1"), sub11("sub11");
root0.appendRow(QList<QStandardItem*>() << &sub1 << &sub11);
- QTest::qWait(200);
+ QTest::qWait(20);
//items in the 2nd column should have been painted
+ QTRY_VERIFY(!delegate.paintedIndexes.isEmpty());
QVERIFY(delegate.paintedIndexes.contains(sub00.index()));
QVERIFY(delegate.paintedIndexes.contains(sub11.index()));
}
diff --git a/tests/auto/qwsembedwidget/qwsembedwidget.pro b/tests/auto/qwsembedwidget/qwsembedwidget.pro
index bd3c32c..c34212b 100644
--- a/tests/auto/qwsembedwidget/qwsembedwidget.pro
+++ b/tests/auto/qwsembedwidget/qwsembedwidget.pro
@@ -1,3 +1,2 @@
load(qttest_p4)
SOURCES += tst_qwsembedwidget.cpp
-QT = core
diff --git a/tests/auto/qwsinputmethod/qwsinputmethod.pro b/tests/auto/qwsinputmethod/qwsinputmethod.pro
index 69cce78..d549de0 100644
--- a/tests/auto/qwsinputmethod/qwsinputmethod.pro
+++ b/tests/auto/qwsinputmethod/qwsinputmethod.pro
@@ -1,3 +1,2 @@
load(qttest_p4)
SOURCES += tst_qwsinputmethod.cpp
-QT = core
diff --git a/tests/auto/qwswindowsystem/qwswindowsystem.pro b/tests/auto/qwswindowsystem/qwswindowsystem.pro
index 49466ee..ee33935 100644
--- a/tests/auto/qwswindowsystem/qwswindowsystem.pro
+++ b/tests/auto/qwswindowsystem/qwswindowsystem.pro
@@ -1,3 +1,2 @@
load(qttest_p4)
SOURCES += tst_qwswindowsystem.cpp
-QT = core
diff --git a/tools/qmldebugger/engines.qml b/tools/qmldebugger/engines.qml
index 1652ebd..1e9335b 100644
--- a/tools/qmldebugger/engines.qml
+++ b/tools/qmldebugger/engines.qml
@@ -9,16 +9,16 @@ Item {
Row {
anchors.fill: parent
Repeater {
- dataSource: engines
+ model: engines
Item {
width: 100; height: 100;
Image {
- id: Image;
+ id: EngineIcon;
source: "qrc:/engine.png"
anchors.horizontalCenter: parent.horizontalCenter
}
Text {
- anchors.top: Image.bottom;
+ anchors.top: EngineIcon.bottom;
text: modelData.name + "(" + modelData.engineId + ")"
anchors.horizontalCenter: parent.horizontalCenter
}