summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativeitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativeitem.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp86
1 files changed, 56 insertions, 30 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 86dbaf0..bc0c65e 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -61,7 +61,6 @@
#include <QtCore/qnumeric.h>
#include <QtScript/qscriptengine.h>
#include <QtGui/qgraphicstransform.h>
-#include <QtGui/qgraphicseffect.h>
#include <qlistmodelinterface_p.h>
QT_BEGIN_NAMESPACE
@@ -70,8 +69,6 @@ QT_BEGIN_NAMESPACE
#define FLT_MAX 1E+37
#endif
-#include "qdeclarativeeffects.cpp"
-
/*!
\qmlclass Transform QGraphicsTransform
\since 4.7
@@ -234,11 +231,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \group group_effects
- \title Effects
-*/
-
-/*!
\group group_layouts
\title Layouts
*/
@@ -275,17 +267,6 @@ QDeclarativeContents::QDeclarativeContents() : m_x(0), m_y(0), m_width(0), m_hei
{
}
-/*!
- \qmlproperty real Item::childrenRect.x
- \qmlproperty real Item::childrenRect.y
- \qmlproperty real Item::childrenRect.width
- \qmlproperty real Item::childrenRect.height
-
- The childrenRect properties allow an item access to the geometry of its
- children. This property is useful if you have an item that needs to be
- sized to fit its children.
-*/
-
QRectF QDeclarativeContents::rectF() const
{
return QRectF(m_x, m_y, m_width, m_height);
@@ -1415,7 +1396,7 @@ QDeclarativeItem::~QDeclarativeItem()
}
/*!
- \qmlproperty enum Item::transformOrigin
+ \qmlproperty enumeration Item::transformOrigin
This property holds the origin point around which scale and rotation transform.
Nine transform origins are available, as shown in the image below.
@@ -1457,6 +1438,18 @@ QDeclarativeItem *QDeclarativeItem::parentItem() const
}
/*!
+ \qmlproperty real Item::childrenRect.x
+ \qmlproperty real Item::childrenRect.y
+ \qmlproperty real Item::childrenRect.width
+ \qmlproperty real Item::childrenRect.height
+
+ The childrenRect properties allow an item access to the geometry of its
+ children. This property is useful if you have an item that needs to be
+ sized to fit its children.
+*/
+
+
+/*!
\qmlproperty list<Item> Item::children
\qmlproperty list<Object> Item::resources
@@ -1594,10 +1587,10 @@ void QDeclarativeItemPrivate::transform_clear(QDeclarativeListProperty<QGraphics
}
}
-void QDeclarativeItemPrivate::parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e)
+void QDeclarativeItemPrivate::parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e)
{
QDeclarativeItem *item = static_cast<QDeclarativeItem*>(o);
- if (e)
+ if (e)
e->connect(&item->d_func()->parentNotifier);
*((QDeclarativeItem **)rv) = item->parentItem();
}
@@ -1794,9 +1787,13 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry,
if (transformOrigin() != QDeclarativeItem::TopLeft
&& (newGeometry.width() != oldGeometry.width() || newGeometry.height() != oldGeometry.height())) {
- QPointF origin = d->computeTransformOrigin();
- if (transformOriginPoint() != origin)
- setTransformOriginPoint(origin);
+ if (d->transformData) {
+ QPointF origin = d->computeTransformOrigin();
+ if (transformOriginPoint() != origin)
+ setTransformOriginPoint(origin);
+ } else {
+ d->transformOriginDirty = true;
+ }
}
if (newGeometry.x() != oldGeometry.x())
@@ -2149,8 +2146,8 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
Opacity is an \e inherited attribute. That is, the opacity is
also applied individually to child items. In almost all cases this
- is what you want. If you can spot the issue in the following
- example, you might need to use an \l Opacity effect instead.
+ is what you want, but in some cases (like the following example)
+ it may produce undesired results.
\table
\row
@@ -2238,7 +2235,7 @@ QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, qreal x, qr
QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject();
QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject());
if (!itemObj && !item.isNull()) {
- qWarning().nospace() << "mapFromItem() given argument " << item.toString() << " which is neither null nor an Item";
+ qmlInfo(this) << "mapFromItem() given argument \"" << item.toString() << "\" which is neither null nor an Item";
return 0;
}
@@ -2264,7 +2261,7 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qrea
QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject();
QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject());
if (!itemObj && !item.isNull()) {
- qWarning().nospace() << "mapToItem() given argument " << item.toString() << " which is neither null nor an Item";
+ qmlInfo(this) << "mapToItem() given argument \"" << item.toString() << "\" which is neither null nor an Item";
return 0;
}
@@ -2275,6 +2272,23 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qrea
return sv;
}
+/*!
+ \qmlmethod Item::forceFocus()
+
+ Force the focus on the item.
+ This method sets the focus on the item and makes sure that all the focus scopes higher in the object hierarchy are given focus.
+*/
+void QDeclarativeItem::forceFocus()
+{
+ setFocus(true);
+ QGraphicsItem *parent = parentItem();
+ while (parent) {
+ if (parent->flags() & QGraphicsItem::ItemIsFocusScope)
+ parent->setFocus(Qt::OtherFocusReason);
+ parent = parent->parentItem();
+ }
+}
+
void QDeclarativeItemPrivate::focusChanged(bool flag)
{
Q_Q(QDeclarativeItem);
@@ -2656,11 +2670,23 @@ void QDeclarativeItem::setTransformOrigin(TransformOrigin origin)
Q_D(QDeclarativeItem);
if (origin != d->origin) {
d->origin = origin;
- QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin());
+ if (d->transformData)
+ QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin());
+ else
+ d->transformOriginDirty = true;
emit transformOriginChanged(d->origin);
}
}
+void QDeclarativeItemPrivate::transformChanged()
+{
+ Q_Q(QDeclarativeItem);
+ if (transformOriginDirty) {
+ q->QGraphicsItem::setTransformOriginPoint(computeTransformOrigin());
+ transformOriginDirty = false;
+ }
+}
+
/*!
\property QDeclarativeItem::smooth
\brief whether the item is smoothly transformed.