aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-22 21:21:39 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-22 21:21:39 +0200
commit2ff13bdf697adff8574c5cea716627c78fb6b5b3 (patch)
treef4eac21b3b54f62d9f79714f40d5c9f4804dfc0c /src/quick/items
parent9d487cd6bf8ad75de19a4c05eb3d2641ce4a5289 (diff)
parente13eece273195a9f39d29712a233a8dd00ddf71b (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickitem.cpp90
-rw-r--r--src/quick/items/qquickitem.h6
-rw-r--r--src/quick/items/qquickitemsmodule.cpp1
-rw-r--r--src/quick/items/qquicktextinput.cpp2
4 files changed, 86 insertions, 13 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index cbe1bac5c9..fd872a5912 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -4297,12 +4297,12 @@ void QQuickItem::polish()
*/
void QQuickItem::mapFromItem(QQmlV4Function *args) const
{
+ QV4::ExecutionEngine *v4 = args->v4engine();
if (args->length() != 3 && args->length() != 5) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
- QV4::ExecutionEngine *v4 = args->v4engine();
QV4::Scope scope(v4);
QV4::ScopedValue item(scope, (*args)[0]);
@@ -4316,7 +4316,7 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const
if (!itemObj && !item->isNull()) {
qmlInfo(this) << "mapFromItem() given argument \"" << item->toQStringNoThrow()
<< "\" which is neither null nor an Item";
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
@@ -4324,7 +4324,7 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const
QV4::ScopedValue vy(scope, (*args)[2]);
if (!vx->isNumber() || !vy->isNumber()) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
@@ -4337,7 +4337,7 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const
QV4::ScopedValue vw(scope, (*args)[3]);
QV4::ScopedValue vh(scope, (*args)[4]);
if (!vw->isNumber() || !vh->isNumber()) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
qreal w = vw->asDouble();
@@ -4385,12 +4385,12 @@ QTransform QQuickItem::itemTransform(QQuickItem *other, bool *ok) const
*/
void QQuickItem::mapToItem(QQmlV4Function *args) const
{
+ QV4::ExecutionEngine *v4 = args->v4engine();
if (args->length() != 3 && args->length() != 5) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
- QV4::ExecutionEngine *v4 = args->v4engine();
QV4::Scope scope(v4);
QV4::ScopedValue item(scope, (*args)[0]);
@@ -4404,7 +4404,7 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
if (!itemObj && !item->isNull()) {
qmlInfo(this) << "mapToItem() given argument \"" << item->toQStringNoThrow()
<< "\" which is neither null nor an Item";
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
@@ -4412,7 +4412,7 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
QV4::ScopedValue vy(scope, (*args)[2]);
if (!vx->isNumber() || !vy->isNumber()) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
@@ -4425,7 +4425,7 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
QV4::ScopedValue vw(scope, (*args)[3]);
QV4::ScopedValue vh(scope, (*args)[4]);
if (!vw->isNumber() || !vh->isNumber()) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
qreal w = vw->asDouble();
@@ -4441,6 +4441,76 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
}
/*!
+ \since 5.7
+ \qmlmethod object QtQuick::Item::mapFromGlobal(real x, real y)
+
+ Maps the point (\a x, \a y), which is in the global coordinate system, to the
+ item's coordinate system, and returns a \l point matching the mapped coordinate.
+*/
+/*!
+ \internal
+ */
+void QQuickItem::mapFromGlobal(QQmlV4Function *args) const
+{
+ QV4::ExecutionEngine *v4 = args->v4engine();
+ if (args->length() != 2) {
+ v4->throwTypeError();
+ return;
+ }
+
+ QV4::Scope scope(v4);
+ QV4::ScopedValue vx(scope, (*args)[0]);
+ QV4::ScopedValue vy(scope, (*args)[1]);
+
+ if (!vx->isNumber() || !vy->isNumber()) {
+ v4->throwTypeError();
+ return;
+ }
+
+ qreal x = vx->asDouble();
+ qreal y = vy->asDouble();
+ QVariant result = mapFromGlobal(QPointF(x, y));
+
+ QV4::ScopedObject rv(scope, v4->fromVariant(result));
+ args->setReturnValue(rv.asReturnedValue());
+}
+
+/*!
+ \since 5.7
+ \qmlmethod object QtQuick::Item::mapToGlobal(real x, real y)
+
+ Maps the point (\a x, \a y), which is in this item's coordinate system, to the
+ global coordinate system, and returns a \l point matching the mapped coordinate.
+*/
+/*!
+ \internal
+ */
+void QQuickItem::mapToGlobal(QQmlV4Function *args) const
+{
+ QV4::ExecutionEngine *v4 = args->v4engine();
+ if (args->length() != 2) {
+ v4->throwTypeError();
+ return;
+ }
+
+ QV4::Scope scope(v4);
+ QV4::ScopedValue vx(scope, (*args)[0]);
+ QV4::ScopedValue vy(scope, (*args)[1]);
+
+ if (!vx->isNumber() || !vy->isNumber()) {
+ v4->throwTypeError();
+ return;
+ }
+
+ qreal x = vx->asDouble();
+ qreal y = vy->asDouble();
+ QVariant result = mapToGlobal(QPointF(x, y));
+
+ QV4::ScopedObject rv(scope, v4->fromVariant(result));
+ args->setReturnValue(rv.asReturnedValue());
+}
+
+/*!
\qmlmethod QtQuick::Item::forceActiveFocus()
Forces active focus on the item.
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index 510d46739a..b1b1d627b1 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -320,12 +320,12 @@ public:
QTransform itemTransform(QQuickItem *, bool *) const;
QPointF mapToItem(const QQuickItem *item, const QPointF &point) const;
QPointF mapToScene(const QPointF &point) const;
- Q_REVISION(7) Q_INVOKABLE QPointF mapToGlobal(const QPointF &point) const;
+ QPointF mapToGlobal(const QPointF &point) const;
QRectF mapRectToItem(const QQuickItem *item, const QRectF &rect) const;
QRectF mapRectToScene(const QRectF &rect) const;
QPointF mapFromItem(const QQuickItem *item, const QPointF &point) const;
QPointF mapFromScene(const QPointF &point) const;
- Q_REVISION(7) Q_INVOKABLE QPointF mapFromGlobal(const QPointF &point) const;
+ QPointF mapFromGlobal(const QPointF &point) const;
QRectF mapRectFromItem(const QQuickItem *item, const QRectF &rect) const;
QRectF mapRectFromScene(const QRectF &rect) const;
@@ -333,6 +333,8 @@ public:
Q_INVOKABLE void mapFromItem(QQmlV4Function*) const;
Q_INVOKABLE void mapToItem(QQmlV4Function*) const;
+ Q_REVISION(7) Q_INVOKABLE void mapFromGlobal(QQmlV4Function*) const;
+ Q_REVISION(7) Q_INVOKABLE void mapToGlobal(QQmlV4Function*) const;
Q_INVOKABLE void forceActiveFocus();
Q_INVOKABLE void forceActiveFocus(Qt::FocusReason reason);
Q_REVISION(1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 944f24c4ad..0705d9b504 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -349,6 +349,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickShaderEffectSource, 1>(uri, 2, 6, "ShaderEffectSource");
#endif
+ qmlRegisterType<QQuickItem, 7>(uri, 2, 7, "Item");
#if QT_CONFIG(quick_listview)
qmlRegisterType<QQuickListView, 7>(uri, 2, 7, "ListView");
#endif
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 4c9a1f8dfc..9a43ee8bdf 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -766,7 +766,7 @@ void QQuickTextInput::setMaxLength(int ml)
(but without actually giving it active focus).
It should not be set directly on the item, like in the below QML,
- as the specified value will be overridden an lost on focus changes.
+ as the specified value will be overridden and lost on focus changes.
\code
TextInput {