summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri6
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors.cpp144
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p.h17
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p_p.h18
-rw-r--r--src/declarative/graphicsitems/qdeclarativegraphicswidget.cpp144
-rw-r--r--src/declarative/graphicsitems/qdeclarativegraphicswidget_p.h90
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp4
9 files changed, 356 insertions, 72 deletions
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index eab41e3..ad7ccb5 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -50,7 +50,8 @@ HEADERS += \
$$PWD/qdeclarativelistview_p.h \
$$PWD/qdeclarativelayoutitem_p.h \
$$PWD/qdeclarativeitemchangelistener_p.h \
- $$PWD/qdeclarativeeffects.cpp
+ $$PWD/qdeclarativeeffects.cpp \
+ $$PWD/qdeclarativegraphicswidget_p.h
SOURCES += \
$$PWD/qdeclarativeitemsmodule.cpp \
@@ -81,4 +82,5 @@ SOURCES += \
$$PWD/qdeclarativetextedit.cpp \
$$PWD/qdeclarativevisualitemmodel.cpp \
$$PWD/qdeclarativelistview.cpp \
- $$PWD/qdeclarativelayoutitem.cpp
+ $$PWD/qdeclarativelayoutitem.cpp \
+ $$PWD/qdeclarativegraphicswidget.cpp
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
index 7a7e5be..96d0867 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
@@ -55,30 +55,32 @@ QT_BEGIN_NAMESPACE
//### const item?
//local position
-static qreal position(QDeclarativeItem *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
+static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
{
qreal ret = 0.0;
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item);
switch(anchorLine) {
case QDeclarativeAnchorLine::Left:
ret = item->x();
break;
case QDeclarativeAnchorLine::Right:
- ret = item->x() + item->width();
+ ret = item->x() + d->width();
break;
case QDeclarativeAnchorLine::Top:
ret = item->y();
break;
case QDeclarativeAnchorLine::Bottom:
- ret = item->y() + item->height();
+ ret = item->y() + d->height();
break;
case QDeclarativeAnchorLine::HCenter:
- ret = item->x() + item->width()/2;
+ ret = item->x() + d->width()/2;
break;
case QDeclarativeAnchorLine::VCenter:
- ret = item->y() + item->height()/2;
+ ret = item->y() + d->height()/2;
break;
case QDeclarativeAnchorLine::Baseline:
- ret = item->y() + item->baselineOffset();
+ if (d->isDeclarativeItem)
+ ret = item->y() + static_cast<QDeclarativeItem*>(item)->baselineOffset();
break;
default:
break;
@@ -88,30 +90,32 @@ static qreal position(QDeclarativeItem *item, QDeclarativeAnchorLine::AnchorLine
}
//position when origin is 0,0
-static qreal adjustedPosition(QDeclarativeItem *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
+static qreal adjustedPosition(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
{
int ret = 0;
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item);
switch(anchorLine) {
case QDeclarativeAnchorLine::Left:
ret = 0;
break;
case QDeclarativeAnchorLine::Right:
- ret = item->width();
+ ret = d->width();
break;
case QDeclarativeAnchorLine::Top:
ret = 0;
break;
case QDeclarativeAnchorLine::Bottom:
- ret = item->height();
+ ret = d->height();
break;
case QDeclarativeAnchorLine::HCenter:
- ret = item->width()/2;
+ ret = d->width()/2;
break;
case QDeclarativeAnchorLine::VCenter:
- ret = item->height()/2;
+ ret = d->height()/2;
break;
case QDeclarativeAnchorLine::Baseline:
- ret = item->baselineOffset();
+ if (d->isDeclarativeItem)
+ ret = static_cast<QDeclarativeItem*>(item)->baselineOffset();
break;
default:
break;
@@ -136,7 +140,7 @@ QDeclarativeAnchors::QDeclarativeAnchors(QObject *parent)
qFatal("QDeclarativeAnchors::QDeclarativeAnchors(QObject*) called");
}
-QDeclarativeAnchors::QDeclarativeAnchors(QDeclarativeItem *item, QObject *parent)
+QDeclarativeAnchors::QDeclarativeAnchors(QGraphicsObject *item, QObject *parent)
: QObject(*new QDeclarativeAnchorsPrivate(item), parent)
{
}
@@ -168,7 +172,8 @@ void QDeclarativeAnchorsPrivate::fillChanged()
} else if (fill->parentItem() == item->parentItem()) { //siblings
setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin));
}
- setItemSize(QSizeF(fill->width()-leftMargin-rightMargin, fill->height()-topMargin-bottomMargin));
+ QGraphicsItemPrivate *fillPrivate = QGraphicsItemPrivate::get(fill);
+ setItemSize(QSizeF(fillPrivate->width()-leftMargin-rightMargin, fillPrivate->height()-topMargin-bottomMargin));
--updatingFill;
} else {
@@ -185,16 +190,17 @@ void QDeclarativeAnchorsPrivate::centerInChanged()
if (updatingCenterIn < 2) {
++updatingCenterIn;
-
+ QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item);
if (centerIn == item->parentItem()) {
- QPointF p((item->parentItem()->width() - item->width()) / 2. + hCenterOffset,
- (item->parentItem()->height() - item->height()) / 2. + vCenterOffset);
+ QGraphicsItemPrivate *parentPrivate = QGraphicsItemPrivate::get(item->parentItem());
+ QPointF p((parentPrivate->width() - itemPrivate->width()) / 2. + hCenterOffset,
+ (parentPrivate->height() - itemPrivate->height()) / 2. + vCenterOffset);
setItemPos(p);
} else if (centerIn->parentItem() == item->parentItem()) {
-
- QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2. + hCenterOffset,
- centerIn->y() + (centerIn->height() - item->height()) / 2. + vCenterOffset);
+ QGraphicsItemPrivate *centerPrivate = QGraphicsItemPrivate::get(centerIn);
+ QPointF p(centerIn->x() + (centerPrivate->width() - itemPrivate->width()) / 2. + hCenterOffset,
+ centerIn->y() + (centerPrivate->height() - itemPrivate->height()) / 2. + vCenterOffset);
setItemPos(p);
}
@@ -205,7 +211,7 @@ void QDeclarativeAnchorsPrivate::centerInChanged()
}
}
-void QDeclarativeAnchorsPrivate::clearItem(QDeclarativeItem *item)
+void QDeclarativeAnchorsPrivate::clearItem(QGraphicsObject *item)
{
if (!item)
return;
@@ -243,22 +249,38 @@ void QDeclarativeAnchorsPrivate::clearItem(QDeclarativeItem *item)
}
}
-void QDeclarativeAnchorsPrivate::addDepend(QDeclarativeItem *item)
+void QDeclarativeAnchorsPrivate::addDepend(QGraphicsObject *item)
{
if (!item)
return;
- QDeclarativeItemPrivate *p =
- static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(item));
- p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(item);
+ if (itemPrivate->isDeclarativeItem) {
+ QDeclarativeItemPrivate *p =
+ static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(item));
+ p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ } else if(itemPrivate->isWidget) {
+ Q_Q(QDeclarativeAnchors);
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
+ QObject::connect(widget, SIGNAL(destroyed(QObject *)), q, SLOT(_q_widgetDestroyed(QObject *)));
+ QObject::connect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged()));
+ }
}
-void QDeclarativeAnchorsPrivate::remDepend(QDeclarativeItem *item)
+void QDeclarativeAnchorsPrivate::remDepend(QGraphicsObject *item)
{
if (!item)
return;
- QDeclarativeItemPrivate *p =
- static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(item));
- p->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(item);
+ if (itemPrivate->isDeclarativeItem) {
+ QDeclarativeItemPrivate *p =
+ static_cast<QDeclarativeItemPrivate *>(itemPrivate);
+ p->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ } else if(itemPrivate->isWidget) {
+ Q_Q(QDeclarativeAnchors);
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
+ QObject::disconnect(widget, SIGNAL(destroyed(QObject *)), q, SLOT(_q_widgetDestroyed(QObject *)));
+ QObject::disconnect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged()));
+ }
}
bool QDeclarativeAnchorsPrivate::isItemComplete() const
@@ -281,14 +303,14 @@ void QDeclarativeAnchors::componentComplete()
void QDeclarativeAnchorsPrivate::setItemHeight(qreal v)
{
updatingMe = true;
- item->setHeight(v);
+ QGraphicsItemPrivate::get(item)->setHeight(v);
updatingMe = false;
}
void QDeclarativeAnchorsPrivate::setItemWidth(qreal v)
{
updatingMe = true;
- item->setWidth(v);
+ QGraphicsItemPrivate::get(item)->setWidth(v);
updatingMe = false;
}
@@ -316,7 +338,10 @@ void QDeclarativeAnchorsPrivate::setItemPos(const QPointF &v)
void QDeclarativeAnchorsPrivate::setItemSize(const QSizeF &v)
{
updatingMe = true;
- item->setSize(v);
+ if(QGraphicsItemPrivate::get(item)->isWidget)
+ static_cast<QGraphicsWidget *>(item)->resize(v);
+ else if (QGraphicsItemPrivate::get(item)->isDeclarativeItem)
+ static_cast<QDeclarativeItem *>(item)->setSize(v);
updatingMe = false;
}
@@ -341,24 +366,36 @@ void QDeclarativeAnchorsPrivate::updateOnComplete()
updateVerticalAnchors();
}
-void QDeclarativeAnchorsPrivate::itemGeometryChanged(QDeclarativeItem *, const QRectF &newG, const QRectF &oldG)
+void QDeclarativeAnchorsPrivate::_q_widgetDestroyed(QObject *obj)
+{
+ clearItem(qobject_cast<QGraphicsObject*>(obj));
+}
+
+void QDeclarativeAnchorsPrivate::_q_widgetGeometryChanged()
{
fillChanged();
centerInChanged();
+ updateHorizontalAnchors();
+ updateVerticalAnchors();
+}
+void QDeclarativeAnchorsPrivate::itemGeometryChanged(QDeclarativeItem *, const QRectF &newG, const QRectF &oldG)
+{
+ fillChanged();
+ centerInChanged();
if (newG.x() != oldG.x() || newG.width() != oldG.width())
updateHorizontalAnchors();
if (newG.y() != oldG.y() || newG.height() != oldG.height())
updateVerticalAnchors();
}
-QDeclarativeItem *QDeclarativeAnchors::fill() const
+QGraphicsObject *QDeclarativeAnchors::fill() const
{
Q_D(const QDeclarativeAnchors);
return d->fill;
}
-void QDeclarativeAnchors::setFill(QDeclarativeItem *f)
+void QDeclarativeAnchors::setFill(QGraphicsObject *f)
{
Q_D(QDeclarativeAnchors);
if (d->fill == f)
@@ -386,13 +423,13 @@ void QDeclarativeAnchors::resetFill()
setFill(0);
}
-QDeclarativeItem *QDeclarativeAnchors::centerIn() const
+QGraphicsObject *QDeclarativeAnchors::centerIn() const
{
Q_D(const QDeclarativeAnchors);
return d->centerIn;
}
-void QDeclarativeAnchors::setCenterIn(QDeclarativeItem* c)
+void QDeclarativeAnchors::setCenterIn(QGraphicsObject* c)
{
Q_D(QDeclarativeAnchors);
if (d->centerIn == c)
@@ -439,10 +476,10 @@ bool QDeclarativeAnchorsPrivate::calcStretch(const QDeclarativeAnchorLine &edge1
- ((int)position(edge1.item, edge1.anchorLine) + offset1);
} else if (edge2IsParent && edge1IsSibling) {
stretch = ((int)position(edge2.item, edge2.anchorLine) + offset2)
- - ((int)position(item->parentItem(), line)
+ - ((int)position(item->parentObject(), line)
+ (int)position(edge1.item, edge1.anchorLine) + offset1);
} else if (edge2IsSibling && edge1IsParent) {
- stretch = ((int)position(item->parentItem(), line) + (int)position(edge2.item, edge2.anchorLine) + offset2)
+ stretch = ((int)position(item->parentObject(), line) + (int)position(edge2.item, edge2.anchorLine) + offset2)
- ((int)position(edge1.item, edge1.anchorLine) + offset1);
} else
invalid = true;
@@ -457,6 +494,7 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
if (updatingVerticalAnchor < 2) {
++updatingVerticalAnchor;
+ QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item);
if (usedAnchors & QDeclarativeAnchors::HasTopAnchor) {
//Handle stretching
bool invalid = true;
@@ -488,9 +526,9 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
//Handle bottom
if (bottom.item == item->parentItem()) {
- setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
+ setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - itemPrivate->height() - bottomMargin);
} else if (bottom.item->parentItem() == item->parentItem()) {
- setItemY(position(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
+ setItemY(position(bottom.item, bottom.anchorLine) - itemPrivate->height() - bottomMargin);
}
} else if (usedAnchors & QDeclarativeAnchors::HasVCenterAnchor) {
//(stetching handled above)
@@ -498,18 +536,20 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
//Handle vCenter
if (vCenter.item == item->parentItem()) {
setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine)
- - item->height()/2 + vCenterOffset);
+ - itemPrivate->height()/2 + vCenterOffset);
} else if (vCenter.item->parentItem() == item->parentItem()) {
- setItemY(position(vCenter.item, vCenter.anchorLine) - item->height()/2 + vCenterOffset);
+ setItemY(position(vCenter.item, vCenter.anchorLine) - itemPrivate->height()/2 + vCenterOffset);
}
} else if (usedAnchors & QDeclarativeAnchors::HasBaselineAnchor) {
//Handle baseline
if (baseline.item == item->parentItem()) {
- setItemY(adjustedPosition(baseline.item, baseline.anchorLine)
- - item->baselineOffset() + baselineOffset);
+ if (itemPrivate->isDeclarativeItem)
+ setItemY(adjustedPosition(baseline.item, baseline.anchorLine)
+ - static_cast<QDeclarativeItem *>(item)->baselineOffset() + baselineOffset);
} else if (baseline.item->parentItem() == item->parentItem()) {
- setItemY(position(baseline.item, baseline.anchorLine)
- - item->baselineOffset() + baselineOffset);
+ if (itemPrivate->isDeclarativeItem)
+ setItemY(position(baseline.item, baseline.anchorLine)
+ - static_cast<QDeclarativeItem *>(item)->baselineOffset() + baselineOffset);
}
}
--updatingVerticalAnchor;
@@ -526,7 +566,7 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors()
if (updatingHorizontalAnchor < 2) {
++updatingHorizontalAnchor;
-
+ QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item);
if (usedAnchors & QDeclarativeAnchors::HasLeftAnchor) {
//Handle stretching
bool invalid = true;
@@ -558,16 +598,16 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors()
//Handle right
if (right.item == item->parentItem()) {
- setItemX(adjustedPosition(right.item, right.anchorLine) - item->width() - rightMargin);
+ setItemX(adjustedPosition(right.item, right.anchorLine) - itemPrivate->width() - rightMargin);
} else if (right.item->parentItem() == item->parentItem()) {
- setItemX(position(right.item, right.anchorLine) - item->width() - rightMargin);
+ setItemX(position(right.item, right.anchorLine) - itemPrivate->width() - rightMargin);
}
} else if (usedAnchors & QDeclarativeAnchors::HasHCenterAnchor) {
//Handle hCenter
if (hCenter.item == item->parentItem()) {
- setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
+ setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - itemPrivate->width()/2 + hCenterOffset);
} else if (hCenter.item->parentItem() == item->parentItem()) {
- setItemX(position(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
+ setItemX(position(hCenter.item, hCenter.anchorLine) - itemPrivate->width()/2 + hCenterOffset);
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p.h
index 0b97e8c..f2e57cc 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p.h
@@ -75,12 +75,12 @@ class Q_DECLARATIVE_EXPORT QDeclarativeAnchors : public QObject
Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged())
Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())
- Q_PROPERTY(QDeclarativeItem *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged)
- Q_PROPERTY(QDeclarativeItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
+ Q_PROPERTY(QGraphicsObject *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged)
+ Q_PROPERTY(QGraphicsObject *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
public:
QDeclarativeAnchors(QObject *parent=0);
- QDeclarativeAnchors(QDeclarativeItem *item, QObject *parent=0);
+ QDeclarativeAnchors(QGraphicsObject *item, QObject *parent=0);
virtual ~QDeclarativeAnchors();
enum UsedAnchor {
@@ -148,12 +148,12 @@ public:
qreal baselineOffset() const;
void setBaselineOffset(qreal);
- QDeclarativeItem *fill() const;
- void setFill(QDeclarativeItem *);
+ QGraphicsObject *fill() const;
+ void setFill(QGraphicsObject *);
void resetFill();
- QDeclarativeItem *centerIn() const;
- void setCenterIn(QDeclarativeItem *);
+ QGraphicsObject *centerIn() const;
+ void setCenterIn(QGraphicsObject *);
void resetCenterIn();
UsedAnchors usedAnchors() const;
@@ -182,8 +182,11 @@ Q_SIGNALS:
private:
friend class QDeclarativeItem;
+ friend class QDeclarativeGraphicsWidget;
Q_DISABLE_COPY(QDeclarativeAnchors)
Q_DECLARE_PRIVATE(QDeclarativeAnchors)
+ Q_PRIVATE_SLOT(d_func(), void _q_widgetGeometryChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *obj))
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeAnchors::UsedAnchors)
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
index 4cadb43..f8489aa 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
@@ -77,7 +77,7 @@ public:
Vertical_Mask = Top | Bottom | VCenter | Baseline
};
- QDeclarativeItem *item;
+ QGraphicsObject *item;
AnchorLine anchorLine;
};
@@ -90,7 +90,7 @@ class QDeclarativeAnchorsPrivate : public QObjectPrivate, public QDeclarativeIte
{
Q_DECLARE_PUBLIC(QDeclarativeAnchors)
public:
- QDeclarativeAnchorsPrivate(QDeclarativeItem *i)
+ QDeclarativeAnchorsPrivate(QGraphicsObject *i)
: componentComplete(true), updatingMe(false), updatingHorizontalAnchor(0),
updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0),
centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
@@ -98,10 +98,10 @@ public:
{
}
- void clearItem(QDeclarativeItem *);
+ void clearItem(QGraphicsObject *);
- void addDepend(QDeclarativeItem *);
- void remDepend(QDeclarativeItem *);
+ void addDepend(QGraphicsObject *);
+ void remDepend(QGraphicsObject *);
bool isItemComplete() const;
bool componentComplete:1;
@@ -123,6 +123,8 @@ public:
// QDeclarativeItemGeometryListener interface
void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &);
+ void _q_widgetDestroyed(QObject *);
+ void _q_widgetGeometryChanged();
QDeclarativeAnchorsPrivate *anchorPrivate() { return this; }
bool checkHValid() const;
@@ -136,11 +138,11 @@ public:
void fillChanged();
void centerInChanged();
- QDeclarativeItem *item;
+ QGraphicsObject *item;
QDeclarativeAnchors::UsedAnchors usedAnchors;
- QDeclarativeItem *fill;
- QDeclarativeItem *centerIn;
+ QGraphicsObject *fill;
+ QGraphicsObject *centerIn;
QDeclarativeAnchorLine left;
QDeclarativeAnchorLine right;
diff --git a/src/declarative/graphicsitems/qdeclarativegraphicswidget.cpp b/src/declarative/graphicsitems/qdeclarativegraphicswidget.cpp
new file mode 100644
index 0000000..ee45406
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativegraphicswidget.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativegraphicswidget_p.h"
+#include "private/qdeclarativeanchors_p.h"
+#include "private/qdeclarativeitem_p.h"
+#include "private/qdeclarativeanchors_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeGraphicsWidgetPrivate : public QObjectPrivate {
+ Q_DECLARE_PUBLIC(QDeclarativeGraphicsWidget)
+public :
+ QDeclarativeGraphicsWidgetPrivate() :
+ _anchors(0), _anchorLines(0)
+ {}
+ QDeclarativeItemPrivate::AnchorLines *anchorLines() const;
+ QDeclarativeAnchors *_anchors;
+ mutable QDeclarativeItemPrivate::AnchorLines *_anchorLines;
+};
+
+QDeclarativeGraphicsWidget::QDeclarativeGraphicsWidget(QObject *parent) :
+ QObject(*new QDeclarativeGraphicsWidgetPrivate, parent)
+{
+}
+QDeclarativeGraphicsWidget::~QDeclarativeGraphicsWidget()
+{
+ Q_D(QDeclarativeGraphicsWidget);
+ delete d->_anchorLines; d->_anchorLines = 0;
+ delete d->_anchors; d->_anchors = 0;
+}
+
+/*! \internal */
+QDeclarativeAnchors *QDeclarativeGraphicsWidget::anchors()
+{
+ Q_D(QDeclarativeGraphicsWidget);
+ if (!d->_anchors)
+ d->_anchors = new QDeclarativeAnchors(static_cast<QGraphicsObject *>(parent()));
+ return d->_anchors;
+}
+
+QDeclarativeItemPrivate::AnchorLines *QDeclarativeGraphicsWidgetPrivate::anchorLines() const
+{
+ Q_Q(const QDeclarativeGraphicsWidget);
+ if (!_anchorLines)
+ _anchorLines = new QDeclarativeItemPrivate::AnchorLines(static_cast<QGraphicsObject *>(q->parent()));
+ return _anchorLines;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeGraphicsWidget::left() const
+{
+ Q_D(const QDeclarativeGraphicsWidget);
+ return d->anchorLines()->left;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeGraphicsWidget::right() const
+{
+ Q_D(const QDeclarativeGraphicsWidget);
+ return d->anchorLines()->right;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeGraphicsWidget::horizontalCenter() const
+{
+ Q_D(const QDeclarativeGraphicsWidget);
+ return d->anchorLines()->hCenter;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeGraphicsWidget::top() const
+{
+ Q_D(const QDeclarativeGraphicsWidget);
+ return d->anchorLines()->top;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeGraphicsWidget::bottom() const
+{
+ Q_D(const QDeclarativeGraphicsWidget);
+ return d->anchorLines()->bottom;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeGraphicsWidget::verticalCenter() const
+{
+ Q_D(const QDeclarativeGraphicsWidget);
+ return d->anchorLines()->vCenter;
+}
+
+QT_END_NAMESPACE
+
+#include <moc_qdeclarativegraphicswidget_p.cpp>
diff --git a/src/declarative/graphicsitems/qdeclarativegraphicswidget_p.h b/src/declarative/graphicsitems/qdeclarativegraphicswidget_p.h
new file mode 100644
index 0000000..987303e
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativegraphicswidget_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEGRAPHICSWIDGET_P_H
+#define QDECLARATIVEGRAPHICSWIDGET_P_H
+
+#include <QObject>
+#include <QtDeclarative/qdeclarativecomponent.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeAnchorLine;
+class QDeclarativeAnchors;
+class QGraphicsObject;
+class QDeclarativeGraphicsWidgetPrivate;
+
+// ### TODO can the extension object be the anchor directly? We save one allocation -> awesome.
+class QDeclarativeGraphicsWidget : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine left READ left CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine right READ right CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine top READ top CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL)
+ // ### TODO : QGraphicsWidget don't have a baseline concept yet.
+ //Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline CONSTANT FINAL)
+public:
+ QDeclarativeGraphicsWidget(QObject *parent = 0);
+ ~QDeclarativeGraphicsWidget();
+ QDeclarativeAnchors *anchors();
+ QDeclarativeAnchorLine left() const;
+ QDeclarativeAnchorLine right() const;
+ QDeclarativeAnchorLine horizontalCenter() const;
+ QDeclarativeAnchorLine top() const;
+ QDeclarativeAnchorLine bottom() const;
+ QDeclarativeAnchorLine verticalCenter() const;
+ Q_DISABLE_COPY(QDeclarativeGraphicsWidget)
+ Q_DECLARE_PRIVATE(QDeclarativeGraphicsWidget)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEGRAPHICSWIDGET_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 55a81f4..86dbaf0 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -2507,7 +2507,7 @@ QDeclarativeStateGroup *QDeclarativeItemPrivate::states()
return _stateGroup;
}
-QDeclarativeItemPrivate::AnchorLines::AnchorLines(QDeclarativeItem *q)
+QDeclarativeItemPrivate::AnchorLines::AnchorLines(QGraphicsObject *q)
{
left.item = q;
left.anchorLine = QDeclarativeAnchorLine::Left;
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 2607137..cf138c3 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -120,6 +120,7 @@ public:
mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0)
{
QGraphicsItemPrivate::acceptedMouseButtons = 0;
+ isDeclarativeItem = 1;
QGraphicsItemPrivate::flags = QGraphicsItem::GraphicsItemFlags(
QGraphicsItem::ItemHasNoContents
| QGraphicsItem::ItemIsFocusable
@@ -183,7 +184,7 @@ public:
QDeclarativeNullableValue<qreal> _baselineOffset;
struct AnchorLines {
- AnchorLines(QDeclarativeItem *);
+ AnchorLines(QGraphicsObject *);
QDeclarativeAnchorLine left;
QDeclarativeAnchorLine right;
QDeclarativeAnchorLine hCenter;
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index 8e5b863..eb055da 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -73,6 +73,7 @@
#include "private/qdeclarativetextedit_p.h"
#include "private/qdeclarativetextinput_p.h"
#include "private/qdeclarativevisualitemmodel_p.h"
+#include "private/qdeclarativegraphicswidget_p.h"
#ifdef QT_WEBKIT_LIB
#include "private/qdeclarativewebview_p.h"
#include "private/qdeclarativewebview_p_p.h"
@@ -132,7 +133,8 @@ void QDeclarativeItemModule::defineModule()
qmlRegisterType<QDeclarativeKeyEvent>();
qmlRegisterType<QDeclarativeMouseEvent>();
qmlRegisterType<QGraphicsObject>();
- qmlRegisterType<QGraphicsWidget>();
+ qmlRegisterType<QGraphicsWidget>("Qt",4,6,"QGraphicsWidget");
+ qmlRegisterExtendedType<QGraphicsWidget,QDeclarativeGraphicsWidget>("Qt",4,6,"QGraphicsWidget");
qmlRegisterType<QGraphicsTransform>();
qmlRegisterType<QDeclarativePathElement>();
qmlRegisterType<QDeclarativeCurve>();