aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-05-22 07:48:30 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-05-22 07:48:54 +0200
commit800025fb70ace453275011c1ae5ce906e0fa3344 (patch)
tree7f1ff56262b75beb3b0a1e94563c43fc59de742b
parent666f20523cd7be16d88d3c03252ed2fd6e4be0c4 (diff)
parenteb0f98499485487f9f75b6388f00c58b50aeff50 (diff)
Merge remote-tracking branch 'origin/stable' into dev
-rw-r--r--dist/changes-5.3.088
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/qmldir8
-rw-r--r--examples/quick/demos/photoviewer/deployment.pri23
-rw-r--r--examples/quick/demos/photoviewer/i18n/base.ts30
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_de.qmbin0 -> 310 bytes
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_de.ts35
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_fr.qmbin268 -> 247 bytes
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_fr.ts17
-rw-r--r--examples/quick/demos/photoviewer/main.cpp59
-rw-r--r--examples/quick/demos/photoviewer/main.qml (renamed from examples/quick/demos/photoviewer/photoviewer.qml)9
-rw-r--r--examples/quick/demos/photoviewer/photoviewer.pro22
-rw-r--r--examples/quick/demos/photoviewer/photoviewer.qmlproject20
-rw-r--r--examples/quick/demos/photoviewer/qml.qrc19
-rw-r--r--examples/quick/demos/stocqt/content/Button.qml10
-rw-r--r--examples/quick/demos/stocqt/content/CheckBox.qml24
-rw-r--r--examples/quick/demos/stocqt/content/DatePicker.qml131
-rw-r--r--examples/quick/demos/stocqt/content/StockChart.qml226
-rw-r--r--examples/quick/demos/stocqt/content/StockInfo.qml119
-rw-r--r--examples/quick/demos/stocqt/content/StockListModel.qml200
-rw-r--r--examples/quick/demos/stocqt/content/StockListView.qml181
-rw-r--r--examples/quick/demos/stocqt/content/StockModel.qml45
-rw-r--r--examples/quick/demos/stocqt/content/StockSettings.qml216
-rw-r--r--examples/quick/demos/stocqt/content/StockSettingsPanel.qml174
-rw-r--r--examples/quick/demos/stocqt/content/StockView.qml92
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-calendar-anim.pngbin1088 -> 0 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-calendar.pngbin884 -> 0 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-items.pngbin887 -> 0 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-left-arrow.pngbin0 -> 1368 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-settings.pngbin1066 -> 0 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/logo.pngbin4266 -> 0 bytes
-rw-r--r--examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.pngbin24592 -> 48979 bytes
-rw-r--r--examples/quick/demos/stocqt/stocqt.pro1
-rw-r--r--examples/quick/demos/stocqt/stocqt.qml140
-rw-r--r--examples/quick/demos/stocqt/stocqt.qrc10
-rw-r--r--src/imports/qtquick2/plugins.qmltypes277
-rw-r--r--src/imports/window/plugins.qmltypes36
-rw-r--r--src/qml/compiler/qv4compileddata_p.h11
-rw-r--r--src/qml/compiler/qv4compiler.cpp6
-rw-r--r--src/qml/compiler/qv4ssa.cpp32
-rw-r--r--src/qml/doc/src/cppintegration/exposecppattributes.qdoc5
-rw-r--r--src/qml/doc/src/javascript/expressions.qdoc32
-rw-r--r--src/qml/doc/src/javascript/topic.qdoc13
-rw-r--r--src/qml/doc/src/qmllanguageref/documents/scope.qdoc8
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc52
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/propertybinding.qdoc91
-rw-r--r--src/qml/jsapi/qjsengine.cpp13
-rw-r--r--src/qml/jsapi/qjsvalueiterator.cpp9
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp11
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp18
-rw-r--r--src/quick/accessible/qaccessiblequickitem.cpp22
-rw-r--r--src/quick/accessible/qaccessiblequickitem_p.h5
-rw-r--r--src/quick/doc/src/concepts/convenience/topic.qdoc13
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp6
-rw-r--r--src/quick/items/qquickimage.cpp2
-rw-r--r--src/quick/items/qquickimage_p.h2
-rw-r--r--src/quick/items/qquickitem.cpp8
-rw-r--r--src/quick/items/qquickitemsmodule.cpp2
-rw-r--r--src/quick/items/qquicktextcontrol.cpp7
-rw-r--r--src/quick/items/qquickwindow.cpp10
-rw-r--r--src/quick/items/qquickwindowmodule.cpp1
-rw-r--r--src/quick/util/qquickanimatorcontroller.cpp42
-rw-r--r--src/quick/util/qquickanimatorcontroller_p.h4
-rw-r--r--src/quick/util/qquickanimatorjob.cpp26
-rw-r--r--src/quick/util/qquickanimatorjob_p.h4
-rw-r--r--src/quickwidgets/qquickwidget.cpp22
-rw-r--r--src/quickwidgets/qquickwidget.h3
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp39
-rw-r--r--tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp27
-rw-r--r--tests/auto/qmltest/animators/tst_multiwindow.qml103
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp2
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp7
-rw-r--r--tests/auto/quick/qquicktextedit/data/qtbug-38947.qml16
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp28
-rw-r--r--tests/auto/quick/qquicktextinput/qquicktextinput.pro2
76 files changed, 1899 insertions, 1023 deletions
diff --git a/dist/changes-5.3.0 b/dist/changes-5.3.0
index 05550765d4..56c4b5e20c 100644
--- a/dist/changes-5.3.0
+++ b/dist/changes-5.3.0
@@ -2,7 +2,7 @@ Qt 5.3 introduces many new features and improvements as well as bugfixes
over the 5.2.x series. For more details, refer to the online documentation
included in this distribution. The documentation is also available online:
- http://qt-project.org/doc/qt-5.2
+ http://qt-project.org/doc/qt-5
The Qt version 5.3 series is binary compatible with the 5.2.x series.
Applications compiled for 5.2 will continue to run with 5.3.
@@ -29,46 +29,66 @@ Third party components
* Important Behavior Changes *
****************************************************************************
-- Signals declared in QML that take "var" parameters, are now using QJSValue
- as C++ type for these parameters, instead of QVariant.
+ - Signals declared in QML that take "var" parameters, are now using QJSValue
+ as C++ type for these parameters, instead of QVariant.
-****************************************************************************
-* Library *
-****************************************************************************
-
-QtQml
-------
-
-QtQuick
-------
-
-- Introduced QQuickWidget. This is the equivalent of QQuickView in the
- QWidget world. It allows easy and flexible embedding of QtQuick
- scenes into widget-based application windows without the
- restrictions imposed by QWidget::createWindowContainer().
-
-
-****************************************************************************
-* Database Drivers *
-****************************************************************************
+ - [QTBUG-35913] A QQuick Item is now strongly referenced by its visual
+ parent item, so it doesn't require a QObject parent to stay alive.
+ - [QTBUG-37924] Keys.forwardTo no longer propagates key events to the
+ target item's parents. This makes Keys.forwardTo act more as expected,
+ like an event filter. This way Keys.forwardTo becomes usable for
+ composite types that want to enable the Keys attached property
+ handling by forwarding key events from an internal editor.
****************************************************************************
-* Platform Specific Changes *
+* Library *
****************************************************************************
+QtQml
+-----
-****************************************************************************
-* Compiler Specific Changes *
-****************************************************************************
+ - [QTBUG-36491] Fixed JavaScript Array.push() not working on QStringList
+ properties.
+ - [QTBUG-38430] Fixed a bug that caused a crash when the item is deleted but
+ is not removed from the QQmlDelegateModel's cache.
+QtQuickWidgets
+-------
+ - Introduced QQuickWidget. This is the equivalent of QQuickView in the
+ QWidget world. It allows easy and flexible embedding of QtQuick
+ scenes into widget-based application windows without the
+ restrictions imposed by QWidget::createWindowContainer().
-****************************************************************************
-* Tools *
-****************************************************************************
-
-
-****************************************************************************
-* Plugins *
-****************************************************************************
+QtQuick
+-------
+
+ - Added displayMarginBeginning/End to ListView and GridView.
+ - Added a new sceneGraphError() signal to QQuickWindow which applications
+ can use to detect errors like OpenGL context creation failures and react
+ in their own custom ways.
+ - Moved dialog implementations from qtdeclarative repository to
+ qtquickcontrols repository due to dependencies. QML import remains unchanged.
+
+
+ - [QTBUG-18946] Added Text::linkAt(x,y) method.
+ - [QTBUG-18946] Added TextEdit::linkAt(x,y) method.
+ - [QTBUG-19961] Added Image.mipmap property to enable mipmap filtering when
+ scaled or transformed.
+ - [QTBUG-38004] Mac: any editable text input will get tab focus when "Text
+ boxes and lists only" option was selected.
+ - [QTBUG-21549] Fixed a bug where Behavior would trigger when the tracked
+ value has not changed.
+ - [QTBUG-35073] QQuickWindow will now emit the afterAnimating() signal
+ from the gui thread before each scenegraph sync request.
+ - [QTBUG-36749] Fixed wrong baseline alignment for TextInput
+ - [QTBUG-31047] handles mouse as a touchpoint; added mouseEnabled
+ property to permit transparent pass-through to mouse-sensitive items
+ - [QTBUG-31830] "updatePolish" is not called for invisible items any more.
+ - [QTBUG-35772] Changed QSGGeometry::lineWidth to also affect point size
+ (glPointSize) when drawing GL_POINTS, in addition to the existing
+ behavior of affecting line width when drawing GL_LINES, GL_LINE_STRIP,
+ and GL_LINE_LOOP.
+ - [QTBUG-36069] Fixed TextEdit not vertically aligning its text after
+ having its height changed.
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/qmldir b/examples/quick/demos/photoviewer/PhotoViewerCore/qmldir
deleted file mode 100644
index d3c247f21a..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/qmldir
+++ /dev/null
@@ -1,8 +0,0 @@
-AlbumDelegate AlbumDelegate.qml
-PhotoDelegate PhotoDelegate.qml
-ProgressBar ProgressBar.qml
-RssModel RssModel.qml
-BusyIndicator BusyIndicator.qml
-EditableButton EditableButton.qml
-Button Button.qml
-Tag Tag.qml
diff --git a/examples/quick/demos/photoviewer/deployment.pri b/examples/quick/demos/photoviewer/deployment.pri
new file mode 100644
index 0000000000..839b3b5cac
--- /dev/null
+++ b/examples/quick/demos/photoviewer/deployment.pri
@@ -0,0 +1,23 @@
+android-no-sdk {
+ target.path = /data/user/qt
+ export(target.path)
+ INSTALLS += target
+} else:android {
+ x86 {
+ target.path = /libs/x86
+ } else: armeabi-v7a {
+ target.path = /libs/armeabi-v7a
+ } else {
+ target.path = /libs/armeabi
+ }
+ export(target.path)
+ INSTALLS += target
+} else:unix {
+ isEmpty(target.path) {
+ target.path = /opt/$${TARGET}/bin
+ export(target.path)
+ }
+ INSTALLS += target
+}
+
+export(INSTALLS)
diff --git a/examples/quick/demos/photoviewer/i18n/base.ts b/examples/quick/demos/photoviewer/i18n/base.ts
deleted file mode 100644
index 1accfd2f90..0000000000
--- a/examples/quick/demos/photoviewer/i18n/base.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.0">
-<context>
- <name>AlbumDelegate</name>
- <message>
- <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
- <source>Remove</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-<context>
- <name>photoviewer</name>
- <message>
- <location filename="../photoviewer.qml" line="30"/>
- <source>Add</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../photoviewer.qml" line="39"/>
- <source>Edit</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../photoviewer.qml" line="52"/>
- <source>Back</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-</TS>
diff --git a/examples/quick/demos/photoviewer/i18n/qml_de.qm b/examples/quick/demos/photoviewer/i18n/qml_de.qm
new file mode 100644
index 0000000000..8186e7309f
--- /dev/null
+++ b/examples/quick/demos/photoviewer/i18n/qml_de.qm
Binary files differ
diff --git a/examples/quick/demos/photoviewer/i18n/qml_de.ts b/examples/quick/demos/photoviewer/i18n/qml_de.ts
new file mode 100644
index 0000000000..92ab50a136
--- /dev/null
+++ b/examples/quick/demos/photoviewer/i18n/qml_de.ts
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="de_DE">
+<context>
+ <name>AlbumDelegate</name>
+ <message>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="102"/>
+ <source>Remove</source>
+ <translation>Entfernen</translation>
+ </message>
+</context>
+<context>
+ <name>main</name>
+ <message>
+ <location filename="../main.qml" line="75"/>
+ <source>Add</source>
+ <translation>Zufügen</translation>
+ </message>
+ <message>
+ <location filename="../main.qml" line="84"/>
+ <source>Edit</source>
+ <translation>Bearbeiten</translation>
+ </message>
+ <message>
+ <location filename="../main.qml" line="89"/>
+ <source>Quit</source>
+ <translation>Verlassen</translation>
+ </message>
+ <message>
+ <location filename="../main.qml" line="102"/>
+ <source>Back</source>
+ <translation>Zurück</translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/quick/demos/photoviewer/i18n/qml_fr.qm b/examples/quick/demos/photoviewer/i18n/qml_fr.qm
index c24fcbc46c..e4257d4073 100644
--- a/examples/quick/demos/photoviewer/i18n/qml_fr.qm
+++ b/examples/quick/demos/photoviewer/i18n/qml_fr.qm
Binary files differ
diff --git a/examples/quick/demos/photoviewer/i18n/qml_fr.ts b/examples/quick/demos/photoviewer/i18n/qml_fr.ts
index 9f892db616..1edb5e0fe4 100644
--- a/examples/quick/demos/photoviewer/i18n/qml_fr.ts
+++ b/examples/quick/demos/photoviewer/i18n/qml_fr.ts
@@ -1,28 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
-<TS version="2.0" language="fr_FR">
+<TS version="2.1" language="fr_FR">
<context>
<name>AlbumDelegate</name>
<message>
- <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="102"/>
<source>Remove</source>
<translation>Supprimer</translation>
</message>
</context>
<context>
- <name>photoviewer</name>
+ <name>main</name>
<message>
- <location filename="../photoviewer.qml" line="30"/>
+ <location filename="../main.qml" line="75"/>
<source>Add</source>
<translation>Ajouter</translation>
</message>
<message>
- <location filename="../photoviewer.qml" line="39"/>
+ <location filename="../main.qml" line="84"/>
<source>Edit</source>
<translation>Éditer</translation>
</message>
<message>
- <location filename="../photoviewer.qml" line="52"/>
+ <location filename="../main.qml" line="89"/>
+ <source>Quit</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../main.qml" line="102"/>
<source>Back</source>
<translation>Retour</translation>
</message>
diff --git a/examples/quick/demos/photoviewer/main.cpp b/examples/quick/demos/photoviewer/main.cpp
new file mode 100644
index 0000000000..6ce7c1c1e9
--- /dev/null
+++ b/examples/quick/demos/photoviewer/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QQmlApplicationEngine>
+#include <QTranslator>
+#include <QDebug>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QTranslator qtTranslator;
+ qtTranslator.load("qml_" + QLocale::system().name(), ":/i18n/");
+ app.installTranslator(&qtTranslator);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
+
+ return app.exec();
+}
diff --git a/examples/quick/demos/photoviewer/photoviewer.qml b/examples/quick/demos/photoviewer/main.qml
index df344accd5..f443b70762 100644
--- a/examples/quick/demos/photoviewer/photoviewer.qml
+++ b/examples/quick/demos/photoviewer/main.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtQml module of the Qt Toolkit.
@@ -39,13 +39,16 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.2
+import QtQuick.Controls 1.1
import QtQml.Models 2.1
import "PhotoViewerCore"
-Rectangle {
+ApplicationWindow {
id: mainWindow
+ visible: true
+
property real downloadProgress: 0
property bool imageLoading: false
property bool editMode: false
diff --git a/examples/quick/demos/photoviewer/photoviewer.pro b/examples/quick/demos/photoviewer/photoviewer.pro
new file mode 100644
index 0000000000..704e2ce003
--- /dev/null
+++ b/examples/quick/demos/photoviewer/photoviewer.pro
@@ -0,0 +1,22 @@
+TEMPLATE = app
+
+QT += qml quick widgets xmlpatterns
+
+SOURCES += main.cpp
+
+lupdate_only{
+SOURCES = *.qml \
+ PhotoViewerCore/*.qml \
+ PhotoViewerCore/script/*.js
+}
+
+TRANSLATIONS += i18n/qml_fr.ts \
+ i18n/qml_de.ts
+
+RESOURCES += qml.qrc
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+# Default rules for deployment.
+include(deployment.pri)
diff --git a/examples/quick/demos/photoviewer/photoviewer.qmlproject b/examples/quick/demos/photoviewer/photoviewer.qmlproject
deleted file mode 100644
index 600bdb10f4..0000000000
--- a/examples/quick/demos/photoviewer/photoviewer.qmlproject
+++ /dev/null
@@ -1,20 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "photoviewer.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
- Files {
- filter: "*.ts"
- directory: "i18n"
- }
-}
diff --git a/examples/quick/demos/photoviewer/qml.qrc b/examples/quick/demos/photoviewer/qml.qrc
new file mode 100644
index 0000000000..8abefc6212
--- /dev/null
+++ b/examples/quick/demos/photoviewer/qml.qrc
@@ -0,0 +1,19 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>PhotoViewerCore/AlbumDelegate.qml</file>
+ <file>PhotoViewerCore/BusyIndicator.qml</file>
+ <file>PhotoViewerCore/Button.qml</file>
+ <file>PhotoViewerCore/EditableButton.qml</file>
+ <file>PhotoViewerCore/PhotoDelegate.qml</file>
+ <file>PhotoViewerCore/ProgressBar.qml</file>
+ <file>PhotoViewerCore/RssModel.qml</file>
+ <file>PhotoViewerCore/Tag.qml</file>
+ <file>PhotoViewerCore/images/box-shadow.png</file>
+ <file>PhotoViewerCore/images/busy.png</file>
+ <file>PhotoViewerCore/images/cardboard.png</file>
+ <file>PhotoViewerCore/script/script.js</file>
+ <file>i18n/qml_fr.qm</file>
+ <file>i18n/qml_de.qm</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/demos/stocqt/content/Button.qml b/examples/quick/demos/stocqt/content/Button.qml
index 6cad4e135e..38b553fb31 100644
--- a/examples/quick/demos/stocqt/content/Button.qml
+++ b/examples/quick/demos/stocqt/content/Button.qml
@@ -47,17 +47,17 @@ Rectangle {
property bool buttonEnabled: false
width: Math.max(64, txt.width + 16)
height: 32
- color: buttonEnabled ? "#76644A" : "transparent"
- border.color: "#76644A"
- border.width: 1
+ color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: button.clicked()
}
Text {
anchors.centerIn: parent
- font.pixelSize: 18
- color: "#ecc089"
+ font.family: "Open Sans"
+ font.pointSize: 19
+ font.weight: Font.DemiBold
+ color: button.buttonEnabled ? "#000000" : "#14aaff"
id: txt
}
}
diff --git a/examples/quick/demos/stocqt/content/CheckBox.qml b/examples/quick/demos/stocqt/content/CheckBox.qml
index 1e7dcf7c74..5d9accaf7f 100644
--- a/examples/quick/demos/stocqt/content/CheckBox.qml
+++ b/examples/quick/demos/stocqt/content/CheckBox.qml
@@ -42,10 +42,9 @@ import QtQuick 2.0
Item {
id: button
- property alias text: txt.text
property bool buttonEnabled: true
- width: 140
- height: 25
+ width: 30
+ height: 30
x: 5
MouseArea {
id: mouse
@@ -59,29 +58,20 @@ Item {
}
Rectangle {
id: checkbox
- width: 23
- height: 23
+ width: 30
+ height: 30
anchors.left: parent.left
- border.color: "#76644A"
+ border.color: "#999999"
border.width: 1
antialiasing: true
radius: 2
color: "transparent"
Rectangle {
anchors.fill: parent
- anchors.margins: 4
+ anchors.margins: 5
antialiasing: true
radius: 1
- color: mouse.pressed || buttonEnabled ? "#76644A" : "transparent"
+ color: mouse.pressed || buttonEnabled ? "#999999" : "transparent"
}
}
- Text {
- id: txt
- anchors.left: checkbox.right
- anchors.leftMargin: 4
- anchors.verticalCenter: parent.verticalCenter
- text: "Close "
- color: "#ecc089"
- font.pixelSize: 18
- }
}
diff --git a/examples/quick/demos/stocqt/content/DatePicker.qml b/examples/quick/demos/stocqt/content/DatePicker.qml
deleted file mode 100644
index 6c0df2a41a..0000000000
--- a/examples/quick/demos/stocqt/content/DatePicker.qml
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- color: "transparent"
- width: 300
- height: 40
- property var _monthNames: [ "JAN", "FEB", "MAR", "APR", "MAY", "JUN","JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ];
- property var date: new Date()
-
- onDateChanged: {
- month.text = root._monthNames[root.date.getMonth()];
- day.text = date.getDate();
- year.text = date.getFullYear();
- }
- Row {
- spacing: 4
- anchors.fill: parent
-
- Rectangle {
- height: root.height
- width: root.width/3 - 20
- color: "#272822"
- border.color: "#76644A"
- border.width: 1
- radius: 2
- antialiasing: true
-
- TextInput {
- id: month
- anchors.centerIn: parent
- color: "#ecc089"
- font.pointSize: 25
- font.bold: true
- text: root._monthNames[root.date.getMonth()]
- onAccepted: {
- for (var i = 0; i < 12; i++) {
- if (text === root._monthNames[i]) {
- root.date.setMonth(i);
- root.date = root.date;
- return;
- }
- }
- root.date = root.date;
- }
- }
- }
-
- Rectangle {
- height: root.height
- width: root.width/3 - 20
- color: "#272822"
- border.color: "#76644A"
- border.width: 1
- radius: 2
- antialiasing: true
-
- TextInput {
- id: day
- anchors.centerIn: parent
- color: "#ecc089"
- font.pointSize: 25
- font.bold: true
- text: root.date.getDate()
- validator:IntValidator {bottom: 1; top: 31}
- onAccepted: { root.date.setDate(text); root.date = root.date;}
- }
- }
-
- Rectangle {
- height: root.height
- width: root.width/3 - 20
- color: "#272822"
- border.color: "#76644A"
- border.width: 1
- radius: 2
- antialiasing: true
-
- TextInput {
- id: year
- anchors.centerIn: parent
- color: "#ecc089"
- font.pointSize: 25
- font.bold: true
- text: root.date.getFullYear()
- validator: IntValidator {bottom: 1995; top: (new Date()).getFullYear()}
- onAccepted:{ root.date.setFullYear(text); root.date = root.date;}
- }
- }
- }
-}
diff --git a/examples/quick/demos/stocqt/content/StockChart.qml b/examples/quick/demos/stocqt/content/StockChart.qml
index f7e0d0206b..e6bc02306e 100644
--- a/examples/quick/demos/stocqt/content/StockChart.qml
+++ b/examples/quick/demos/stocqt/content/StockChart.qml
@@ -43,93 +43,155 @@ import QtQuick 2.0
Rectangle {
id: chart
width: 320
- height: 320
+ height: 200
color: "transparent"
property var _months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
property var stockModel: null
property var startDate: new Date()
property var endDate: new Date()
+ property string activeChart: "year"
property var settings
function update() {
- if (settings.chartType === "year")
+ endDate = new Date();
+ if (chart.activeChart === "year")
chart.startDate = new Date(chart.endDate.getFullYear() - 1, chart.endDate.getMonth(), chart.endDate.getDate());
- else if (settings.chartType === "month")
+ else if (chart.activeChart === "month")
chart.startDate = new Date(chart.endDate.getFullYear() , chart.endDate.getMonth() -1, chart.endDate.getDate());
- else if (settings.chartType === "week")
+ else if (chart.activeChart === "week")
chart.startDate = new Date(chart.endDate.getFullYear() , chart.endDate.getMonth(), chart.endDate.getDate() - 7);
else
- chart.startDate = new Date(1995, 3, 25);
+ chart.startDate = new Date(2005, 3, 25);
canvas.requestPaint();
}
+ Row {
+ id: activeChartRow
+ anchors.left: chart.left
+ anchors.right: chart.right
+ anchors.top: chart.top
+ anchors.topMargin: 4
+ spacing: 52
+ onWidthChanged: {
+ var buttonsLen = maxButton.width + yearButton.width + monthButton.width + weekButton.width;
+ var space = (width - buttonsLen) / 3;
+ spacing = Math.max(space, 10);
+ }
+
+ Button {
+ id: maxButton
+ text: "Max"
+ buttonEnabled: chart.activeChart === "max"
+ onClicked: {
+ chart.activeChart = "max";
+ chart.update();
+ }
+ }
+ Button {
+ id: yearButton
+ text: "Year"
+ buttonEnabled: chart.activeChart === "year"
+ onClicked: {
+ chart.activeChart = "year";
+ chart.update();
+ }
+ }
+ Button {
+ id: monthButton
+ text: "Month"
+ buttonEnabled: chart.activeChart === "month"
+ onClicked: {
+ chart.activeChart = "month";
+ chart.update();
+ }
+ }
+ Button {
+ id: weekButton
+ text: "Week"
+ buttonEnabled: chart.activeChart === "week"
+ onClicked: {
+ chart.activeChart = "week";
+ chart.update();
+ }
+ }
+ }
+
Text {
id: fromDate
- color: "#6a5b44"
+ color: "#000000"
width: 50
+ font.family: "Open Sans"
font.pointSize: 10
wrapMode: Text.WordWrap
anchors.left: parent.left
anchors.leftMargin: 20
- anchors.top: parent.top
+ anchors.bottom: parent.bottom
text: _months[startDate.getMonth()] + "\n" + startDate.getFullYear()
}
Text {
id: toDate
- color: "#6a5b44"
+ color: "#000000"
font.pointSize: 10
width: 50
wrapMode: Text.WordWrap
anchors.right: parent.right
anchors.leftMargin: 20
- anchors.top: parent.top
+ anchors.bottom: parent.bottom
text: _months[endDate.getMonth()] + "\n" + endDate.getFullYear()
}
Canvas {
id: canvas
- width: parent.width
- anchors.top: toDate.bottom
- anchors.bottom: parent.bottom
- renderTarget: Canvas.FramebufferObject
+ anchors.top: activeChartRow.bottom
+ anchors.left: chart.left
+ anchors.right: chart.right
+ anchors.bottom: fromDate.top
antialiasing: true
- property int frames: first
- property int mouseX: 0
- property int mouseY: 0
- property int mousePressedX: 0
- property int mousePressedY: 0
- property int movedY: 0
- property real scaleX: 1.0
- property real scaleY: 1.0
- property int first: 0
- property int last: 0
property int pixelSkip: 1
+ property real xGridOffset: width / 13
+ property real xGridStep: width / 4
+ property real yGridOffset: height / 26
+ property real yGridStep: height / 12
+
function drawBackground(ctx) {
ctx.save();
- ctx.fillStyle = "#272822";
+ ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 0, canvas.width, canvas.height);
- ctx.strokeStyle = "#423a2f";
+ ctx.strokeStyle = "#d7d7d7";
ctx.beginPath();
- for (var i = 0; i < 10; i++) {
- ctx.moveTo(0, i * (canvas.height/10.0));
- ctx.lineTo(canvas.width, i * (canvas.height/10.0));
+ // Horizontal grid lines
+ for (var i = 0; i < 12; i++) {
+ ctx.moveTo(0, canvas.yGridOffset + i * canvas.yGridStep);
+ ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep);
}
- for (i = 0; i < 12; i++) {
- ctx.moveTo(i * (canvas.width/12.0), 0);
- ctx.lineTo(i * (canvas.width/12.0), canvas.height);
+ // Vertical grid lines
+ var height = 35 * canvas.height / 36;
+ var yOffset = canvas.height - height;
+ for (i = 0; i < 4; i++) {
+ ctx.moveTo(canvas.xGridOffset + i * canvas.xGridStep, yOffset);
+ ctx.lineTo(canvas.xGridOffset + i * canvas.xGridStep, height);
}
ctx.stroke();
- ctx.strokeStyle = "#5c7a37";
+ // Right ticks
+ ctx.strokeStyle = "#666666";
ctx.beginPath();
- ctx.moveTo(8 * (canvas.width/12.0), 0);
- ctx.lineTo(8 * (canvas.width/12.0), canvas.height);
+ var xStart = 35 * canvas.width / 36;
+ ctx.moveTo(xStart, 0);
+ ctx.lineTo(xStart, canvas.height);
+ for (i = 0; i < 12; i++) {
+ ctx.moveTo(xStart, canvas.yGridOffset + i * canvas.yGridStep);
+ ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep);
+ }
+ ctx.moveTo(0, canvas.yGridOffset + 9 * canvas.yGridStep);
+ ctx.lineTo(canvas.width, canvas.yGridOffset + 9 * canvas.yGridStep);
+ ctx.closePath();
ctx.stroke();
ctx.restore();
@@ -140,64 +202,29 @@ Rectangle {
ctx.save();
ctx.globalAlpha = 0.7;
ctx.strokeStyle = color;
- ctx.lineWidth = 1;
+ ctx.lineWidth = 3;
ctx.beginPath();
- var w = canvas.width/points.length;
var end = points.length;
- for (var i = 0; i < end; i+=pixelSkip) {
- var x = points[i].x;
+ var xOffset = canvas.width / 36
+
+ for (var i = 0; i < end; i += pixelSkip) {
+ var x = 34 * points[i].x / 36 + xOffset;
var y = points[i][price];
+
y = canvas.height * y/highest;
+ y = canvas.height - y;
+ y = 9 * y / 12 + yGridOffset; // Scaling to graph area
if (i == 0) {
- ctx.moveTo(x+w/2, y);
+ ctx.moveTo(x, y);
} else {
- ctx.lineTo(x+w/2, y);
+ ctx.lineTo(x, y);
}
}
ctx.stroke();
ctx.restore();
}
- function drawKLine(ctx, from, to, points, highest)
- {
- ctx.save();
- ctx.globalAlpha = 0.4;
- ctx.lineWidth = 2;
- var end = points.length;
- for (var i = 0; i < end; i+=pixelSkip) {
- var x = points[i].x;
- var open = canvas.height * points[i].open/highest - canvas.movedY;
- var close = canvas.height * points[i].close/highest - canvas.movedY;
- var high = canvas.height * points[i].high/highest - canvas.movedY;
- var low = canvas.height * points[i].low/highest - canvas.movedY;
-
- var top, bottom;
- if (close <= open) {
- ctx.fillStyle = Qt.rgba(1, 0, 0, 1);
- ctx.strokeStyle = Qt.rgba(1, 0, 0, 1);
- top = close;
- bottom = open;
- } else {
- ctx.fillStyle = Qt.rgba(0, 1, 0, 1);
- ctx.strokeStyle = Qt.rgba(0, 1, 0, 1);
- top = open;
- bottom = close;
- }
-
- var w1, w2;
- w1 = canvas.width/points.length;
- w2 = w1 > 10 ? w1/2 : w1;
-
- ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top);
- ctx.beginPath();
- ctx.moveTo(x+w1/2, high);
- ctx.lineTo(x+w1/2, low);
- ctx.stroke();
- }
- ctx.restore();
- }
-
function drawVolume(ctx, from, to, color, price, points, highest)
{
ctx.save();
@@ -211,7 +238,8 @@ Rectangle {
var x = points[i].x;
var y = points[i][price];
y = canvas.height * (1 - y/highest);
- ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y);
+ y = 3 * y / 13;
+ ctx.fillRect(x, canvas.height - y, canvas.width/points.length, y);
}
ctx.restore();
}
@@ -223,41 +251,39 @@ Rectangle {
ctx.lineWidth = 1;
drawBackground(ctx);
- if (!stockModel.ready)
+
+ if (!stockModel.ready) {
return;
+ }
- last = stockModel.indexOf(chart.endDate)
- first = last - (chart.endDate.getTime() - chart.startDate.getTime())/86400000;
- first = Math.max(first, 0);
- console.log("painting... first:" + first + ", last:" + last);
+ var last = stockModel.indexOf(chart.startDate);
+ var first = 0;
var highestPrice = stockModel.highestPrice;
var highestVolume = stockModel.highestVolume;
- console.log("highest price:" + highestPrice + ", highest volume:" + highestVolume)
var points = [];
- for (var i = 0; i <= last - first; i+=pixelSkip) {
- var price = stockModel.get(i + first);
+ var step = canvas.width / (last + 0);
+ for (var i = last, j = 0; i >= 0 ; i -= pixelSkip, j += pixelSkip) {
+ var price = stockModel.get(i);
points.push({
- x: i*canvas.width/(last-first+1),
+ x: j * step,
open: price.open,
close: price.close,
- high:price.high,
- low:price.low,
- volume:price.volume
+ high: price.high,
+ low: price.low,
+ volume: price.volume
});
}
+
if (settings.drawHighPrice)
- drawPrice(ctx, first, last, settings.highColor,"high", points, highestPrice);
+ drawPrice(ctx, first, last, settings.highColor, "high", points, highestPrice);
if (settings.drawLowPrice)
- drawPrice(ctx, first, last, settings.lowColor,"low", points, highestPrice);
+ drawPrice(ctx, first, last, settings.lowColor, "low", points, highestPrice);
if (settings.drawOpenPrice)
- drawPrice(ctx, first, last,settings.openColor,"open", points, highestPrice);
+ drawPrice(ctx, first, last,settings.openColor, "open", points, highestPrice);
if (settings.drawClosePrice)
- drawPrice(ctx, first, last, settings.closeColor,"close", points, highestPrice);
- if (settings.drawVolume)
- drawVolume(ctx, first, last, settings.volumeColor,"volume", points, highestVolume);
- if (settings.drawKLine)
- drawKLine(ctx, first, last, points, highestPrice);
+ drawPrice(ctx, first, last, settings.closeColor, "close", points, highestPrice);
+ drawVolume(ctx, first, last, settings.volumeColor, "volume", points, highestVolume);
}
}
}
diff --git a/examples/quick/demos/stocqt/content/StockInfo.qml b/examples/quick/demos/stocqt/content/StockInfo.qml
new file mode 100644
index 0000000000..3178f03098
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockInfo.qml
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 440
+ height: 160
+ color: "transparent"
+
+ property var stock: null
+
+ Text {
+ id: stockIdText
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ anchors.top: parent.top
+ anchors.topMargin: 15
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 38
+ font.weight: Font.DemiBold
+ text: root.stock.stockId
+ }
+
+ Text {
+ id: stockNameText
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ anchors.bottom: priceChangePercentage.bottom
+ anchors.right: priceChangePercentage.left
+ anchors.rightMargin: 15
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 16
+ elide: Text.ElideRight
+ text: root.stock.stockName
+ }
+
+ Text {
+ id: price
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ anchors.top: parent.top
+ anchors.topMargin: 15
+ horizontalAlignment: Text.AlignRight
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 30
+ font.weight: Font.DemiBold
+ text: root.stock.stockPrice
+ }
+
+ Text {
+ id: priceChange
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ anchors.top: price.bottom
+ anchors.topMargin: 5
+ horizontalAlignment: Text.AlignRight
+ color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
+ font.family: "Open Sans"
+ font.pointSize: 20
+ font.weight: Font.Bold
+ text: root.stock.stockPriceChanged
+ }
+
+ Text {
+ id: priceChangePercentage
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ anchors.top: priceChange.bottom
+ anchors.topMargin: 5
+ horizontalAlignment: Text.AlignRight
+ color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
+ font.family: "Open Sans"
+ font.pointSize: 18
+ font.weight: Font.Bold
+ text: Math.abs(Math.round(root.stock.stockPriceChanged/(root.stock.stockPrice - root.stock.stockPriceChanged) * 100))/100 +"%"
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/StockListModel.qml b/examples/quick/demos/stocqt/content/StockListModel.qml
index 635e3afb4a..a0e5590763 100644
--- a/examples/quick/demos/stocqt/content/StockListModel.qml
+++ b/examples/quick/demos/stocqt/content/StockListModel.qml
@@ -43,104 +43,104 @@ import QtQuick 2.0
ListModel {
id: stocks
// Data from : http://en.wikipedia.org/wiki/NASDAQ-100
- ListElement {name: "Activision Blizzard"; stockId: "ATVI"}
- ListElement {name: "Adobe Systems Incorporated"; stockId: "ADBE"}
- ListElement {name: "Akamai Technologies, Inc"; stockId: "AKAM"}
- ListElement {name: "Alexion Pharmaceuticals"; stockId: "ALXN"}
- ListElement {name: "Altera Corporation"; stockId: "ALTR"}
- ListElement {name: "Amazon.com, Inc."; stockId: "AMZN"}
- ListElement {name: "Amgen Inc."; stockId: "AMGN"}
- ListElement {name: "Apollo Group, Inc."; stockId: "APOL"}
- ListElement {name: "Apple Inc."; stockId: "AAPL"}
- ListElement {name: "Applied Materials, Inc."; stockId: "AMAT"}
- ListElement {name: "Autodesk, Inc."; stockId: "ADSK"}
- ListElement {name: "Automatic Data Processing, Inc."; stockId: "ADP"}
- ListElement {name: "Baidu.com, Inc."; stockId: "BIDU"}
- ListElement {name: "Bed Bath & Beyond Inc."; stockId: "BBBY"}
- ListElement {name: "Biogen Idec, Inc"; stockId: "BIIB"}
- ListElement {name: "BMC Software, Inc."; stockId: "BMC"}
- ListElement {name: "Broadcom Corporation"; stockId: "BRCM"}
- ListElement {name: "C. H. Robinson Worldwide, Inc."; stockId: "CHRW"}
- ListElement {name: "CA, Inc."; stockId: "CA"}
- ListElement {name: "Celgene Corporation"; stockId: "CELG"}
- ListElement {name: "Cephalon, Inc."; stockId: "CEPH"}
- ListElement {name: "Cerner Corporation"; stockId: "CERN"}
- ListElement {name: "Check Point Software Technologies Ltd."; stockId: "CHKP"}
- ListElement {name: "Cisco Systems, Inc."; stockId: "CSCO"}
- ListElement {name: "Citrix Systems, Inc."; stockId: "CTXS"}
- ListElement {name: "Cognizant Technology Solutions Corporation"; stockId: "CTSH"}
- ListElement {name: "Comcast Corporation"; stockId: "CMCSA"}
- ListElement {name: "Costco Wholesale Corporation"; stockId: "COST"}
- ListElement {name: "Ctrip.com International, Ltd."; stockId: "CTRP"}
- ListElement {name: "Dell Inc."; stockId: "DELL"}
- ListElement {name: "DENTSPLY International Inc."; stockId: "XRAY"}
- ListElement {name: "DirecTV"; stockId: "DTV"}
- ListElement {name: "Dollar Tree, Inc."; stockId: "DLTR"}
- ListElement {name: "eBay Inc."; stockId: "EBAY"}
- ListElement {name: "Electronic Arts Inc."; stockId: "ERTS"}
- ListElement {name: "Expedia, Inc."; stockId: "EXPE"}
- ListElement {name: "Expeditors International of Washington, Inc."; stockId: "EXPD"}
- ListElement {name: "Express Scripts, Inc."; stockId: "ESRX"}
- ListElement {name: "F5 Networks, Inc."; stockId: "FFIV"}
- ListElement {name: "Fastenal Company"; stockId: "FAST"}
- ListElement {name: "First Solar, Inc."; stockId: "FSLR"}
- ListElement {name: "Fiserv, Inc."; stockId: "FISV"}
- ListElement {name: "Flextronics International Ltd."; stockId: "FLEX"}
- ListElement {name: "FLIR Systems, Inc."; stockId: "FLIR"}
- ListElement {name: "Garmin Ltd."; stockId: "GRMN"}
- ListElement {name: "Gilead Sciences, Inc."; stockId: "GILD"}
- ListElement {name: "Google Inc."; stockId: "GOOG"}
- ListElement {name: "Green Mountain Coffee Roasters, Inc."; stockId: "GMCR"}
- ListElement {name: "Henry Schein, Inc."; stockId: "HSIC"}
- ListElement {name: "Illumina, Inc."; stockId: "ILMN"}
- ListElement {name: "Infosys Technologies"; stockId: "INFY"}
- ListElement {name: "Intel Corporation"; stockId: "INTC"}
- ListElement {name: "Intuit, Inc."; stockId: "INTU"}
- ListElement {name: "Intuitive Surgical Inc."; stockId: "ISRG"}
- ListElement {name: "Joy Global Inc."; stockId: "JOYG"}
- ListElement {name: "KLA Tencor Corporation"; stockId: "KLAC"}
- ListElement {name: "Lam Research Corporation"; stockId: "LRCX"}
- ListElement {name: "Liberty Media Corporation, Interactive Series A"; stockId: "LINTA"}
- ListElement {name: "Life Technologies Corporation"; stockId: "LIFE"}
- ListElement {name: "Linear Technology Corporation"; stockId: "LLTC"}
- ListElement {name: "Marvell Technology Group, Ltd."; stockId: "MRVL"}
- ListElement {name: "Mattel, Inc."; stockId: "MAT"}
- ListElement {name: "Maxim Integrated Products"; stockId: "MXIM"}
- ListElement {name: "Microchip Technology Incorporated"; stockId: "MCHP"}
- ListElement {name: "Micron Technology, Inc."; stockId: "MU"}
- ListElement {name: "Microsoft Corporation"; stockId: "MSFT"}
- ListElement {name: "Mylan, Inc."; stockId: "MYL"}
- ListElement {name: "NetApp, Inc."; stockId: "NTAP"}
- ListElement {name: "Netflix, Inc."; stockId: "NFLX"}
- ListElement {name: "News Corporation, Ltd."; stockId: "NWSA"}
- ListElement {name: "NII Holdings, Inc."; stockId: "NIHD"}
- ListElement {name: "NVIDIA Corporation"; stockId: "NVDA"}
- ListElement {name: "O'Reilly Automotive, Inc."; stockId: "ORLY"}
- ListElement {name: "Oracle Corporation"; stockId: "ORCL"}
- ListElement {name: "PACCAR Inc."; stockId: "PCAR"}
- ListElement {name: "Paychex, Inc."; stockId: "PAYX"}
- ListElement {name: "Priceline.com, Incorporated"; stockId: "PCLN"}
- ListElement {name: "Qiagen N.V."; stockId: "QGEN"}
- ListElement {name: "QUALCOMM Incorporated"; stockId: "QCOM"}
- ListElement {name: "Research in Motion Limited"; stockId: "RIMM"}
- ListElement {name: "Ross Stores Inc."; stockId: "ROST"}
- ListElement {name: "SanDisk Corporation"; stockId: "SNDK"}
- ListElement {name: "Seagate Technology Holdings"; stockId: "STX"}
- ListElement {name: "Sears Holdings Corporation"; stockId: "SHLD"}
- ListElement {name: "Sigma-Aldrich Corporation"; stockId: "SIAL"}
- ListElement {name: "Staples Inc."; stockId: "SPLS"}
- ListElement {name: "Starbucks Corporation"; stockId: "SBUX"}
- ListElement {name: "Stericycle, Inc"; stockId: "SRCL"}
- ListElement {name: "Symantec Corporation"; stockId: "SYMC"}
- ListElement {name: "Teva Pharmaceutical Industries Ltd."; stockId: "TEVA"}
- ListElement {name: "Urban Outfitters, Inc."; stockId: "URBN"}
- ListElement {name: "VeriSign, Inc."; stockId: "VRSN"}
- ListElement {name: "Vertex Pharmaceuticals"; stockId: "VRTX"}
- ListElement {name: "Virgin Media, Inc."; stockId: "VMED"}
- ListElement {name: "Vodafone Group, plc."; stockId: "VOD"}
- ListElement {name: "Warner Chilcott, Ltd."; stockId: "WCRX"}
- ListElement {name: "Whole Foods Market, Inc."; stockId: "WFM"}
- ListElement {name: "Wynn Resorts Ltd."; stockId: "WYNN"}
- ListElement {name: "Xilinx, Inc."; stockId: "XLNX"}
- ListElement {name: "Yahoo! Inc."; stockId: "YHOO"}
+ ListElement {name: "Apple Inc."; stockId: "AAPL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Adobe Systems Inc."; stockId: "ADBE"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Analog Devices, Inc."; stockId: "ADI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Automatic Data Processing, Inc."; stockId: "ADP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Autodesk, Inc."; stockId: "ADSK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Akamai Technologies, Inc."; stockId: "AKAM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Altera Corp."; stockId: "ALTR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Alexion Pharmaceuticals, Inc."; stockId: "ALXN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Applied Materials, Inc."; stockId: "AMAT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Amgen Inc."; stockId: "AMGN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Amazon.com Inc."; stockId: "AMZN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Activision Blizzard, Inc."; stockId: "ATVI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Avago Technologies Limited"; stockId: "AVGO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Bed Bath & Beyond Inc."; stockId: "BBBY"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Baidu, Inc."; stockId: "BIDU"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Biogen Idec Inc."; stockId: "BIIB"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Broadcom Corp."; stockId: "BRCM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "CA Technologies"; stockId: "CA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Celgene Corporation"; stockId: "CELG"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Cerner Corporation"; stockId: "CERN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Check Point Software Technologies Ltd."; stockId: "CHKP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "CH Robinson Worldwide Inc."; stockId: "CHRW"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Charter Communications, Inc."; stockId: "CHTR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Comcast Corporation"; stockId: "CMCSA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Costco Wholesale Corporation"; stockId: "COST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Cisco Systems, Inc."; stockId: "CSCO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Catamaran Corporation"; stockId: "CTRX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Cognizant Technology Solutions Corporation"; stockId: "CTSH"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Citrix Systems, Inc."; stockId: "CTXS"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Discovery Communications, Inc."; stockId: "DISCA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Dish Network Corp."; stockId: "DISH"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Dollar Tree, Inc."; stockId: "DLTR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "DIRECTV"; stockId: "DTV"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "eBay Inc."; stockId: "EBAY"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Equinix, Inc."; stockId: "EQIX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Express Scripts Holding Company"; stockId: "ESRX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Expeditors International of Washington Inc."; stockId: "EXPD"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Expedia Inc."; stockId: "EXPE"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Fastenal Company"; stockId: "FAST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Facebook, Inc."; stockId: "FB"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "F5 Networks, Inc."; stockId: "FFIV"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Fiserv, Inc."; stockId: "FISV"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Twenty-First Century Fox, Inc."; stockId: "FOXA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Gilead Sciences Inc."; stockId: "GILD"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Keurig Green Mountain, Inc."; stockId: "GMCR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Google Inc."; stockId: "GOOG"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Google Inc."; stockId: "GOOGL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Garmin Ltd."; stockId: "GRMN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Henry Schein, Inc."; stockId: "HSIC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Illumina Inc."; stockId: "ILMN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Intel Corporation"; stockId: "INTC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Intuit Inc."; stockId: "INTU"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Intuitive Surgical, Inc."; stockId: "ISRG"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "KLA-Tencor Corporation"; stockId: "KLAC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Kraft Foods Group, Inc."; stockId: "KRFT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Liberty Global plc"; stockId: "LBTYA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Liberty Interactive Corporation"; stockId: "LINTA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Linear Technology Corporation"; stockId: "LLTC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Liberty Media Corporation"; stockId: "LMCA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Marriott International, Inc."; stockId: "MAR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Mattel, Inc"; stockId: "MAT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Mondelez International, Inc."; stockId: "MDLZ"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Monster Beverage Corporation"; stockId: "MNST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Microsoft Corporation"; stockId: "MSFT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Micron Technology Inc."; stockId: "MU"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Maxim Integrated Products, Inc."; stockId: "MXIM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Mylan, Inc."; stockId: "MYL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Netflix, Inc."; stockId: "NFLX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "NetApp, Inc."; stockId: "NTAP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "NVIDIA Corporation"; stockId: "NVDA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "NXP Semiconductors NV"; stockId: "NXPI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "O'Reilly Automotive Inc."; stockId: "ORLY"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Paychex, Inc."; stockId: "PAYX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "PACCAR Inc."; stockId: "PCAR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "The Priceline Group Inc."; stockId: "PCLN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "QUALCOMM Incorporated"; stockId: "QCOM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Regeneron Pharmaceuticals, Inc."; stockId: "REGN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Ross Stores Inc."; stockId: "ROST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "SBA Communications Corp."; stockId: "SBAC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Starbucks Corporation"; stockId: "SBUX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Sigma-Aldrich Corporation"; stockId: "SIAL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Sirius XM Holdings Inc."; stockId: "SIRI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "SanDisk Corp."; stockId: "SNDK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Staples, Inc."; stockId: "SPLS"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Stericycle, Inc."; stockId: "SRCL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Seagate Technology Public Limited Company"; stockId: "STX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Symantec Corporation"; stockId: "SYMC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "TripAdvisor Inc."; stockId: "TRIP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Tractor Supply Company"; stockId: "TSCO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Tesla Motors, Inc."; stockId: "TSLA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Texas Instruments Inc."; stockId: "TXN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Viacom, Inc."; stockId: "VIAB"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "VimpelCom Ltd."; stockId: "VIP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Vodafone Group Public Limited Company"; stockId: "VOD"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Verisk Analytics, Inc."; stockId: "VRSK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Vertex Pharmaceuticals Incorporated"; stockId: "VRTX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Western Digital Corporation"; stockId: "WDC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Whole Foods Market, Inc."; stockId: "WFM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Wynn Resorts Ltd."; stockId: "WYNN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
+ ListElement {name: "Xilinx Inc."; stockId: "XLNX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
}
diff --git a/examples/quick/demos/stocqt/content/StockListView.qml b/examples/quick/demos/stocqt/content/StockListView.qml
index 3345e5d804..72d8df2440 100644
--- a/examples/quick/demos/stocqt/content/StockListView.qml
+++ b/examples/quick/demos/stocqt/content/StockListView.qml
@@ -43,8 +43,10 @@ import QtQuick 2.0
Rectangle {
id: root
width: 320
- height: 480
- color: "#423A2F"
+ height: 410
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ color: "white"
property string currentStockId: ""
property string currentStockName: ""
@@ -52,39 +54,196 @@ Rectangle {
ListView {
id: view
anchors.fill: parent
+ width: parent.width
+ clip: true
keyNavigationWraps: true
+ highlightMoveDuration: 0
focus: true
snapMode: ListView.SnapToItem
model: StockListModel{}
+ function requestUrl(stockId) {
+ var endDate = new Date(""); //today
+ var startDate = new Date()
+ startDate.setDate(startDate.getDate() - 5);
+
+ var request = "http://ichart.finance.yahoo.com/table.csv?";
+ request += "s=" + stockId;
+ request += "&g=d";
+ request += "&a=" + startDate.getMonth();
+ request += "&b=" + startDate.getDate();
+ request += "&c=" + startDate.getFullYear();
+ request += "&d=" + endDate.getMonth();
+ request += "&e=" + endDate.getDate();
+ request += "&f=" + endDate.getFullYear();
+ request += "&g=d";
+ request += "&ignore=.csv";
+ return request;
+ }
+
+ function getCloseValue(index) {
+ var req = requestUrl(model.get(index).stockId);
+
+ if (!req)
+ return;
+
+ var xhr = new XMLHttpRequest;
+
+ xhr.open("GET", req, true);
+
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === XMLHttpRequest.LOADING || xhr.readyState === XMLHttpRequest.DONE) {
+ var records = xhr.responseText.split('\n');
+ if (records.length > 0) {
+ var r = records[1].split(',');
+ model.setProperty(index, "value", r[4]);
+
+ var today = parseFloat(r[4]);
+ r = records[2].split(',');
+ var yesterday = parseFloat(r[4]);
+ var change = today - yesterday;
+ if (change >= 0.0)
+ model.setProperty(index, "change", "+" + change.toFixed(2));
+ else
+ model.setProperty(index, "change", change.toFixed(2));
+
+ var changePercentage = (change / yesterday) * 100.0;
+ if (changePercentage >= 0.0)
+ model.setProperty(index, "changePercentage", "+" + changePercentage.toFixed(2) + "%");
+ else
+ model.setProperty(index, "changePercentage", changePercentage.toFixed(2) + "%");
+ }
+ }
+ }
+ xhr.send()
+ }
+
onCurrentIndexChanged: {
+ mainRect.listViewActive = 0;
root.currentStockId = model.get(currentIndex).stockId;
root.currentStockName = model.get(currentIndex).name;
- console.log("current stock:" + root.currentStockId + " - " + root.currentStockName);
}
delegate: Rectangle {
- height: 30
+ height: 102
width: parent.width
color: "transparent"
MouseArea {
anchors.fill: parent;
- onClicked:view.currentIndex = index;
+ onClicked: {
+ view.currentIndex = index;
+ }
}
Text {
- anchors.verticalCenter: parent.top
- anchors.verticalCenterOffset : 15
- color: index == view.currentIndex ? "#ECC089" : "#A58963"
- font.pointSize: 12
+ id: stockIdText
+ anchors.top: parent.top
+ anchors.topMargin: 15
+ anchors.left: parent.left
+ anchors.leftMargin: 15
+ width: 125
+ height: 40
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 20
+ font.weight: Font.Bold
+ verticalAlignment: Text.AlignVCenter
+ text: stockId
+ }
+
+ Text {
+ id: stockValueText
+ anchors.top: parent.top
+ anchors.topMargin: 15
+ anchors.right: parent.right
+ anchors.rightMargin: 0.31 * parent.width
+ width: 190
+ height: 40
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 20
font.bold: true
- text:" " + stockId + " - " + name
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ text: value
+ Component.onCompleted: view.getCloseValue(index);
+ }
+
+ Text {
+ id: stockValueChangeText
+ anchors.top: parent.top
+ anchors.topMargin: 15
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ width: 135
+ height: 40
+ color: "#328930"
+ font.family: "Open Sans"
+ font.pointSize: 20
+ font.bold: true
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ text: change
+ onTextChanged: {
+ if (parseFloat(text) >= 0.0)
+ color = "#328930";
+ else
+ color = "#d40000";
+ }
+ }
+
+ Text {
+ id: stockNameText
+ anchors.top: stockIdText.bottom
+ anchors.left: parent.left
+ anchors.leftMargin: 15
+ width: 330
+ height: 30
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 16
+ font.bold: false
+ elide: Text.ElideRight
+ maximumLineCount: 1
+ verticalAlignment: Text.AlignVCenter
+ text: name
+ }
+
+ Text {
+ id: stockValueChangePercentageText
+ anchors.top: stockIdText.bottom
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ width: 120
+ height: 30
+ color: "#328930"
+ font.family: "Open Sans"
+ font.pointSize: 18
+ font.bold: false
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ text: changePercentage
+ onTextChanged: {
+ if (parseFloat(text) >= 0.0)
+ color = "#328930";
+ else
+ color = "#d40000";
+ }
+ }
+
+ Rectangle {
+ id: endingLine
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ height: 1
+ width: parent.width
+ color: "#d7d7d7"
}
}
highlight: Rectangle {
width: parent.width
- color: "#662"
+ color: "#eeeeee"
}
}
}
diff --git a/examples/quick/demos/stocqt/content/StockModel.qml b/examples/quick/demos/stocqt/content/StockModel.qml
index f9ed9c87d4..682c96bb53 100644
--- a/examples/quick/demos/stocqt/content/StockModel.qml
+++ b/examples/quick/demos/stocqt/content/StockModel.qml
@@ -44,8 +44,6 @@ ListModel {
id: model
property string stockId: ""
property string stockName: ""
- property var startDate
- property var endDate
property string stockDataCycle: "d"
property bool ready: false
property real stockPrice: 0.0
@@ -56,19 +54,28 @@ ListModel {
signal dataReady
function indexOf(date) {
- var end = new Date(model.get(0).date);
- var start = new Date(model.get(model.count - 1).date);
- if (end <= date)
- return model.count -1;
+ var newest = new Date(model.get(0).date);
+ var oldest = new Date(model.get(model.count - 1).date);
+ if (newest <= date)
+ return -1;
- if (start >= date)
- return 0;
+ if (oldest >= date)
+ return model.count - 1;
+ var currDiff = 0;
+ var bestDiff = Math.abs(date.getTime() - newest.getTime());
+ var retval = 0;
for (var i = 0; i < model.count; i++) {
var d = new Date(model.get(i).date);
- if ( d === date)
- return i;
+ currDiff = Math.abs(d.getTime() - date.getTime());
+ if (currDiff < bestDiff) {
+ bestDiff = currDiff;
+ retval = i;
+ }
+ if (currDiff > bestDiff)
+ return retval;
}
+
return -1;
}
@@ -76,11 +83,9 @@ ListModel {
if (stockId === "")
return;
- if (startDate === undefined)
- startDate = new Date(1995, 3, 25); //default: 25 April 1995
+ var startDate = new Date(2011, 4, 25);
- if (endDate === undefined)
- endDate = new Date(); //today
+ var endDate = new Date(); //today
if (stockDataCycle !== "d" && stockDataCycle !== "w" && stockDataCycle !== "m")
stockDataCycle = "d";
@@ -94,11 +99,11 @@ ListModel {
*/
var request = "http://ichart.finance.yahoo.com/table.csv?";
request += "s=" + stockId;
- request += "&a=" + startDate.getDate();
- request += "&b=" + startDate.getMonth();
+ request += "&a=" + startDate.getMonth();
+ request += "&b=" + startDate.getDate();
request += "&c=" + startDate.getFullYear();
- request += "&d=" + endDate.getDate();
- request += "&e=" + endDate.getMonth();
+ request += "&d=" + endDate.getMonth();
+ request += "&e=" + endDate.getDate();
request += "&f=" + endDate.getFullYear();
request += "&g=" + stockDataCycle;
request += "&ignore=.csv";
@@ -133,6 +138,10 @@ ListModel {
model.ready = false;
model.clear();
+
+ highestPrice = 0;
+ highestVolume = 0;
+
var i = 1; //skip the first line
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.LOADING || xhr.readyState === XMLHttpRequest.DONE) {
diff --git a/examples/quick/demos/stocqt/content/StockSettings.qml b/examples/quick/demos/stocqt/content/StockSettings.qml
deleted file mode 100644
index 07152410fa..0000000000
--- a/examples/quick/demos/stocqt/content/StockSettings.qml
+++ /dev/null
@@ -1,216 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 320
- height: 480
- color: "#423A2F"
- property var startDate : startDatePicker.date
- property var endDate : endDatePicker.date
-
- property bool drawHighPrice: highButton.buttonEnabled
- property bool drawLowPrice: lowButton.buttonEnabled
- property bool drawOpenPrice: openButton.buttonEnabled
- property bool drawClosePrice: closeButton.buttonEnabled
- property bool drawVolume: volumeButton.buttonEnabled
- property bool drawKLine: klineButton.buttonEnabled
-
- property color highColor: Qt.rgba(1, 0, 0, 1)
- property color lowColor: Qt.rgba(0, 1, 0, 1)
- property color openColor: Qt.rgba(0, 0, 1, 1)
- property color volumeColor: Qt.rgba(0.3, 0.5, 0.7, 1)
- property color closeColor: "#ecc088"
-
- property string chartType: "year"
-
- Image {
- id: logo
- source: "images/logo.png"
- anchors.horizontalCenter : parent.horizontalCenter
- anchors.top: parent.top
- anchors.topMargin: 15
- }
-
- Text {
- id: startDateText
- text: "START DATE:"
- color: "#76644A"
- font.pointSize: 15
- anchors.left: parent.left
- anchors.leftMargin: 20
- anchors.top: logo.bottom
- anchors.topMargin: 20
- }
-
- DatePicker {
- id: startDatePicker
- anchors.left: parent.left
- anchors.leftMargin: 30
- anchors.top: startDateText.bottom
- anchors.topMargin: 8
- }
-
- Text {
- id: endDateText
- text: "END DATE:"
- color: "#76644A"
- font.pointSize: 15
- anchors.left: parent.left
- anchors.leftMargin: 20
- anchors.top: startDatePicker.bottom
- anchors.topMargin: 20
- }
-
- DatePicker {
- id: endDatePicker
- anchors.left: parent.left
- anchors.leftMargin: 30
- anchors.top: endDateText.bottom
- anchors.topMargin: 8
- }
-
- Text {
- id: drawOptionsText
- text: "DRAW OPTIONS:"
- color: "#76644A"
- font.pointSize: 15
- anchors.left: parent.left
- anchors.leftMargin: 20
- anchors.top: endDatePicker.bottom
- anchors.topMargin: 20
- }
- Column {
- id: drawOptions
- anchors.top: drawOptionsText.bottom
- anchors.topMargin: 8
- anchors.left: parent.left
- anchors.leftMargin: 30
- spacing: 2
-
- Row {
- spacing: 10
-
- CheckBox {
- id: highButton
- text: "High"
- buttonEnabled: false
- }
- CheckBox {
- id: lowButton
- text: "Low"
- buttonEnabled: false
- }
- }
- Row {
- spacing: 10
- CheckBox {
- id: openButton
- text: "Open"
- buttonEnabled: false
- }
- CheckBox {
- text: "Close"
- id: closeButton
- buttonEnabled: true
- }
-
- }
- Row {
- spacing: 10
- CheckBox {
- id: volumeButton
- text: "Volume"
- buttonEnabled: true
- }
- CheckBox {
- id: klineButton
- text: "K Line"
- buttonEnabled: false
- }
- }
- }
-
- Text {
- id: chartTypeText
- text: "SHOW PREVIOUS:"
- color: "#76644A"
- font.pointSize: 15
- anchors.left: parent.left
- anchors.leftMargin: 20
- anchors.top: drawOptions.bottom
- anchors.topMargin: 20
- }
- Row {
- anchors.left: parent.left
- anchors.leftMargin: 20
- anchors.top: chartTypeText.bottom
- anchors.topMargin: 8
- spacing: -1
- Button {
- id: yearView
- text: "YEAR"
- buttonEnabled: root.chartType == "year"
- onClicked: root.chartType = "year"
- }
- Button {
- id: monthView
- text: "MONTH"
- buttonEnabled: root.chartType == "month"
- onClicked: root.chartType = "month"
- }
- Button {
- id: weekView
- text: "WEEK"
- buttonEnabled: root.chartType == "week"
- onClicked: root.chartType = "week"
- }
- Button {
- id: allView
- text: "ALL"
- buttonEnabled: root.chartType == "all"
- onClicked: root.chartType = "all"
- }
- }
-
- Component.onCompleted: startDatePicker.date = new Date(1995, 3, 25)
-}
diff --git a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
new file mode 100644
index 0000000000..055d15e1b1
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 440
+ height: 160
+ color: "transparent"
+
+ property bool drawOpenPrice: openButton.buttonEnabled
+ property bool drawClosePrice: closeButton.buttonEnabled
+ property bool drawHighPrice: highButton.buttonEnabled
+ property bool drawLowPrice: lowButton.buttonEnabled
+
+ property string openColor: "#face20"
+ property string closeColor: "#14aaff"
+ property string highColor: "#80c342"
+ property string lowColor: "#f30000"
+ property string volumeColor: "#14aaff"
+
+ Text {
+ id: openText
+ anchors.left: root.left
+ anchors.top: root.top
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 19
+ text: "Open"
+ }
+
+ Text {
+ id: closeText
+ anchors.left: root.left
+ anchors.top: openText.bottom
+ anchors.topMargin: 10
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 19
+ text: "Close"
+ }
+
+ Text {
+ id: highText
+ anchors.left: root.left
+ anchors.top: closeText.bottom
+ anchors.topMargin: 10
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 19
+ text: "High"
+ }
+
+ Text {
+ id: lowText
+ anchors.left: root.left
+ anchors.top: highText.bottom
+ anchors.topMargin: 10
+ color: "#000000"
+ font.family: "Open Sans"
+ font.pointSize: 19
+ text: "Low"
+ }
+
+ Rectangle {
+ height: 4
+ anchors.left: root.left
+ anchors.leftMargin: 114
+ anchors.right: openButton.left
+ anchors.rightMargin: 65
+ anchors.verticalCenter: openText.verticalCenter
+ color: openColor
+ }
+
+ Rectangle {
+ height: 4
+ anchors.left: root.left
+ anchors.leftMargin: 114
+ anchors.right: closeButton.left
+ anchors.rightMargin: 65
+ anchors.verticalCenter: closeText.verticalCenter
+ color: closeColor
+ }
+
+ Rectangle {
+ height: 4
+ anchors.left: root.left
+ anchors.leftMargin: 114
+ anchors.right: highButton.left
+ anchors.rightMargin: 65
+ anchors.verticalCenter: highText.verticalCenter
+ color: highColor
+ }
+
+ Rectangle {
+ height: 4
+ anchors.left: root.left
+ anchors.leftMargin: 114
+ anchors.right: lowButton.left
+ anchors.rightMargin: 65
+ anchors.verticalCenter: lowText.verticalCenter
+ color: lowColor
+ }
+
+ CheckBox {
+ id: openButton
+ buttonEnabled: false
+ anchors.verticalCenter: openText.verticalCenter
+ anchors.right: root.right
+ anchors.rightMargin: 40
+ }
+
+ CheckBox {
+ id: closeButton
+ buttonEnabled: false
+ anchors.verticalCenter: closeText.verticalCenter
+ anchors.right: root.right
+ anchors.rightMargin: 40
+ }
+
+ CheckBox {
+ id: highButton
+ buttonEnabled: true
+ anchors.verticalCenter: highText.verticalCenter
+ anchors.right: root.right
+ anchors.rightMargin: 40
+ }
+
+ CheckBox {
+ id: lowButton
+ buttonEnabled: true
+ anchors.verticalCenter: lowText.verticalCenter
+ anchors.right: root.right
+ anchors.rightMargin: 40
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/StockView.qml b/examples/quick/demos/stocqt/content/StockView.qml
index ce55fdf3d3..e503cbea04 100644
--- a/examples/quick/demos/stocqt/content/StockView.qml
+++ b/examples/quick/demos/stocqt/content/StockView.qml
@@ -39,95 +39,63 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.Window 2.1
Rectangle {
id: root
width: 320
height: 480
- color: "#423A2F"
+ color: "transparent"
property var stock: null
property var stocklist: null
- property var settings: null
- signal listViewClicked
signal settingsClicked
function update() {
- if (!settings)
- return;
- chart.endDate = settings.endDate
chart.update()
}
Rectangle {
- color: "#272822"
+ id: mainRect
+ color: "transparent"
anchors.fill: parent
- radius: 20
- Image {
- source: "images/icon-items.png"
+ StockInfo {
+ id: stockInfo
anchors.left: parent.left
anchors.leftMargin: 10
anchors.top: parent.top
- anchors.topMargin: 10
- MouseArea {
- anchors.fill: parent
- onClicked: listViewClicked()
- }
- }
- Image {
- source: "images/icon-settings.png"
- anchors.right: parent.right
- anchors.rightMargin: 10
- anchors.top: parent.top
- anchors.topMargin: 10
- MouseArea {
- anchors.fill: parent
- onClicked: settingsClicked()
- }
- }
-
- Text {
- id: desc
- anchors.left: parent.left
- anchors.leftMargin: 20
- anchors.top: parent.top
- anchors.topMargin: 40
- color: "#564c3A"
- font.pointSize: 15
- text: root.stock.stockId + " - " + root.stock.stockName
+ anchors.topMargin: 15
+ height: 160
+ anchors.right: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.right : chart.left
+ anchors.rightMargin: 20
+ stock: root.stock
}
- Text {
- id: price
- anchors.left: parent.left
- anchors.leftMargin: 20
- anchors.top: desc.bottom
- anchors.topMargin: 5
- color: "#ECC089"
- font.pointSize: 30
- text: root.stock.stockPrice
+ StockChart {
+ id: chart
+ anchors.bottom: Screen.primaryOrientation === Qt.PortraitOrientation ? settingsPanel.top : parent.bottom
+ anchors.bottomMargin: 20
+ anchors.top : Screen.primaryOrientation === Qt.PortraitOrientation ? stockInfo.bottom : parent.top
+ anchors.topMargin: 20
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ width: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.width - 40 : 0.6 * parent.width
+ stockModel: root.stock
+ settings: settingsPanel
}
- Text {
- id: priceChange
+ StockSettingsPanel {
+ id: settingsPanel
anchors.left: parent.left
anchors.leftMargin: 20
- anchors.top: price.bottom
- anchors.topMargin: 5
- color: root.stock.stockPriceChanged < 0 ? "#A43D3D" : "#679B3A"
- font.pointSize: 25
- text: root.stock.stockPriceChanged + " (" + Math.abs(Math.round(root.stock.stockPriceChanged/(root.stock.stockPrice - root.stock.stockPriceChanged) * 100))/100 +"%)"
- }
-
- StockChart {
- id: chart
+ anchors.right: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.right : chart.left
+ anchors.rightMargin: 20
anchors.bottom: parent.bottom
- anchors.top : priceChange.bottom
- anchors.topMargin: 30
- width: parent.width
- stockModel: root.stock
- settings: root.settings
+ onDrawOpenPriceChanged: root.update()
+ onDrawClosePriceChanged: root.update();
+ onDrawHighPriceChanged: root.update();
+ onDrawLowPriceChanged: root.update();
}
}
}
diff --git a/examples/quick/demos/stocqt/content/images/icon-calendar-anim.png b/examples/quick/demos/stocqt/content/images/icon-calendar-anim.png
deleted file mode 100644
index c5164d5183..0000000000
--- a/examples/quick/demos/stocqt/content/images/icon-calendar-anim.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-calendar.png b/examples/quick/demos/stocqt/content/images/icon-calendar.png
deleted file mode 100644
index bd2857470b..0000000000
--- a/examples/quick/demos/stocqt/content/images/icon-calendar.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-items.png b/examples/quick/demos/stocqt/content/images/icon-items.png
deleted file mode 100644
index f951aa5009..0000000000
--- a/examples/quick/demos/stocqt/content/images/icon-items.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-left-arrow.png b/examples/quick/demos/stocqt/content/images/icon-left-arrow.png
new file mode 100644
index 0000000000..7868e8ab31
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/icon-left-arrow.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-settings.png b/examples/quick/demos/stocqt/content/images/icon-settings.png
deleted file mode 100644
index 222d998289..0000000000
--- a/examples/quick/demos/stocqt/content/images/icon-settings.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/logo.png b/examples/quick/demos/stocqt/content/images/logo.png
deleted file mode 100644
index 90c7c3ba3d..0000000000
--- a/examples/quick/demos/stocqt/content/images/logo.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png b/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png
index 1783881e1f..550c2a8a22 100644
--- a/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png
+++ b/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/stocqt.pro b/examples/quick/demos/stocqt/stocqt.pro
index efe37cb722..0e89a30050 100644
--- a/examples/quick/demos/stocqt/stocqt.pro
+++ b/examples/quick/demos/stocqt/stocqt.pro
@@ -3,6 +3,7 @@ TEMPLATE = app
QT += qml quick
SOURCES += main.cpp
RESOURCES += stocqt.qrc
+OTHER_FILES += *.qml content/*.qml content/images/*.png
target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/stocqt
INSTALLS += target
diff --git a/examples/quick/demos/stocqt/stocqt.qml b/examples/quick/demos/stocqt/stocqt.qml
index 3e231ab8bf..d4a188d0d2 100644
--- a/examples/quick/demos/stocqt/stocqt.qml
+++ b/examples/quick/demos/stocqt/stocqt.qml
@@ -42,67 +42,103 @@ import QtQuick 2.0
import QtQml.Models 2.1
import "./content"
-ListView {
- id: root
- width: 320
- height: 480
- snapMode: ListView.SnapOneItem
- focus: false
- orientation: ListView.Horizontal
- boundsBehavior: Flickable.StopAtBounds
- currentIndex: 1
+Rectangle {
+ id: mainRect
+ width: 1000
+ height: 700
- Timer {
- id: updateTimer
- interval: 500
- onTriggered: stock.updateStock()
- }
+ property int listViewActive: 0
+
+ Rectangle {
+ id: banner
+ height: 80
+ anchors.top: parent.top
+ width: parent.width
+ color: "#000000"
- StockModel {
- id: stock
- stockId: listView.currentStockId
- stockName: listView.currentStockName
- startDate: settings.startDate
- endDate: settings.endDate
- onStockIdChanged: updateTimer.restart()
- onStartDateChanged: updateTimer.restart()
- onEndDateChanged: updateTimer.restart()
- onDataReady: {
- root.positionViewAtIndex(1, ListView.SnapPosition)
- stockView.update()
+ Image {
+ id: arrow
+ source: "./content/images/icon-left-arrow.png"
+ anchors.left: banner.left
+ anchors.leftMargin: 20
+ anchors.verticalCenter: banner.verticalCenter
+ visible: root.currentIndex == 1 ? true : false
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: listViewActive = 1;
+ }
}
- }
- model: ObjectModel {
- StockListView {
- id: listView
- width: root.width
- height: root.height
+ Item {
+ id: textItem
+ width: stocText.width + qtText.width
+ height: stocText.height + qtText.height
+ anchors.horizontalCenter: banner.horizontalCenter
+ anchors.verticalCenter: banner.verticalCenter
+
+ Text {
+ id: stocText
+ anchors.verticalCenter: textItem.verticalCenter
+ color: "#ffffff"
+ font.family: "Abel"
+ font.pointSize: 40
+ text: "Stoc"
+ }
+ Text {
+ id: qtText
+ anchors.verticalCenter: textItem.verticalCenter
+ anchors.left: stocText.right
+ color: "#5caa15"
+ font.family: "Abel"
+ font.pointSize: 40
+ text: "Qt"
+ }
}
+ }
- StockView {
- id: stockView
- width: root.width
- height: root.height
- stocklist: listView
- settings: settings
- stock: stock
+ ListView {
+ id: root
+ width: parent.width
+ anchors.top: banner.bottom
+ anchors.bottom: parent.bottom
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ highlightMoveDuration: 250
+ focus: false
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ currentIndex: listViewActive == 0 ? 1 : 0
+ onCurrentIndexChanged: {
+ if (currentIndex == 1)
+ listViewActive = 0;
+ }
- onListViewClicked: root.currentIndex = 0
- onSettingsClicked: root.currentIndex = 2
+ StockModel {
+ id: stock
+ stockId: listView.currentStockId
+ stockName: listView.currentStockName
+ onStockIdChanged: stock.updateStock();
+ onDataReady: {
+ root.positionViewAtIndex(1, ListView.SnapPosition)
+ stockView.update()
+ }
}
- StockSettings {
- id: settings
- width: root.width
- height: root.height
- onDrawHighPriceChanged: stockView.update()
- onDrawLowPriceChanged: stockView.update()
- onDrawOpenPriceChanged: stockView.update()
- onDrawClosePriceChanged: stockView.update()
- onDrawVolumeChanged: stockView.update()
- onDrawKLineChanged: stockView.update()
- onChartTypeChanged: stockView.update()
+ model: ObjectModel {
+ StockListView {
+ id: listView
+ width: root.width
+ height: root.height
+ }
+
+ StockView {
+ id: stockView
+ width: root.width
+ height: root.height
+ stocklist: listView
+ stock: stock
+ }
}
}
}
diff --git a/examples/quick/demos/stocqt/stocqt.qrc b/examples/quick/demos/stocqt/stocqt.qrc
index 8885aaa807..ee5dd0c24f 100644
--- a/examples/quick/demos/stocqt/stocqt.qrc
+++ b/examples/quick/demos/stocqt/stocqt.qrc
@@ -3,19 +3,15 @@
<file>stocqt.qml</file>
<file>content/Button.qml</file>
<file>content/CheckBox.qml</file>
- <file>content/DatePicker.qml</file>
<file>content/StockChart.qml</file>
<file>content/StockListModel.qml</file>
<file>content/StockListView.qml</file>
<file>content/StockModel.qml</file>
- <file>content/StockSettings.qml</file>
<file>content/StockView.qml</file>
- <file>content/images/icon-calendar-anim.png</file>
- <file>content/images/icon-calendar.png</file>
- <file>content/images/icon-items.png</file>
- <file>content/images/icon-settings.png</file>
- <file>content/images/logo.png</file>
<file>content/images/wheel-touch.png</file>
<file>content/images/wheel.png</file>
+ <file>content/images/icon-left-arrow.png</file>
+ <file>content/StockSettingsPanel.qml</file>
+ <file>content/StockInfo.qml</file>
</qresource>
</RCC>
diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes
index cadef10370..dd41871e45 100644
--- a/src/imports/qtquick2/plugins.qmltypes
+++ b/src/imports/qtquick2/plugins.qmltypes
@@ -176,6 +176,7 @@ Module {
name: "QInputMethod"
prototype: "QObject"
exports: ["QtQuick/InputMethod 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Enum {
name: "Action"
@@ -225,6 +226,7 @@ Module {
Component {
name: "QKeySequence"
exports: ["QtQuick/StandardKey 2.2"]
+ isCreatable: false
exportMetaObjectRevisions: [2]
Enum {
name: "StandardKey"
@@ -514,6 +516,7 @@ Module {
name: "QQmlEasingValueType"
prototype: "QQmlValueType"
exports: ["QtQuick/Easing 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Enum {
name: "Type"
@@ -677,6 +680,7 @@ Module {
Component {
name: "QQmlLocale"
exports: ["QtQml/Locale 2.2", "QtQuick/Locale 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0, 0]
Enum {
name: "MeasurementSystem"
@@ -750,6 +754,7 @@ Module {
name: "QQuickAbstractAnimation"
prototype: "QObject"
exports: ["QtQuick/Animation 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Enum {
name: "Loops"
@@ -790,10 +795,81 @@ Module {
name: "QQuickAccessibleAttached"
prototype: "QObject"
exports: ["QtQuick/Accessible 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Property { name: "role"; type: "QAccessible::Role" }
Property { name: "name"; type: "string" }
Property { name: "description"; type: "string" }
+ Property { name: "checkable"; type: "bool" }
+ Property { name: "checked"; type: "bool" }
+ Property { name: "editable"; type: "bool" }
+ Property { name: "focusable"; type: "bool" }
+ Property { name: "focused"; type: "bool" }
+ Property { name: "multiLine"; type: "bool" }
+ Property { name: "readOnly"; type: "bool" }
+ Property { name: "selected"; type: "bool" }
+ Property { name: "selectable"; type: "bool" }
+ Property { name: "pressed"; type: "bool" }
+ Property { name: "checkStateMixed"; type: "bool" }
+ Property { name: "defaultButton"; type: "bool" }
+ Property { name: "passwordEdit"; type: "bool" }
+ Property { name: "selectableText"; type: "bool" }
+ Signal {
+ name: "checkableChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "checkedChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "editableChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "focusableChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "focusedChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "multiLineChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "readOnlyChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "selectedChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "selectableChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "pressedChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "checkStateMixedChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "defaultButtonChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "passwordEditChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "selectableTextChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
Method { name: "valueChanged" }
Method { name: "cursorPositionChanged" }
}
@@ -1051,6 +1127,7 @@ Module {
name: "QQuickAnimator"
prototype: "QQuickAbstractAnimation"
exports: ["QtQuick/Animator 2.2"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Property { name: "target"; type: "QQuickItem"; isPointer: true }
Property { name: "easing"; type: "QEasingCurve" }
@@ -1082,6 +1159,7 @@ Module {
name: "QQuickApplication"
prototype: "QQmlApplication"
exports: ["QtQuick/Application 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Property { name: "active"; type: "bool"; isReadonly: true }
Property { name: "layoutDirection"; type: "Qt::LayoutDirection"; isReadonly: true }
@@ -1097,6 +1175,7 @@ Module {
defaultProperty: "data"
prototype: "QQuickImplicitSizeItem"
exports: ["QtQuick/Positioner 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
attachedType: "QQuickPositionerAttached"
Property { name: "spacing"; type: "double" }
@@ -1221,6 +1300,11 @@ Module {
Method { name: "toDataURL"; type: "string" }
}
Component {
+ name: "QQuickCloseEvent"
+ prototype: "QObject"
+ Property { name: "accepted"; type: "bool" }
+ }
+ Component {
name: "QQuickColorAnimation"
prototype: "QQuickPropertyAnimation"
exports: ["QtQuick/ColorAnimation 2.0"]
@@ -1255,6 +1339,7 @@ Module {
name: "QQuickDrag"
prototype: "QObject"
exports: ["QtQuick/Drag 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
attachedType: "QQuickDragAttached"
Enum {
@@ -1345,6 +1430,39 @@ Module {
Signal { name: "positionChanged" }
}
Component {
+ name: "QQuickDropEvent"
+ prototype: "QObject"
+ Property { name: "x"; type: "double"; isReadonly: true }
+ Property { name: "y"; type: "double"; isReadonly: true }
+ Property { name: "source"; type: "QObject"; isReadonly: true; isPointer: true }
+ Property { name: "keys"; type: "QStringList"; isReadonly: true }
+ Property { name: "supportedActions"; type: "Qt::DropActions"; isReadonly: true }
+ Property { name: "proposedAction"; type: "Qt::DropActions"; isReadonly: true }
+ Property { name: "action"; type: "Qt::DropAction" }
+ Property { name: "accepted"; type: "bool" }
+ Property { name: "hasColor"; type: "bool"; isReadonly: true }
+ Property { name: "hasHtml"; type: "bool"; isReadonly: true }
+ Property { name: "hasText"; type: "bool"; isReadonly: true }
+ Property { name: "hasUrls"; type: "bool"; isReadonly: true }
+ Property { name: "colorData"; type: "QVariant"; isReadonly: true }
+ Property { name: "html"; type: "string"; isReadonly: true }
+ Property { name: "text"; type: "string"; isReadonly: true }
+ Property { name: "urls"; type: "QList<QUrl>"; isReadonly: true }
+ Property { name: "formats"; type: "QStringList"; isReadonly: true }
+ Method {
+ name: "getDataAsString"
+ Parameter { type: "QQmlV4Function"; isPointer: true }
+ }
+ Method {
+ name: "acceptProposedAction"
+ Parameter { type: "QQmlV4Function"; isPointer: true }
+ }
+ Method {
+ name: "accept"
+ Parameter { type: "QQmlV4Function"; isPointer: true }
+ }
+ }
+ Component {
name: "QQuickFlickable"
defaultProperty: "flickableData"
prototype: "QQuickItem"
@@ -1517,6 +1635,7 @@ Module {
name: "QQuickFontValueType"
prototype: "QQmlValueType"
exports: ["QtQuick/Font 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Enum {
name: "FontWeight"
@@ -1552,6 +1671,13 @@ Module {
Property { name: "wordSpacing"; type: "double" }
}
Component {
+ name: "QQuickGrabGestureEvent"
+ prototype: "QObject"
+ Property { name: "touchPoints"; type: "QObject"; isList: true; isReadonly: true }
+ Property { name: "dragThreshold"; type: "double"; isReadonly: true }
+ Method { name: "grab" }
+ }
+ Component {
name: "QQuickGradient"
defaultProperty: "stops"
prototype: "QObject"
@@ -1667,17 +1793,13 @@ Module {
Method { name: "moveCurrentIndexLeft" }
Method { name: "moveCurrentIndexRight" }
}
- Component {
- name: "QQuickGridViewAttached"
- prototype: "QQuickItemViewAttached"
- Property { name: "view"; type: "QQuickGridView"; isReadonly: true; isPointer: true }
- }
+ Component { name: "QQuickGridViewAttached"; prototype: "QQuickItemViewAttached" }
Component {
name: "QQuickImage"
defaultProperty: "data"
prototype: "QQuickImageBase"
- exports: ["QtQuick/Image 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/Image 2.0", "QtQuick/Image 2.3"]
+ exportMetaObjectRevisions: [0, 1]
Enum {
name: "HAlignment"
values: {
@@ -1711,6 +1833,7 @@ Module {
Property { name: "paintedHeight"; type: "double"; isReadonly: true }
Property { name: "horizontalAlignment"; type: "HAlignment" }
Property { name: "verticalAlignment"; type: "VAlignment" }
+ Property { name: "mipmap"; revision: 1; type: "bool" }
Signal { name: "paintedGeometryChanged" }
Signal {
name: "horizontalAlignmentChanged"
@@ -1720,6 +1843,11 @@ Module {
name: "verticalAlignmentChanged"
Parameter { name: "alignment"; type: "VAlignment" }
}
+ Signal {
+ name: "mipmapChanged"
+ revision: 1
+ Parameter { type: "bool" }
+ }
}
Component {
name: "QQuickImageBase"
@@ -1967,8 +2095,9 @@ Module {
name: "QQuickItemView"
defaultProperty: "flickableData"
prototype: "QQuickFlickable"
- exports: ["QtQuick/ItemView 2.1"]
- exportMetaObjectRevisions: [1]
+ exports: ["QtQuick/ItemView 2.1", "QtQuick/ItemView 2.3"]
+ isCreatable: false
+ exportMetaObjectRevisions: [1, 2]
Enum {
name: "LayoutDirection"
values: {
@@ -2011,6 +2140,8 @@ Module {
Property { name: "currentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "keyNavigationWraps"; type: "bool" }
Property { name: "cacheBuffer"; type: "int" }
+ Property { name: "displayMarginBeginning"; revision: 2; type: "int" }
+ Property { name: "displayMarginEnd"; revision: 2; type: "int" }
Property { name: "layoutDirection"; type: "Qt::LayoutDirection" }
Property { name: "effectiveLayoutDirection"; type: "Qt::LayoutDirection"; isReadonly: true }
Property { name: "verticalLayoutDirection"; type: "VerticalLayoutDirection" }
@@ -2065,6 +2196,7 @@ Module {
Component {
name: "QQuickItemViewAttached"
prototype: "QObject"
+ Property { name: "view"; type: "QQuickItemView"; isReadonly: true; isPointer: true }
Property { name: "isCurrentItem"; type: "bool"; isReadonly: true }
Property { name: "delayRemove"; type: "bool" }
Property { name: "section"; type: "string"; isReadonly: true }
@@ -2076,9 +2208,27 @@ Module {
Signal { name: "prevSectionChanged" }
}
Component {
+ name: "QQuickKeyEvent"
+ prototype: "QObject"
+ Property { name: "key"; type: "int"; isReadonly: true }
+ Property { name: "text"; type: "string"; isReadonly: true }
+ Property { name: "modifiers"; type: "int"; isReadonly: true }
+ Property { name: "isAutoRepeat"; type: "bool"; isReadonly: true }
+ Property { name: "count"; type: "int"; isReadonly: true }
+ Property { name: "nativeScanCode"; type: "uint"; isReadonly: true }
+ Property { name: "accepted"; type: "bool" }
+ Method {
+ name: "matches"
+ revision: 2
+ type: "bool"
+ Parameter { name: "key"; type: "QKeySequence::StandardKey" }
+ }
+ }
+ Component {
name: "QQuickKeyNavigationAttached"
prototype: "QObject"
exports: ["QtQuick/KeyNavigation 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Enum {
name: "Priority"
@@ -2099,6 +2249,7 @@ Module {
name: "QQuickKeysAttached"
prototype: "QObject"
exports: ["QtQuick/Keys 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Enum {
name: "Priority"
@@ -2275,6 +2426,7 @@ Module {
name: "QQuickLayoutMirroringAttached"
prototype: "QObject"
exports: ["QtQuick/LayoutMirroring 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Property { name: "enabled"; type: "bool" }
Property { name: "childrenInherit"; type: "bool" }
@@ -2312,11 +2464,7 @@ Module {
Method { name: "incrementCurrentIndex" }
Method { name: "decrementCurrentIndex" }
}
- Component {
- name: "QQuickListViewAttached"
- prototype: "QQuickItemViewAttached"
- Property { name: "view"; type: "QQuickListView"; isReadonly: true; isPointer: true }
- }
+ Component { name: "QQuickListViewAttached"; prototype: "QQuickItemViewAttached" }
Component {
name: "QQuickLoader"
defaultProperty: "data"
@@ -2346,6 +2494,13 @@ Module {
}
}
Component {
+ name: "QQuickMatrix4x4"
+ prototype: "QQuickTransform"
+ exports: ["QtQuick/Matrix4x4 2.3"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "matrix"; type: "QMatrix4x4" }
+ }
+ Component {
name: "QQuickMouseArea"
defaultProperty: "data"
prototype: "QQuickItem"
@@ -2425,6 +2580,7 @@ Module {
Property { name: "touchPoints"; type: "QQuickTouchPoint"; isList: true; isReadonly: true }
Property { name: "minimumTouchPoints"; type: "int" }
Property { name: "maximumTouchPoints"; type: "int" }
+ Property { name: "mouseEnabled"; type: "bool" }
Signal {
name: "pressed"
Parameter { name: "touchPoints"; type: "QList<QObject*>" }
@@ -2483,6 +2639,7 @@ Module {
defaultProperty: "data"
prototype: "QQuickItem"
exports: ["QtQuick/PaintedItem 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Enum {
name: "RenderTarget"
@@ -2844,6 +3001,24 @@ Module {
}
}
Component {
+ name: "QQuickPinchEvent"
+ prototype: "QObject"
+ Property { name: "center"; type: "QPointF"; isReadonly: true }
+ Property { name: "startCenter"; type: "QPointF"; isReadonly: true }
+ Property { name: "previousCenter"; type: "QPointF"; isReadonly: true }
+ Property { name: "scale"; type: "double"; isReadonly: true }
+ Property { name: "previousScale"; type: "double"; isReadonly: true }
+ Property { name: "angle"; type: "double"; isReadonly: true }
+ Property { name: "previousAngle"; type: "double"; isReadonly: true }
+ Property { name: "rotation"; type: "double"; isReadonly: true }
+ Property { name: "point1"; type: "QPointF"; isReadonly: true }
+ Property { name: "startPoint1"; type: "QPointF"; isReadonly: true }
+ Property { name: "point2"; type: "QPointF"; isReadonly: true }
+ Property { name: "startPoint2"; type: "QPointF"; isReadonly: true }
+ Property { name: "pointCount"; type: "int"; isReadonly: true }
+ Property { name: "accepted"; type: "bool" }
+ }
+ Component {
name: "QQuickPositionerAttached"
prototype: "QObject"
Property { name: "index"; type: "int"; isReadonly: true }
@@ -3081,6 +3256,7 @@ Module {
name: "QQuickShaderEffectMesh"
prototype: "QObject"
exports: ["QtQuick/ShaderEffectMesh 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Signal { name: "geometryChanged" }
}
@@ -3430,8 +3606,8 @@ Module {
name: "QQuickText"
defaultProperty: "data"
prototype: "QQuickImplicitSizeItem"
- exports: ["QtQuick/Text 2.0", "QtQuick/Text 2.2"]
- exportMetaObjectRevisions: [0, 2]
+ exports: ["QtQuick/Text 2.0", "QtQuick/Text 2.2", "QtQuick/Text 2.3"]
+ exportMetaObjectRevisions: [0, 2, 3]
Enum {
name: "HAlignment"
values: {
@@ -3587,6 +3763,13 @@ Module {
Parameter { name: "line"; type: "QQuickTextLine"; isPointer: true }
}
Method { name: "doLayout" }
+ Method {
+ name: "linkAt"
+ revision: 3
+ type: "string"
+ Parameter { name: "x"; type: "double" }
+ Parameter { name: "y"; type: "double" }
+ }
}
Component { name: "QQuickTextDocument"; prototype: "QObject" }
Component {
@@ -3596,9 +3779,10 @@ Module {
exports: [
"QtQuick/TextEdit 2.0",
"QtQuick/TextEdit 2.1",
- "QtQuick/TextEdit 2.2"
+ "QtQuick/TextEdit 2.2",
+ "QtQuick/TextEdit 2.3"
]
- exportMetaObjectRevisions: [0, 1, 2]
+ exportMetaObjectRevisions: [0, 1, 2, 3]
Enum {
name: "HAlignment"
values: {
@@ -3830,13 +4014,20 @@ Module {
Parameter { name: "start"; type: "int" }
Parameter { name: "end"; type: "int" }
}
+ Method {
+ name: "linkAt"
+ revision: 3
+ type: "string"
+ Parameter { name: "x"; type: "double" }
+ Parameter { name: "y"; type: "double" }
+ }
}
Component {
name: "QQuickTextInput"
defaultProperty: "data"
prototype: "QQuickImplicitSizeItem"
- exports: ["QtQuick/TextInput 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/TextInput 2.0", "QtQuick/TextInput 2.2"]
+ exportMetaObjectRevisions: [0, 2]
Enum {
name: "EchoMode"
values: {
@@ -3932,6 +4123,7 @@ Module {
Property { name: "contentHeight"; type: "double"; isReadonly: true }
Property { name: "renderType"; type: "RenderType" }
Signal { name: "accepted" }
+ Signal { name: "editingFinished"; revision: 2 }
Signal {
name: "fontChanged"
Parameter { name: "font"; type: "QFont" }
@@ -4036,6 +4228,15 @@ Module {
}
}
Component {
+ name: "QQuickTextLine"
+ prototype: "QObject"
+ Property { name: "number"; type: "int"; isReadonly: true }
+ Property { name: "width"; type: "double" }
+ Property { name: "height"; type: "double" }
+ Property { name: "x"; type: "double" }
+ Property { name: "y"; type: "double" }
+ }
+ Component {
name: "QQuickTouchPoint"
prototype: "QObject"
exports: ["QtQuick/TouchPoint 2.0"]
@@ -4125,6 +4326,7 @@ Module {
name: "QQuickViewTransitionAttached"
prototype: "QObject"
exports: ["QtQuick/ViewTransition 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
Property { name: "index"; type: "int"; isReadonly: true }
Property { name: "item"; type: "QQuickItem"; isReadonly: true; isPointer: true }
@@ -4133,6 +4335,17 @@ Module {
Property { name: "targetItems"; type: "QObject"; isList: true; isReadonly: true }
}
Component {
+ name: "QQuickWheelEvent"
+ prototype: "QObject"
+ Property { name: "x"; type: "double"; isReadonly: true }
+ Property { name: "y"; type: "double"; isReadonly: true }
+ Property { name: "angleDelta"; type: "QPoint"; isReadonly: true }
+ Property { name: "pixelDelta"; type: "QPoint"; isReadonly: true }
+ Property { name: "buttons"; type: "int"; isReadonly: true }
+ Property { name: "modifiers"; type: "int"; isReadonly: true }
+ Property { name: "accepted"; type: "bool" }
+ }
+ Component {
name: "QQuickWorkerScript"
prototype: "QObject"
exports: ["QtQuick/WorkerScript 2.0"]
@@ -4585,7 +4798,10 @@ Module {
"AA_SynthesizeTouchForUnhandledMouseEvents": 11,
"AA_SynthesizeMouseForUnhandledTouchEvents": 12,
"AA_UseHighDpiPixmaps": 13,
- "AA_AttributeCount": 14
+ "AA_ForceRasterWidgets": 14,
+ "AA_UseDesktopOpenGL": 15,
+ "AA_UseOpenGLES": 16,
+ "AA_AttributeCount": 17
}
}
Enum {
@@ -5027,6 +5243,9 @@ Module {
"Key_Blue": 16777495,
"Key_ChannelUp": 16777496,
"Key_ChannelDown": 16777497,
+ "Key_Guide": 16777498,
+ "Key_Info": 16777499,
+ "Key_Settings": 16777500,
"Key_MediaLast": 16842751,
"Key_Select": 16842752,
"Key_Yes": 16842753,
@@ -5037,6 +5256,7 @@ Module {
"Key_Sleep": 16908292,
"Key_Play": 16908293,
"Key_Zoom": 16908294,
+ "Key_Exit": 16908298,
"Key_Context1": 17825792,
"Key_Context2": 17825793,
"Key_Context3": 17825794,
@@ -5288,6 +5508,15 @@ Module {
}
}
Enum {
+ name: "Edges"
+ values: {
+ "TopEdge": 1,
+ "LeftEdge": 2,
+ "RightEdge": 4,
+ "BottomEdge": 8
+ }
+ }
+ Enum {
name: "ConnectionType"
values: {
"AutoConnection": 0,
@@ -5376,6 +5605,9 @@ Module {
"ImAnchorPosition": 128,
"ImHints": 256,
"ImPreferredLanguage": 512,
+ "ImAbsolutePosition": 1024,
+ "ImTextBeforeCursor": 2048,
+ "ImTextAfterCursor": 4096,
"ImPlatformData": -2147483648,
"ImQueryInput": 186,
"ImQueryAll": -1
@@ -5395,6 +5627,9 @@ Module {
"ImAnchorPosition": 128,
"ImHints": 256,
"ImPreferredLanguage": 512,
+ "ImAbsolutePosition": 1024,
+ "ImTextBeforeCursor": 2048,
+ "ImTextAfterCursor": 4096,
"ImPlatformData": -2147483648,
"ImQueryInput": 186,
"ImQueryAll": -1
diff --git a/src/imports/window/plugins.qmltypes b/src/imports/window/plugins.qmltypes
index 1e3577acda..f69359b125 100644
--- a/src/imports/window/plugins.qmltypes
+++ b/src/imports/window/plugins.qmltypes
@@ -24,6 +24,7 @@ Module {
name: "QQuickScreen"
prototype: "QObject"
exports: ["QtQuick.Window/Screen 2.0"]
+ isCreatable: false
exportMetaObjectRevisions: [0]
attachedType: "QQuickScreenAttached"
}
@@ -56,6 +57,12 @@ Module {
prototype: "QWindow"
exports: ["QtQuick.Window/Window 2.0"]
exportMetaObjectRevisions: [0]
+ Enum {
+ name: "SceneGraphError"
+ values: {
+ "ContextNotAvailable": 1
+ }
+ }
Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
Property { name: "color"; type: "QColor" }
Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
@@ -67,11 +74,19 @@ Module {
isPointer: true
}
Signal { name: "frameSwapped" }
+ Signal {
+ name: "openglContextCreated"
+ revision: 2
+ Parameter { name: "context"; type: "QOpenGLContext"; isPointer: true }
+ }
Signal { name: "sceneGraphInitialized" }
Signal { name: "sceneGraphInvalidated" }
Signal { name: "beforeSynchronizing" }
+ Signal { name: "afterSynchronizing"; revision: 2 }
Signal { name: "beforeRendering" }
Signal { name: "afterRendering" }
+ Signal { name: "afterAnimating"; revision: 2 }
+ Signal { name: "sceneGraphAboutToStop"; revision: 2 }
Signal {
name: "closing"
revision: 1
@@ -82,6 +97,12 @@ Module {
Parameter { type: "QColor" }
}
Signal { name: "activeFocusItemChanged"; revision: 1 }
+ Signal {
+ name: "sceneGraphError"
+ revision: 2
+ Parameter { name: "error"; type: "QQuickWindow::SceneGraphError" }
+ Parameter { name: "message"; type: "string" }
+ }
Method { name: "update" }
Method { name: "releaseResources" }
}
@@ -91,6 +112,16 @@ Module {
prototype: "QQuickWindow"
exports: ["QtQuick.Window/Window 2.1"]
exportMetaObjectRevisions: [0]
+ Property { name: "visible"; type: "bool" }
+ Property { name: "visibility"; type: "Visibility" }
+ Signal {
+ name: "visibleChanged"
+ Parameter { name: "arg"; type: "bool" }
+ }
+ Signal {
+ name: "visibilityChanged"
+ Parameter { name: "visibility"; type: "QWindow::Visibility" }
+ }
}
Component {
name: "QWindow"
@@ -135,6 +166,11 @@ Module {
Parameter { name: "windowState"; type: "Qt::WindowState" }
}
Signal {
+ name: "windowTitleChanged"
+ revision: 2
+ Parameter { name: "title"; type: "string" }
+ }
+ Signal {
name: "xChanged"
Parameter { name: "arg"; type: "int" }
}
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 1fba6c0d3c..6ee23690a6 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -151,7 +151,7 @@ struct JSClass
struct String
{
quint32 flags; // isArrayIndex
- QArrayData str;
+ qint32 size;
// uint16 strdata[]
static int calculateSize(const QString &str) {
@@ -195,13 +195,12 @@ struct Unit
const uint *offsetTable = reinterpret_cast<const uint*>((reinterpret_cast<const char *>(this)) + offsetToStringTable);
const uint offset = offsetTable[idx];
const String *str = reinterpret_cast<const String*>(reinterpret_cast<const char *>(this) + offset);
- if (str->str.size == 0)
+ if (str->size == 0)
return QString();
- QStringDataPtr holder = { const_cast<QStringData *>(static_cast<const QStringData*>(&str->str)) };
- QString qstr(holder);
+ const QChar *characters = reinterpret_cast<const QChar *>(str + 1);
if (flags & StaticData)
- return qstr;
- return QString(qstr.constData(), qstr.length());
+ return QString::fromRawData(characters, str->size);
+ return QString(characters, str->size);
}
const uint *functionOffsetTable() const { return reinterpret_cast<const uint*>((reinterpret_cast<const char *>(this)) + offsetToFunctionTable); }
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index 65ef5c4b5e..144ef8a79e 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -82,11 +82,7 @@ void QV4::Compiler::StringTableGenerator::serialize(uint *stringTable, char *dat
QV4::CompiledData::String *s = (QV4::CompiledData::String*)(stringData);
s->flags = 0; // ###
- s->str.ref.atomic.store(-1);
- s->str.size = qstr.length();
- s->str.alloc = 0;
- s->str.capacityReserved = false;
- s->str.offset = sizeof(QArrayData);
+ s->size = qstr.length();
memcpy(s + 1, qstr.constData(), (qstr.length() + 1)*sizeof(ushort));
stringData += QV4::CompiledData::String::calculateSize(qstr);
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index e5c66a8929..48c68533ba 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -154,18 +154,13 @@ public:
else
flagIt = set.blockFlags->size();
} else {
- if (set.blockNumbers) {
+ if (set.blockNumbers)
numberIt = set.blockNumbers->begin();
- } else {
- flagIt = 0;
- size_t eIt = set.blockFlags->size();
- while (flagIt != eIt) {
- if (set.blockFlags->operator[](flagIt))
- break;
- else
- ++flagIt;
- }
- }
+ else
+ flagIt = std::distance(set.blockFlags->begin(),
+ std::find(set.blockFlags->begin(),
+ set.blockFlags->end(),
+ true));
}
}
@@ -195,16 +190,13 @@ public:
const_iterator &operator++()
{
- if (set.blockNumbers) {
+ if (set.blockNumbers)
++numberIt;
- } else {
- size_t eIt = set.blockFlags->size();
- while (flagIt != eIt) {
- ++flagIt;
- if (flagIt == eIt || set.blockFlags->operator[](flagIt))
- break;
- }
- }
+ else
+ flagIt = std::distance(set.blockFlags->begin(),
+ std::find(set.blockFlags->begin() + flagIt + 1,
+ set.blockFlags->end(),
+ true));
return *this;
}
diff --git a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
index 86715e93f1..f02c3da6af 100644
--- a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
+++ b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
@@ -148,8 +148,9 @@ Text {
For maximum interoperability with QML, \b {any property that is writable should
have an associated NOTIFY signal} that is emitted whenever the property value
has changed. This allows the property to be used with \l{Property
-Binding}{property binding}, which is an essential feature of QML that enables
-specific values to be updated whenever an associated property changes.
+Binding}{property binding}, which is an essential feature of QML that enforces
+relationships between properties by automatically updating a property whenever
+any of its dependencies change in value.
In the above example, the associated NOTIFY signal for the \c author property is
\c authorChanged, as specified in the Q_PROPERTY() macro call. This means that
diff --git a/src/qml/doc/src/javascript/expressions.qdoc b/src/qml/doc/src/javascript/expressions.qdoc
index c33daf7acc..79c11b3ac5 100644
--- a/src/qml/doc/src/javascript/expressions.qdoc
+++ b/src/qml/doc/src/javascript/expressions.qdoc
@@ -57,30 +57,28 @@ QML \l{QML Object Types}{object types} defined in \l{QML Documents}
{QML documents} can make use of JavaScript expressions which implement program
logic. There are four ways that JavaScript can be used in a QML document:
-\list
- \li \l{Property Attributes}{properties} can be
- assigned \l{Property Binding}{bindings} which are defined with
- JavaScript expressions, and which are automatically evaluated by the
- \l{QQmlEngine}{QML engine} when any properties accessed in the binding
- change, in order to ensure always-up-to-date property values. Binding
- expressions can also perform function evaluation as an explicit side
- effect
- \li \l{Signal Attributes}{signal handlers} can be defined
+\list 1
+ \li Relationships between \l{Property Attributes}{properties} are described
+ using JavaScript expressions in \l{Property Binding}{property bindings}.
+ When any of a property's \e dependencies change, the property is
+ automatically updated too, according to the specified relationship.
+ \li \l{Signal Attributes}{Signal handlers} can be defined
which are automatically evaluated when the object emits the associated
- signal
- \li \l{Method Attributes}{custom methods} can be defined
- in QML files as JavaScript functions
+ signal.
+ \li \l{Method Attributes}{Custom methods} can be defined
+ in QML files as JavaScript functions.
\li JavaScript files providing functions and variables can be
\l{Importing JavaScript Resources in QML}{imported} in a QML
- document
+ document.
\endlist
\section2 Property Bindings
-During startup, the QML engine will set up and initialize the property
-bindings. The JavaScript conditional operator is a valid property binding.
+In the following example, the \l Rectangle's \c color depends on the
+\l MouseArea's \c pressed property. This relationship is described using a
+conditional expression:
\qml
import QtQuick 2.0
@@ -100,7 +98,9 @@ Rectangle {
In fact, any JavaScript expression (no matter how complex) may be used in a
property binding definition, as long as the result of the expression is a
-value whose type can be assigned to the property.
+value whose type can be assigned to the property. This includes side effects.
+However, complex bindings and side effects are discouraged because they can
+reduce the performance, readability, and maintainability of the code.
There are two ways to define a property binding: the first (and most common)
is, as previously shown, in a \l{QML Object Attributes#Value Assignment on Initialization}
diff --git a/src/qml/doc/src/javascript/topic.qdoc b/src/qml/doc/src/javascript/topic.qdoc
index 40602b5017..f341816201 100644
--- a/src/qml/doc/src/javascript/topic.qdoc
+++ b/src/qml/doc/src/javascript/topic.qdoc
@@ -38,14 +38,11 @@ JavaScript to quickly develop both user-interfaces and application logic.
\section1 JavaScript Expressions
-QML has a deep JavaScript integration, and allows
-\l{Signal Attributes}{signal handlers}
-and \l{Method Attributes}{methods}
-to be defined in JavaScript. One of the other fundamental concepts of QML is
-the ability to bind property values to the result of complex expressions which
-can include properties from other objects. These
-\l{Property Binding}{property bindings}
-are JavaScript expressions.
+QML has a deep JavaScript integration, and allows \l{Signal Attributes}
+{signal handlers} and \l{Method Attributes}{methods} to be defined in JavaScript.
+Another core feature of QML is the ability to specify and enforce relationships
+between object properties using \l{Property Binding}{property bindings}, which
+are also defined using JavaScript.
See the documentation page titled
\l{qtqml-javascript-expressions.html}{JavaScript Expressions in QML Documents}
diff --git a/src/qml/doc/src/qmllanguageref/documents/scope.qdoc b/src/qml/doc/src/qmllanguageref/documents/scope.qdoc
index 845ca30b4f..af59afe1fb 100644
--- a/src/qml/doc/src/qmllanguageref/documents/scope.qdoc
+++ b/src/qml/doc/src/qmllanguageref/documents/scope.qdoc
@@ -105,11 +105,9 @@ ListView {
\section1 Binding Scope Object
-Property bindings are the most common use of JavaScript in QML. Property
-bindings associate the result of a JavaScript expression with a property of an
-object. The object to which the bound property belongs is known as the binding's
-scope object. In this QML simple declaration the \l Item object is the
-binding's scope object.
+An object which has a \l{Property Binding}{property binding} is known has the
+binding's \e{scope object}. In the following example, the \l Item object is
+the binding's scope object.
\code
Item {
diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
index 46a225ee30..3e48ec2308 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
@@ -189,16 +189,16 @@ which was then imported by the client), then a property of type
\c ColorfulButton would also be valid.
-\section3 Values of Property Attributes
+\section3 Assigning Values to Property Attributes
-The value of a property of an object instance may specified in an
-object declaration in two separate ways:
+The value of a property of an object instance may specified in two separate ways:
\list
\li a value assignment on initialization
\li an imperative value assignment
\endlist
-The value in either case may be either a binding expression or a static value.
+In either case, the value may be either a \e static value or a \e {binding expression}
+value.
\section4 Value Assignment on Initialization
@@ -251,10 +251,11 @@ Rectangle {
}
\endqml
-\section4 Valid Property Values
+\section3 Static Values and Binding Expression Values
As previously noted, there are two kinds of values which may be assigned to a
-property: static values, and binding expression values.
+property: \e static values, and \e {binding expression} values. The latter are
+also known as \l{Property Binding}{property bindings}.
\table
\header
@@ -263,20 +264,21 @@ property: static values, and binding expression values.
\row
\li Static Value
- \li A value whose type matches (or can be converted to) that of
- the property may be assigned to the property.
+ \li A constant value which does not depend on other properties.
\row
\li Binding Expression
- \li A JavaScript expression which may be evaluated, whose result is a
- value whose type matches (or can be converted to) that of the
- property may be assigned to the property. The expression will be
- automatically re-evaluated (and the new result assigned to the
- property) by the QML engine should the value of any properties accessed
- during evaluation change.
+ \li A JavaScript expression which describes a property's relationship with
+ other properties. The variables in this expression are called the
+ property's \e dependencies.
+
+ The QML engine enforces the relationship between a property and its
+ dependencies. When any of the dependencies change in value, the QML
+ engine automatically re-evaluates the binding expression and assigns
+ the new result to the property.
\endtable
-An example of these two types of values being assigned to properties follows:
+Here is an example that shows both kinds of values being assigned to properties:
\qml
import QtQuick 2.0
@@ -294,19 +296,11 @@ Rectangle {
}
\endqml
-In many cases, a string value may be converted automatically to a
-different type of value, as QML provides string converters for many property
-types (thus you can assign the string \c "red" to a color property).
-
-It is important to note that in order to assign a binding expression to a
-property in an imperative value assignment, the right-hand-side of
-the assignment (the binding expression) must be a function returned by the
-\l{Qt::binding()}{Qt.binding()} function, which returns a value of the
-appropriate type. A binding expression value may be assigned to a property
-via an initialization value assignment without using that function (and, in
-fact, attempting to do so will result in an error). See the documentation
-about \l{qtqml-syntax-propertybinding.html}{property binding} for more
-information on the topic.
+\note To assign a binding expression imperatively, the binding expression
+must be contained in a function that is passed into \l{Qt::binding()}{Qt.binding()},
+and then the value returned by Qt.binding() must be assigned to the property.
+In contrast, Qt.binding() must not be used when assigning a binding expression
+upon initialization. See \l{Property Binding} for more information.
\section3 Type Safety
@@ -324,7 +318,7 @@ property int volume: "four" // generates an error; the property's object will n
Likewise if a property is assigned a value of the wrong type during run time,
the new value will not be assigned, and an error will be generated.
-As noted in a previous section, some property types do not have a natural
+Some property types do not have a natural
value representation, and for those property types the QML engine
automatically performs string-to-typed-value conversion. So, for example,
even though properties of the \c color type store colors and not strings,
diff --git a/src/qml/doc/src/qmllanguageref/syntax/propertybinding.qdoc b/src/qml/doc/src/qmllanguageref/syntax/propertybinding.qdoc
index 653fe2391e..4f4d6ed9d8 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/propertybinding.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/propertybinding.qdoc
@@ -30,32 +30,44 @@
\title Property Binding
\brief binding object properties
-To make the fullest use of QML and its built-in support for implementing dynamic object behavioral changes, most QML objects will use \e {property binding}. This is a core feature of QML that allows objects to automatically update their properties in response to changing attributes in other objects or the occurrence of some external event.
+An object's property can be assigned a static value which stays constant until it
+is explicitly assigned a new value. However, to make the fullest use of QML and its
+built-in support for dynamic object behaviors, most QML objects use \e {property bindings}.
-When an object's property is assigned a value, it can either be assigned a static value, or \e bound to a JavaScript expression. In the first case, the property's value will not change unless a new value is assigned to the property. In the latter case, a \e {property binding} is created and the property's value is automatically updated by the QML engine whenever the value of the evaluated expression changes.
+Property bindings are a core feature of QML that lets developers specify relationships
+between different object properties. When a property's \e dependencies change in
+value, the property is automatically updated according to the specified relationship.
+Behind the scenes, the QML engine monitors the property's dependencies (that is,
+the variables in the binding expression). When a change is detected, the QML engine
+re-evaluates the binding expression and applies the new result to the property.
\section1 Overview
-To create a property binding, a property is assigned an expression that evaluates to the desired value. At its simplest, an expression may simply be a reference to another object's property. Take the following example, where the blue \l Rectangle's \c height is bound to the height of its parent:
+To create a property binding, a property is assigned a JavaScript expression that
+evaluates to the desired value. At its simplest, a binding may be a reference to
+another property. Take the following example, where the blue \l Rectangle's height
+is bound to the height of its parent:
\qml
Rectangle {
width: 200; height: 200
Rectangle {
- width: 100; height: parent.height
+ width: 100
+ height: parent.height
color: "blue"
}
}
\endqml
-Whenever the \c height of the parent item changes, the \c height of the blue rectangle will update to be of the same value.
+Whenever the height of the parent rectangle changes, the height of the blue
+rectangle automatically updates to be of the same value.
-Furthermore, a binding can contain any valid JavaScript expression or
-statement, as QML uses a standards compliant JavaScript engine. Below are
-valid bindings that could be substituted for the \c height binding from the
-above example:
+A binding can contain any valid JavaScript expression or statement, as QML uses
+a standards compliant JavaScript engine. Bindings can access object properties,
+call methods and use built-in JavaScript objects such as \c Date and \c Math.
+Below are other possible bindings for the previous example:
\code
height: parent.height / 2
@@ -74,16 +86,16 @@ height: {
height: someMethodThatReturnsHeight()
\endcode
-Whenever the value of \c parent.height changes, the QML engine will re-evaluate the above expression and assign the blue rectangle's \c width property with the appropriate updated value.
-
-Bindings can access object properties, call methods and use built-in JavaScript objects such as \c Date and \c Math. Here is an example with various valid bindings:
+Below is a more complex example involving more objects and types:
\qml
Column {
+ id: column
width: 200
height: 200
Rectangle {
+ id: topRect
width: Math.max(bottomRect.width, parent.width/2)
height: (parent.height / 3) + 10
color: "yellow"
@@ -103,15 +115,33 @@ Column {
}
\endqml
-While syntactically bindings can be of arbitrary complexity, if a binding starts to become overly complex - such as involving multiple lines, or imperative loops - it may be better to refactor the component entirely, or at least factor the binding out into a separate function.
+In the previous example,
+\list
+\li \c topRect.width depends on \c bottomRect.width and \c column.width
+\li \c topRect.height depends on \c column.height
+\li \c bottomRect.color depends on \c myTextInput.text.length
+\endlist
+
+Syntactically, bindings are allowed to be of arbitrary complexity. However, if
+a binding is overly complex - such as involving multiple lines, or imperative
+loops - it could indicate that the binding is being used for more than describing
+property relationships. Complex bindings can reduce code performance, readability,
+and maintainability. It may be a good idea to redesign components that have
+complex bindings, or at least factor the binding out into a separate function.
\keyword qml-javascript-assignment
\section1 Creating Property Bindings from JavaScript
-Once a property has been bound to an expression, the property is set to be automatically updated as necessary. However, be aware that if the property is later assigned a static value from a JavaScript statement, this will remove the binding.
+A property with a binding is automatically updated as necessary. However, if the
+property is later assigned a static value from a JavaScript statement, the binding
+will be removed.
-For example, the \c height of the \l Rectangle below is initially bound to be twice its \c width. However, when the space key is pressed, the \c height value is changed to be three times its \c width. At this point, the \c height is assigned the currently evaluated result of \c width*3 and \e {the height will no longer be automatically updated whenever the width changes}. The assignment of the static value removes the binding.
+For example, the \l Rectangle below initially ensures that its \c height is always
+twice its \c width. However, when the space key is pressed, the current value
+of \c {width*3} will be assigned to \c height as a \e static value. After that,
+\e {the \c height will remain fixed at this value, even if the \c width changes}.
+The assignment of the static value removes the binding.
\qml
import QtQuick 2.0
@@ -127,7 +157,10 @@ Rectangle {
}
\endqml
-If the intention is to remove the binding, then this is not a problem. However if the intention is to create a new binding of \c width*3 then the property must be assigned a Qt.binding() value instead. This is done by passing a function to Qt.binding() that returns the desired result:
+If the intention is to give the rectangle a fixed height and stop automatic
+updates, then this is not a problem. However, if the intention is to establish
+a new relationship between \c width and \c height, then the new binding
+expression must be wrapped in the Qt.binding() function instead:
\qml
import QtQuick 2.0
@@ -143,22 +176,21 @@ Rectangle {
}
\endqml
-Now when the space key is pressed, a new binding of \c width*3 is assigned, instead of simply removing the initial binding.
+Now, after the space key is pressed, the rectangle's height will continue
+auto-updating to always be three times its width.
\section2 Using \c this with Property Binding
-When creating a property binding from JavaScript, QML allows the use of the \c
-this keyword to refer to the object to which the property binding will be
-assigned. This allows one to explicitly refer to a property within an object
-when there may be ambiguity about the exact property that should be used for the
-binding.
+When creating a property binding from JavaScript, the \c this keyword can be used
+to refer to the object which receives the binding. This is helpful for resolving
+ambiguities with property names.
For example, the \c Component.onCompleted handler below is defined within the
-scope of the \l Item, and references to \c width within this scope would refer
-to the \l Item's width, rather than that of the \l Rectangle. To bind the \l
-Rectangle's \c height to its own \c width, the function passed to Qt.binding()
-needs to explicitly refer to \c this.width rather than just \c width.
+scope of the \l Item. In this scope, \c width refers to the \l Item's width, not
+the \l Rectangle's width. To bind the \l Rectangle's \c height to its own \c width,
+the binding expression must explicitly refer to \c this.width (or alternatively,
+\c{rect.width}):
\qml
Item {
@@ -178,12 +210,7 @@ Item {
}
\endqml
-In this case, the function could also have referred to \c rect.width rather than
-\c this.width.
-
-Note that the value of \c this is not defined outside of its use in property binding.
+\note The value of \c this is not defined outside of property bindings.
See \l {JavaScript Environment Restrictions} for details.
-
-
*/
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index d05ada481a..9cb727dd63 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -235,7 +235,7 @@ void QJSEngine::collectGarbage()
Evaluates \a program, using \a lineNumber as the base line number,
and returns the result of the evaluation.
- The script code will be evaluated in the current context.
+ The script code will be evaluated in the context of the global object.
The evaluation of \a program can cause an exception in the
engine; in this case the return value will be the exception
@@ -261,8 +261,11 @@ void QJSEngine::collectGarbage()
*/
QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, int lineNumber)
{
- QV4::Scope scope(d->m_v4Engine);
- QV4::ExecutionContext *ctx = d->m_v4Engine->currentContext();
+ QV4::ExecutionEngine *v4 = d->m_v4Engine;
+ QV4::Scope scope(v4);
+ QV4::ExecutionContext *ctx = v4->currentContext();
+ if (ctx != v4->rootContext)
+ ctx = v4->pushGlobalContext();
QV4::ScopedValue result(scope);
QV4::Script script(ctx, program, fileName, lineNumber);
@@ -273,7 +276,9 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in
result = script.run();
if (scope.engine->hasException)
result = ctx->catchException();
- return new QJSValuePrivate(d->m_v4Engine, result);
+ if (ctx != v4->rootContext)
+ v4->popContext();
+ return new QJSValuePrivate(v4, result);
}
/*!
diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp
index 9e02310815..6dcfafaa27 100644
--- a/src/qml/jsapi/qjsvalueiterator.cpp
+++ b/src/qml/jsapi/qjsvalueiterator.cpp
@@ -135,13 +135,10 @@ bool QJSValueIterator::hasNext() const
/*!
Advances the iterator by one position.
- Returns true if there is at least one item ahead of the iterator
- (i.e. the iterator is \e not at the back of the property sequence);
+ Returns true if there was at least one item ahead of the iterator
+ (i.e. the iterator was \e not already at the back of the property sequence);
otherwise returns false.
- Calling this function on an iterator located at the back of the
- container leads to undefined results.
-
\sa hasNext(), name()
*/
bool QJSValueIterator::next()
@@ -159,7 +156,7 @@ bool QJSValueIterator::next()
QV4::Scope scope(v4);
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
- return !!d_ptr->nextName || d_ptr->nextIndex != UINT_MAX;
+ return !!d_ptr->currentName || d_ptr->currentIndex != UINT_MAX;
}
/*!
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 8e943fa6ef..39a123c4d2 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -326,8 +326,8 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx)
ScopedCallData callData(scope, ctx->callData->argc ? ctx->callData->argc - 1 : 0);
if (ctx->callData->argc) {
- std::copy(ctx->callData->args + 1,
- ctx->callData->args + ctx->callData->argc, callData->args);
+ for (int i = 1; i < ctx->callData->argc; ++i)
+ callData->args[i - 1] = ctx->callData->args[i];
}
callData->thisObject = ctx->argument(0);
return o->call(callData);
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index 1076094a1e..c97e86f2cd 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -227,7 +227,7 @@ ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx)
int fdigits = -1;
if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) {
- int fdigits = ctx->callData->args[0].toInt32();
+ fdigits = ctx->callData->args[0].toInt32();
if (fdigits < 0 || fdigits > 20) {
ScopedString error(scope, ctx->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
return ctx->throwRangeError(error);
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 7c38ae4f01..f1e51703a8 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -508,21 +508,24 @@ ReturnedValue StringPrototype::method_replace(CallContext *ctx)
Scoped<RegExpObject> regExp(scope, searchValue);
if (regExp) {
uint offset = 0;
+
+ // We extract the pointer here to work around a compiler bug on Android.
+ Scoped<RegExp> re(scope, regExp->value);
while (true) {
int oldSize = nMatchOffsets;
- if (allocatedMatchOffsets < nMatchOffsets + regExp->value->captureCount() * 2) {
- allocatedMatchOffsets = qMax(allocatedMatchOffsets * 2, nMatchOffsets + regExp->value->captureCount() * 2);
+ if (allocatedMatchOffsets < nMatchOffsets + re->captureCount() * 2) {
+ allocatedMatchOffsets = qMax(allocatedMatchOffsets * 2, nMatchOffsets + re->captureCount() * 2);
uint *newOffsets = (uint *)malloc(allocatedMatchOffsets*sizeof(uint));
memcpy(newOffsets, matchOffsets, nMatchOffsets*sizeof(uint));
if (matchOffsets != _matchOffsets)
free(matchOffsets);
matchOffsets = newOffsets;
}
- if (regExp->value->match(string, offset, matchOffsets + oldSize) == JSC::Yarr::offsetNoMatch) {
+ if (re->match(string, offset, matchOffsets + oldSize) == JSC::Yarr::offsetNoMatch) {
nMatchOffsets = oldSize;
break;
}
- nMatchOffsets += regExp->value->captureCount() * 2;
+ nMatchOffsets += re->captureCount() * 2;
if (!regExp->global)
break;
offset = qMax(offset + 1, matchOffsets[oldSize + 1]);
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 0bb77d8077..d0d6839bdc 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1207,18 +1207,16 @@ DEFINE_OBJECT_VTABLE(QQmlBindingFunction);
/*!
\qmlmethod Qt::binding(function)
- Returns a JS object representing a binding expression which may be
- assigned to any property in imperative code to cause a binding
- assignment.
+ Returns a JavaScript object representing a \l{Property Binding}{property binding}.
- There are two main use-cases for the function: firstly, in imperative
- JavaScript code to cause a binding assignment:
+ There are two main use-cases for the function: firstly, to apply a
+ property binding imperatively from JavaScript code:
\snippet qml/qtBinding.1.qml 0
- and secondly, when defining initial property values of dynamically
- constructed objects (via Component.createObject() or
- Loader.setSource()) as being bound to the result of an expression.
+ and secondly, to apply a property binding when initializing property values
+ of dynamically constructed objects (via \l{Component::createObject()}
+ {Component.createObject()} or \l{Loader::setSource()}{Loader.setSource()}).
For example, assuming the existence of a DynamicText component:
\snippet qml/DynamicText.qml 0
@@ -1244,8 +1242,8 @@ DEFINE_OBJECT_VTABLE(QQmlBindingFunction);
\snippet qml/qtBinding.4.qml 0
- \note In \l {Qt Quick 1}, all function assignment was treated as
- binding assignment, so the Qt.binding() function is new in
+ \note In \l {Qt Quick 1}, all function assignments were treated as
+ binding assignments. The Qt.binding() function is new to
\l {Qt Quick}{Qt Quick 2}.
\since 5.0
diff --git a/src/quick/accessible/qaccessiblequickitem.cpp b/src/quick/accessible/qaccessiblequickitem.cpp
index bc2b4de86a..c8b2d9ec3e 100644
--- a/src/quick/accessible/qaccessiblequickitem.cpp
+++ b/src/quick/accessible/qaccessiblequickitem.cpp
@@ -193,6 +193,28 @@ bool QAccessibleQuickItem::isAccessible() const
return item()->d_func()->isAccessible;
}
+QStringList QAccessibleQuickItem::actionNames() const
+{
+ QStringList actions = QQmlAccessible::actionNames();
+ if (state().focusable)
+ actions.append(QAccessibleActionInterface::setFocusAction());
+ return actions;
+}
+
+void QAccessibleQuickItem::doAction(const QString &actionName)
+{
+ if (actionName == QAccessibleActionInterface::setFocusAction()) {
+ item()->forceActiveFocus();
+ } else {
+ QQmlAccessible::doAction(actionName);
+ }
+}
+
+QStringList QAccessibleQuickItem::keyBindingsForAction(const QString &actionName) const
+{
+ return QQmlAccessible::keyBindingsForAction(actionName);
+}
+
QString QAccessibleQuickItem::text(QAccessible::Text textType) const
{
// handles generic behavior not specific to an item
diff --git a/src/quick/accessible/qaccessiblequickitem_p.h b/src/quick/accessible/qaccessiblequickitem_p.h
index 354e0bf9f7..d1facf2199 100644
--- a/src/quick/accessible/qaccessiblequickitem_p.h
+++ b/src/quick/accessible/qaccessiblequickitem_p.h
@@ -74,6 +74,11 @@ public:
bool isAccessible() const;
+ // Action Interface
+ QStringList actionNames() const;
+ void doAction(const QString &actionName);
+ QStringList keyBindingsForAction(const QString &actionName) const;
+
// Value Interface
QVariant currentValue() const;
void setCurrentValue(const QVariant &value);
diff --git a/src/quick/doc/src/concepts/convenience/topic.qdoc b/src/quick/doc/src/concepts/convenience/topic.qdoc
index 1a6feeaa61..b87cfd84c1 100644
--- a/src/quick/doc/src/concepts/convenience/topic.qdoc
+++ b/src/quick/doc/src/concepts/convenience/topic.qdoc
@@ -54,14 +54,11 @@ application performance.
\section1 Dynamic Bindings
-Assigning binding expressions to properties is a fundamental concept of QML,
-and Qt Quick extends upon the idea with the \l Binding type. While bindings
-are typically specified as property initialization assignments, the \l Binding
-type allows the target of a binding to be defined explicitly and separately
-from the definition of the binding expression itself.
-By declaring a \l Binding instance, the client can dynamically bind properties
-from arbitrary objects at run-time, and can modify the binding target when
-required (or when it becomes available).
+\l{Property Binding}{Property bindings} are a fundamental feature of QML.
+Typically, a property is initialized with its binding. However, the \l Binding
+type and \l {Qt::binding()}{Qt.binding()} function allows the client to
+dynamically bind properties from any object at run-time, and modify the binding
+target when required (or when it becomes available).
\section1 Dynamic Signal Connections
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 2a6eae71f7..29e83e8247 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -1774,10 +1774,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::CallCon
pattern->patternRepeatY = true;
} else if (repetition == QStringLiteral("repeat-x")) {
pattern->patternRepeatX = true;
+ pattern->patternRepeatY = false;
} else if (repetition == QStringLiteral("repeat-y")) {
+ pattern->patternRepeatX = false;
pattern->patternRepeatY = true;
} else if (repetition == QStringLiteral("no-repeat")) {
- pattern->patternRepeatY = false;
+ pattern->patternRepeatX = false;
pattern->patternRepeatY = false;
} else {
//TODO: exception: SYNTAX_ERR
@@ -3316,7 +3318,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::CallCont
qreal y = ctx->callData->args[1].toNumber();
qreal w = ctx->callData->args[2].toNumber();
qreal h = ctx->callData->args[3].toNumber();
- if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(w))
+ if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(h))
V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "getImageData(): Invalid arguments");
if (w <= 0 || h <= 0)
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index 08dbfa3c23..d7527742dc 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -108,7 +108,7 @@ QQuickImagePrivate::QQuickImagePrivate()
\inherits Item
\brief Displays an image
- The Image type display an image.
+ The Image type displays an image.
The source of the image is specified as a URL using the \l source property.
Images can be supplied in any of the standard image formats supported by Qt,
diff --git a/src/quick/items/qquickimage_p.h b/src/quick/items/qquickimage_p.h
index 902e613b04..56b064f525 100644
--- a/src/quick/items/qquickimage_p.h
+++ b/src/quick/items/qquickimage_p.h
@@ -100,7 +100,7 @@ Q_SIGNALS:
void paintedGeometryChanged();
void horizontalAlignmentChanged(HAlignment alignment);
void verticalAlignmentChanged(VAlignment alignment);
- void mipmapChanged(bool);
+ Q_REVISION(1) void mipmapChanged(bool);
protected:
QQuickImage(QQuickImagePrivate &dd, QQuickItem *parent);
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 03a78895cf..da8ca9fd5d 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -5705,10 +5705,12 @@ void QQuickItem::setAntialiasing(bool aa)
{
Q_D(QQuickItem);
- bool changed = (aa != antialiasing());
- d->antialiasingValid = true;
+ if (!d->antialiasingValid) {
+ d->antialiasingValid = true;
+ d->antialiasing = d->implicitAntialiasing;
+ }
- if (!changed)
+ if (aa == d->antialiasing)
return;
d->antialiasing = aa;
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 0a60ab77f8..2f20dd763b 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -178,7 +178,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickTranslate>(uri,major,minor,"Translate");
qmlRegisterType<QQuickRotation>(uri,major,minor,"Rotation");
qmlRegisterType<QQuickScale>(uri,major,minor,"Scale");
- qmlRegisterType<QQuickMatrix4x4>(uri,2,4,"Matrix4x4");
+ qmlRegisterType<QQuickMatrix4x4>(uri,2,3,"Matrix4x4");
qmlRegisterType<QQuickText>(uri,major,minor,"Text");
qmlRegisterType<QQuickTextEdit>(uri,major,minor,"TextEdit");
qmlRegisterType<QQuickTextEdit,1>(uri,2,1,"TextEdit");
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index 53d736fb36..3087835212 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -423,7 +423,6 @@ void QQuickTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /
#endif
emit q->selectionChanged();
}
- q->updateCursorRectangle(true);
}
void QQuickTextControlPrivate::_q_updateCurrentCharFormatAndSelection()
@@ -1152,8 +1151,10 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou
#endif
if (interactionFlags & Qt::TextEditable) {
- if (cursor.position() != oldCursorPos)
+ if (cursor.position() != oldCursorPos) {
emit q->cursorPositionChanged();
+ q->updateCursorRectangle(true);
+ }
_q_updateCurrentCharFormatAndSelection();
#ifndef QT_NO_IM
if (qGuiApp)
@@ -1161,6 +1162,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou
#endif
} else if (cursor.position() != oldCursorPos) {
emit q->cursorPositionChanged();
+ q->updateCursorRectangle(true);
}
selectionChanged(true);
repaintOldAndNewSelection(oldSelection);
@@ -1255,6 +1257,7 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin
setClipboardSelection();
#endif
emit q->cursorPositionChanged();
+ q->updateCursorRectangle(true);
}
} else if (!sendMouseEventToInputContext(e, pos)) {
e->ignore();
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 16b48efd86..a95c13f161 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -687,6 +687,13 @@ void QQuickWindowPrivate::translateTouchEvent(QTouchEvent *touchEvent)
touchEvent->setTouchPoints(touchPoints);
}
+
+static inline bool windowHasFocus(QQuickWindow *win)
+{
+ const QWindow *focusWindow = QGuiApplication::focusWindow();
+ return win == focusWindow || QQuickRenderControl::renderWindowFor(win) == focusWindow;
+}
+
/*!
Set the focus inside \a scope to be \a item.
If the scope contains the active focus item, it will be changed to \a item.
@@ -762,7 +769,7 @@ void QQuickWindowPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *item, Q
}
if (!(options & DontChangeFocusProperty)) {
- if (item != contentItem || QGuiApplication::focusWindow() == q) {
+ if (item != contentItem || windowHasFocus(q)) {
itemPrivate->focus = true;
changed << item;
}
@@ -2522,6 +2529,7 @@ void QQuickWindowPrivate::cleanupNodesOnShutdown()
QSet<QQuickItem *>::const_iterator it = parentlessItems.begin();
for (; it != parentlessItems.end(); ++it)
cleanupNodesOnShutdown(*it);
+ animationController->windowNodesDestroyed();
q->cleanupSceneGraph();
}
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp
index d06fff8c3e..91388ea30f 100644
--- a/src/quick/items/qquickwindowmodule.cpp
+++ b/src/quick/items/qquickwindowmodule.cpp
@@ -175,6 +175,7 @@ void QQuickWindowModule::defineModule()
qmlRegisterType<QQuickWindow>(uri, 2, 0, "Window");
qmlRegisterRevision<QWindow,1>(uri, 2, 1);
+ qmlRegisterRevision<QWindow,2>(uri, 2, 2);
qmlRegisterRevision<QQuickWindow,1>(uri, 2, 1);//Type moved to a subclass, but also has new members
qmlRegisterRevision<QQuickWindow,2>(uri, 2, 2);
qmlRegisterType<QQuickWindowQmlImpl>(uri, 2, 1, "Window");
diff --git a/src/quick/util/qquickanimatorcontroller.cpp b/src/quick/util/qquickanimatorcontroller.cpp
index 7991dd8110..697c25b211 100644
--- a/src/quick/util/qquickanimatorcontroller.cpp
+++ b/src/quick/util/qquickanimatorcontroller.cpp
@@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE
QQuickAnimatorController::QQuickAnimatorController()
: m_window(0)
+ , m_nodesAreInvalid(false)
{
}
@@ -80,6 +81,26 @@ QQuickAnimatorController::~QQuickAnimatorController()
}
}
+static void qquickanimator_invalidate_node(QAbstractAnimationJob *job)
+{
+ if (job->isRenderThreadJob()) {
+ static_cast<QQuickAnimatorJob *>(job)->nodeWasDestroyed();
+ } else if (job->isGroup()) {
+ QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);
+ for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
+ qquickanimator_invalidate_node(a);
+ }
+}
+
+void QQuickAnimatorController::windowNodesDestroyed()
+{
+ m_nodesAreInvalid = true;
+ for (QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *>::const_iterator it = m_animatorRoots.constBegin();
+ it != m_animatorRoots.constEnd(); ++it) {
+ qquickanimator_invalidate_node(it.key());
+ }
+}
+
void QQuickAnimatorController::itemDestroyed(QObject *o)
{
m_deletedSinceLastFrame << (QQuickItem *) o;
@@ -112,7 +133,7 @@ void QQuickAnimatorController::advance()
m_window->update();
}
-static void qquick_initialize_helper(QAbstractAnimationJob *job, QQuickAnimatorController *c)
+static void qquick_initialize_helper(QAbstractAnimationJob *job, QQuickAnimatorController *c, bool attachListener)
{
if (job->isRenderThreadJob()) {
QQuickAnimatorJob *j = static_cast<QQuickAnimatorJob *>(job);
@@ -121,13 +142,14 @@ static void qquick_initialize_helper(QAbstractAnimationJob *job, QQuickAnimatorC
} else if (c->m_deletedSinceLastFrame.contains(j->target())) {
j->targetWasDeleted();
} else {
- j->addAnimationChangeListener(c, QAbstractAnimationJob::StateChange);
+ if (attachListener)
+ j->addAnimationChangeListener(c, QAbstractAnimationJob::StateChange);
j->initialize(c);
}
} else if (job->isGroup()) {
QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);
for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
- qquick_initialize_helper(a, c);
+ qquick_initialize_helper(a, c, attachListener);
}
}
@@ -147,7 +169,7 @@ void QQuickAnimatorController::beforeNodeSync()
foreach (QQuickAnimatorProxyJob *proxy, m_starting) {
QAbstractAnimationJob *job = proxy->job();
job->addAnimationChangeListener(this, QAbstractAnimationJob::Completion);
- qquick_initialize_helper(job, this);
+ qquick_initialize_helper(job, this, true);
m_animatorRoots[job] = proxy;
job->start();
proxy->startedByController();
@@ -160,6 +182,18 @@ void QQuickAnimatorController::beforeNodeSync()
}
m_stopping.clear();
+ // First sync after a window was hidden or otherwise invalidated.
+ // call initialize again to pick up new nodes..
+ if (m_nodesAreInvalid) {
+ for (QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *>::const_iterator it = m_animatorRoots.constBegin();
+ it != m_animatorRoots.constEnd(); ++it) {
+ qquick_initialize_helper(it.key(), this, false);
+ }
+ m_nodesAreInvalid = false;
+ }
+
+
+
foreach (QQuickAnimatorJob *job, m_activeLeafAnimations) {
if (!job->target())
continue;
diff --git a/src/quick/util/qquickanimatorcontroller_p.h b/src/quick/util/qquickanimatorcontroller_p.h
index 6223a9938f..745a494eec 100644
--- a/src/quick/util/qquickanimatorcontroller_p.h
+++ b/src/quick/util/qquickanimatorcontroller_p.h
@@ -76,6 +76,8 @@ public:
void lock() { m_mutex.lock(); }
void unlock() { m_mutex.unlock(); }
+ void windowNodesDestroyed();
+
public Q_SLOTS:
void itemDestroyed(QObject *);
@@ -92,6 +94,8 @@ public:
QSet<QQuickItem *> m_deletedSinceLastFrame;
QQuickWindow *m_window;
QMutex m_mutex;
+
+ bool m_nodesAreInvalid;
};
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp
index 3bc4cef5b9..0bf95a49b4 100644
--- a/src/quick/util/qquickanimatorjob.cpp
+++ b/src/quick/util/qquickanimatorjob.cpp
@@ -281,6 +281,12 @@ void QQuickTransformAnimatorJob::initialize(QQuickAnimatorController *controller
}
}
+void QQuickTransformAnimatorJob::nodeWasDestroyed()
+{
+ if (m_helper)
+ m_helper->node = 0;
+}
+
void QQuickTransformAnimatorJob::Helper::sync()
{
const quint32 mask = QQuickItemPrivate::Position
@@ -326,7 +332,7 @@ void QQuickTransformAnimatorJob::Helper::sync()
void QQuickTransformAnimatorJob::Helper::apply()
{
- if (!wasChanged)
+ if (!wasChanged || !node)
return;
QMatrix4x4 m;
@@ -412,6 +418,11 @@ void QQuickOpacityAnimatorJob::initialize(QQuickAnimatorController *controller)
}
}
+void QQuickOpacityAnimatorJob::nodeWasDestroyed()
+{
+ m_opacityNode = 0;
+}
+
void QQuickOpacityAnimatorJob::writeBack()
{
if (m_target)
@@ -420,7 +431,7 @@ void QQuickOpacityAnimatorJob::writeBack()
void QQuickOpacityAnimatorJob::updateCurrentTime(int time)
{
- if (!m_controller)
+ if (!m_controller || !m_opacityNode)
return;
Q_ASSERT(m_controller->m_window->openglContext()->thread() == QThread::currentThread());
@@ -504,13 +515,18 @@ void QQuickUniformAnimatorJob::setTarget(QQuickItem *target)
m_target = target;
}
+void QQuickUniformAnimatorJob::nodeWasDestroyed()
+{
+ m_node = 0;
+ m_uniformIndex = -1;
+ m_uniformType = -1;
+}
+
void QQuickUniformAnimatorJob::afterNodeSync()
{
m_node = static_cast<QQuickShaderEffectNode *>(QQuickItemPrivate::get(m_target)->paintNode);
- if (m_node) {
- m_uniformIndex = -1;
- m_uniformType = -1;
+ if (m_node && m_uniformIndex == -1 && m_uniformType == -1) {
QQuickShaderEffectMaterial *material =
static_cast<QQuickShaderEffectMaterial *>(m_node->material());
bool found = false;
diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h
index 8aae121106..03b13bcd30 100644
--- a/src/quick/util/qquickanimatorjob_p.h
+++ b/src/quick/util/qquickanimatorjob_p.h
@@ -131,6 +131,7 @@ public:
void targetWasDeleted();
virtual void initialize(QQuickAnimatorController *controller);
virtual void writeBack() = 0;
+ virtual void nodeWasDestroyed() = 0;
bool isTransform() const { return m_isTransform; }
bool isUniform() const { return m_isUniform; }
@@ -208,6 +209,7 @@ public:
protected:
QQuickTransformAnimatorJob();
void initialize(QQuickAnimatorController *controller);
+ void nodeWasDestroyed();
Helper *m_helper;
};
@@ -256,6 +258,7 @@ public:
void initialize(QQuickAnimatorController *controller);
void updateCurrentTime(int time);
void writeBack();
+ void nodeWasDestroyed();
private:
QSGOpacityNode *m_opacityNode;
@@ -275,6 +278,7 @@ public:
void updateCurrentTime(int time);
void writeBack();
+ void nodeWasDestroyed();
private:
QByteArray m_uniform;
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index e20e5f22ab..687aeabfe5 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -55,6 +55,8 @@
#include <private/qqmlengine_p.h>
#include <QtCore/qbasictimer.h>
#include <QtGui/QOffscreenSurface>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformintegration.h>
#ifdef Q_OS_WIN
# include <QtWidgets/QMessageBox>
@@ -89,7 +91,11 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
// Do not call create() on offscreenWindow.
createOffscreenSurface();
- setRenderToTexture();
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface))
+ setRenderToTexture();
+ else
+ qWarning("QQuickWidget is not supported on this platform.");
+
engine = e;
if (engine.isNull())
@@ -941,6 +947,20 @@ void QQuickWidget::wheelEvent(QWheelEvent *e)
}
#endif
+
+void QQuickWidget::focusInEvent(QFocusEvent * event)
+{
+ Q_D(QQuickWidget);
+ d->offscreenWindow->focusInEvent(event);
+}
+
+void QQuickWidget::focusOutEvent(QFocusEvent * event)
+{
+ Q_D(QQuickWidget);
+ d->offscreenWindow->focusOutEvent(event);
+}
+
+
/*! \reimp */
bool QQuickWidget::event(QEvent *e)
{
diff --git a/src/quickwidgets/qquickwidget.h b/src/quickwidgets/qquickwidget.h
index 81e9af02fb..4287933063 100644
--- a/src/quickwidgets/qquickwidget.h
+++ b/src/quickwidgets/qquickwidget.h
@@ -120,6 +120,9 @@ protected:
virtual void showEvent(QShowEvent *);
virtual void hideEvent(QHideEvent *);
+ virtual void focusInEvent(QFocusEvent * event);
+ virtual void focusOutEvent(QFocusEvent * event);
+
#ifndef QT_NO_WHEELEVENT
virtual void wheelEvent(QWheelEvent *);
#endif
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index b2723b02fd..17acb4fd32 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -157,6 +157,8 @@ private slots:
void dynamicProperties();
+ void scopeOfEvaluate();
+
signals:
void testSignal();
};
@@ -3011,6 +3013,43 @@ void tst_QJSEngine::dynamicProperties()
}
}
+class EvaluateWrapper : public QObject
+{
+ Q_OBJECT
+public:
+ EvaluateWrapper(QJSEngine *engine)
+ : engine(engine)
+ {}
+
+public slots:
+ QJSValue cppEvaluate(const QString &program)
+ {
+ return engine->evaluate(program);
+ }
+
+private:
+ QJSEngine *engine;
+};
+
+void tst_QJSEngine::scopeOfEvaluate()
+{
+ QJSEngine engine;
+ QJSValue wrapper = engine.newQObject(new EvaluateWrapper(&engine));
+
+ engine.evaluate("testVariable = 42");
+
+ QJSValue function = engine.evaluate("(function(evalWrapper){\n"
+ "var testVariable = 100; \n"
+ "try { \n"
+ " return evalWrapper.cppEvaluate(\"(function() { return testVariable; })\")\n"
+ " ()\n"
+ "} catch (e) {}\n"
+ "})");
+ QVERIFY(function.isCallable());
+ QJSValue result = function.call(QJSValueList() << wrapper);
+ QCOMPARE(result.toInt(), 42);
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"
diff --git a/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
index fa6ac3249b..73c880cc2d 100644
--- a/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
+++ b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
@@ -66,6 +66,7 @@ private slots:
void assignObjectToIterator();
void iterateNonObject();
void iterateOverObjectFromDeletedEngine();
+ void iterateWithNext();
};
tst_QJSValueIterator::tst_QJSValueIterator()
@@ -516,5 +517,31 @@ void tst_QJSValueIterator::iterateOverObjectFromDeletedEngine()
}
+void tst_QJSValueIterator::iterateWithNext()
+{
+ QJSEngine engine;
+ QJSValue value = engine.newObject();
+ value.setProperty("one", 1);
+ value.setProperty("two", 2);
+ value.setProperty("three", 3);
+
+ QStringList list;
+ list << QStringLiteral("one") << QStringLiteral("three") << QStringLiteral("two");
+
+ int counter = 0;
+ QJSValueIterator it(value);
+ QStringList actualList;
+ while (it.next()) {
+ ++counter;
+ actualList << it.name();
+ }
+
+ std::sort(actualList.begin(), actualList.end());
+
+ QCOMPARE(counter, 3);
+ QCOMPARE(list, actualList);
+
+}
+
QTEST_MAIN(tst_QJSValueIterator)
#include "tst_qjsvalueiterator.moc"
diff --git a/tests/auto/qmltest/animators/tst_multiwindow.qml b/tests/auto/qmltest/animators/tst_multiwindow.qml
new file mode 100644
index 0000000000..7f7ca253d3
--- /dev/null
+++ b/tests/auto/qmltest/animators/tst_multiwindow.qml
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import QtQuick.Window 2.0
+
+Item {
+ id: root;
+ width: 200
+ height: 200
+
+ TestCase {
+ id: testCase
+ name: "animators-mixed"
+ when: countdown == 0
+ function test_endresult() {
+ verify(true, "Just making sure we didn't crash");
+ }
+ }
+
+ property int countdown: 5;
+
+ Window {
+ id: window
+
+ width: 100
+ height: 100
+
+ ShaderEffect {
+ width: 50
+ height: 50
+
+ property real t;
+ UniformAnimator on t { from: 0; to: 1; duration: 1000; loops: Animation.Infinite }
+ RotationAnimator on rotation { from: 0; to: 360; duration: 1000; loops: Animation.Infinite }
+ ScaleAnimator on scale { from: 0.5; to: 1.5; duration: 1000; loops: Animation.Infinite }
+ XAnimator on x { from: 0; to: 50; duration: 1000; loops: Animation.Infinite }
+ YAnimator on y { from: 0; to: 50; duration: 1000; loops: Animation.Infinite }
+ OpacityAnimator on opacity { from: 1; to: 0.5; duration: 1000; loops: Animation.Infinite }
+
+ fragmentShader: "
+ uniform lowp float t;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor = vec4(qt_TexCoord0, t, 1) * qt_Opacity;
+ }
+ "
+ }
+
+ visible: true
+ }
+
+ Timer {
+ interval: 250
+ running: true
+ repeat: true
+ onTriggered: {
+ if (window.visible)
+ --countdown
+ window.visible = !window.visible;
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index 3298036f53..e7f0adb24d 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -2271,7 +2271,7 @@ void tst_QQuickItem::transforms()
QFETCH(QByteArray, qml);
QFETCH(QTransform, transform);
QQmlComponent component(&engine);
- component.setData("import QtQuick 2.4\nItem { transform: "+qml+"}", QUrl::fromLocalFile(""));
+ component.setData("import QtQuick 2.3\nItem { transform: "+qml+"}", QUrl::fromLocalFile(""));
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item);
QCOMPARE(item->itemTransform(0,0), transform);
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 3859fa8424..9ca7cafe3d 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -1334,6 +1334,13 @@ void tst_qquicktext::antialiasing()
text->resetAntialiasing();
QCOMPARE(text->antialiasing(), true);
QCOMPARE(spy.count(), 2);
+
+ // QTBUG-39047
+ component.setData("import QtQuick 2.0\n Text { antialiasing: true }", QUrl());
+ object.reset(component.create());
+ text = qobject_cast<QQuickText *>(object.data());
+ QVERIFY(text);
+ QCOMPARE(text->antialiasing(), true);
}
void tst_qquicktext::weight()
diff --git a/tests/auto/quick/qquicktextedit/data/qtbug-38947.qml b/tests/auto/quick/qquicktextedit/data/qtbug-38947.qml
new file mode 100644
index 0000000000..ebf8080e69
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/data/qtbug-38947.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+Item {
+ height: 200
+ width: 200
+ TextEdit {
+ objectName: "textedit"
+ text: "Hello\nWorld!"
+ selectByMouse: true
+ cursorDelegate: Rectangle {
+ width: 10
+ color: "transparent"
+ border.color: "red"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 88b9c2d792..f8fc4c10da 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -207,6 +207,7 @@ private slots:
void embeddedImages_data();
void emptytags_QTBUG_22058();
+ void cursorRectangle_QTBUG_38947();
private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
@@ -5262,6 +5263,33 @@ void tst_qquicktextedit::emptytags_QTBUG_22058()
QCOMPARE(input->text(), QString("<b>Bold<>"));
}
+void tst_qquicktextedit::cursorRectangle_QTBUG_38947()
+{
+ QQuickView window(testFileUrl("qtbug-38947.qml"));
+
+ window.show();
+ window.requestActivate();
+ QTest::qWaitForWindowExposed(&window);
+ QQuickTextEdit *edit = window.rootObject()->findChild<QQuickTextEdit *>("textedit");
+ QVERIFY(edit);
+
+ QPoint from = edit->positionToRectangle(0).center().toPoint();
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, from);
+
+ QSignalSpy spy(edit, SIGNAL(cursorRectangleChanged()));
+ QVERIFY(spy.isValid());
+
+ for (int i = 1; i < edit->length() - 1; ++i) {
+ QRectF rect = edit->positionToRectangle(i);
+ QTest::mouseMove(&window, rect.center().toPoint());
+ QCOMPARE(edit->cursorRectangle(), rect);
+ QCOMPARE(spy.count(), i);
+ }
+
+ QPoint to = edit->positionToRectangle(edit->length() - 1).center().toPoint();
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, to);
+}
+
QTEST_MAIN(tst_qquicktextedit)
#include "tst_qquicktextedit.moc"
diff --git a/tests/auto/quick/qquicktextinput/qquicktextinput.pro b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
index 521f41df43..c14b09c545 100644
--- a/tests/auto/quick/qquicktextinput/qquicktextinput.pro
+++ b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
@@ -14,5 +14,3 @@ TESTDATA = data/*
QT += core-private gui-private qml-private quick-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-macx: CONFIG+=insignificant_test # QTBUG-38363