summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-08-16 23:17:08 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-08-16 23:17:08 (GMT)
commit6e1f1d76b5bef03e44a2ec48a1a9359145dfca74 (patch)
tree2c77488c22262b9d74228bdd54a89c4269aa5af6 /src/declarative
parent82440843435b8bf02391fae1c9df6f081a945a65 (diff)
parentc6867a620259ee6c82a038995f424bef63d45aea (diff)
downloadQt-6e1f1d76b5bef03e44a2ec48a1a9359145dfca74.zip
Qt-6e1f1d76b5bef03e44a2ec48a1a9359145dfca74.tar.gz
Qt-6e1f1d76b5bef03e44a2ec48a1a9359145dfca74.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Add missing auto test files. Fix game could not be restarted Handle QGraphicsWidgets in Flickable More positioners with QGraphicsWidgets fixes. Make positioners work with QGraphicsWidgets also emit countChanged where appropriate in Repeater
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp115
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p.h8
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp5
5 files changed, 82 insertions, 53 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 31f7707..7fee44e 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -1029,7 +1029,7 @@ void QDeclarativeFlickable::cancelFlick()
void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
{
- QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o);
+ QGraphicsObject *i = qobject_cast<QGraphicsObject *>(o);
if (i)
i->setParentItem(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem);
else
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 5c21b03..4ceb5d9 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -61,16 +61,37 @@ static const QDeclarativeItemPrivate::ChangeTypes watchedChanges
| QDeclarativeItemPrivate::Opacity
| QDeclarativeItemPrivate::Destroyed;
-void QDeclarativeBasePositionerPrivate::watchChanges(QDeclarativeItem *other)
+void QDeclarativeBasePositionerPrivate::watchChanges(QGraphicsObject *other)
{
- QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other));
- otherPrivate->addItemChangeListener(this, watchedChanges);
+ if (QGraphicsItemPrivate::get(other)->isDeclarativeItem) {
+ QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other));
+ otherPrivate->addItemChangeListener(this, watchedChanges);
+ } else {
+ Q_Q(QDeclarativeBasePositioner);
+ QObject::connect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::connect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::connect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::connect(other, SIGNAL(visibleChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ }
}
-void QDeclarativeBasePositionerPrivate::unwatchChanges(QDeclarativeItem* other)
+void QDeclarativeBasePositionerPrivate::unwatchChanges(QGraphicsObject* other)
{
- QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other));
- otherPrivate->removeItemChangeListener(this, watchedChanges);
+ if (QGraphicsItemPrivate::get(other)->isDeclarativeItem) {
+ QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other));
+ otherPrivate->removeItemChangeListener(this, watchedChanges);
+ } else {
+ Q_Q(QDeclarativeBasePositioner);
+ QObject::disconnect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::disconnect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::disconnect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::disconnect(other, SIGNAL(visibleChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ }
+}
+
+void QDeclarativeBasePositioner::graphicsWidgetGeometryChanged()
+{
+ prePositioning();
}
/*!
@@ -174,16 +195,16 @@ QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change,
Q_D(QDeclarativeBasePositioner);
if (change == ItemChildAddedChange){
QGraphicsItem* item = value.value<QGraphicsItem*>();
- QDeclarativeItem* child = 0;
+ QGraphicsObject* child = 0;
if(item)
- child = qobject_cast<QDeclarativeItem*>(item->toGraphicsObject());
+ child = item->toGraphicsObject();
if (child)
prePositioning();
} else if (change == ItemChildRemovedChange) {
QGraphicsItem* item = value.value<QGraphicsItem*>();
- QDeclarativeItem* child = 0;
+ QGraphicsObject* child = 0;
if(item)
- child = qobject_cast<QDeclarativeItem*>(item->toGraphicsObject());
+ child = item->toGraphicsObject();
if (child) {
QDeclarativeBasePositioner::PositionedItem posItem(child);
int idx = positionedItems.find(posItem);
@@ -194,7 +215,6 @@ QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change,
prePositioning();
}
}
-
return QDeclarativeItem::itemChange(change, value);
}
@@ -216,10 +236,10 @@ void QDeclarativeBasePositioner::prePositioning()
QPODVector<PositionedItem,8> oldItems;
positionedItems.copyAndClear(oldItems);
for (int ii = 0; ii < children.count(); ++ii) {
- QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(ii));
+ QGraphicsObject *child = children.at(ii)->toGraphicsObject();
if (!child)
continue;
- QDeclarativeItemPrivate *childPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(child));
+ QGraphicsItemPrivate *childPrivate = static_cast<QGraphicsItemPrivate*>(QGraphicsItemPrivate::get(child));
PositionedItem *item = 0;
PositionedItem posItem(child);
int wIdx = oldItems.find(posItem);
@@ -302,10 +322,10 @@ void QDeclarativeBasePositioner::finishApplyTransitions()
d->moveActions.clear();
}
-static inline bool isInvisible(QDeclarativeItem *child)
+static inline bool isInvisible(QGraphicsObject *child)
{
- QDeclarativeItemPrivate *childPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(child));
- return child->opacity() == 0.0 || childPrivate->explicitlyHidden || !child->width() || !child->height();
+ QGraphicsItemPrivate *childPrivate = static_cast<QGraphicsItemPrivate*>(QGraphicsItemPrivate::get(child));
+ return child->opacity() == 0.0 || childPrivate->explicitlyHidden || !childPrivate->width() || !childPrivate->height();
}
/*!
@@ -441,9 +461,9 @@ void QDeclarativeColumn::doPositioning(QSizeF *contentSize)
if(child.item->y() != voffset)
positionY(voffset, child);
- contentSize->setWidth(qMax(contentSize->width(), child.item->width()));
+ contentSize->setWidth(qMax(contentSize->width(), QGraphicsItemPrivate::get(child.item)->width()));
- voffset += child.item->height();
+ voffset += QGraphicsItemPrivate::get(child.item)->height();
voffset += spacing();
}
@@ -455,8 +475,8 @@ void QDeclarativeColumn::reportConflictingAnchors()
QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this));
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
- if (child.item) {
- QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors;
+ if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) {
+ QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast<QDeclarativeItem *>(child.item))->_anchors;
if (anchors) {
QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors();
if (usedAnchors & QDeclarativeAnchors::TopAnchor ||
@@ -581,9 +601,9 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize)
if(child.item->x() != hoffset)
positionX(hoffset, child);
- contentSize->setHeight(qMax(contentSize->height(), child.item->height()));
+ contentSize->setHeight(qMax(contentSize->height(), QGraphicsItemPrivate::get(child.item)->height()));
- hoffset += child.item->width();
+ hoffset += QGraphicsItemPrivate::get(child.item)->width();
hoffset += spacing();
}
@@ -595,8 +615,8 @@ void QDeclarativeRow::reportConflictingAnchors()
QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this));
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
- if (child.item) {
- QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors;
+ if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) {
+ QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast<QDeclarativeItem *>(child.item))->_anchors;
if (anchors) {
QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors();
if (usedAnchors & QDeclarativeAnchors::LeftAnchor ||
@@ -817,10 +837,11 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
const PositionedItem &child = positionedItems.at(childIndex++);
if (!child.item || isInvisible(child.item))
continue;
- if (child.item->width() > maxColWidth[j])
- maxColWidth[j] = child.item->width();
- if (child.item->height() > maxRowHeight[i])
- maxRowHeight[i] = child.item->height();
+ QGraphicsItemPrivate *childPrivate = QGraphicsItemPrivate::get(child.item);
+ if (childPrivate->width() > maxColWidth[j])
+ maxColWidth[j] = childPrivate->width();
+ if (childPrivate->height() > maxRowHeight[i])
+ maxRowHeight[i] = childPrivate->height();
}
}
} else {
@@ -836,10 +857,11 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
const PositionedItem &child = positionedItems.at(childIndex++);
if (!child.item || isInvisible(child.item))
continue;
- if (child.item->width() > maxColWidth[j])
- maxColWidth[j] = child.item->width();
- if (child.item->height() > maxRowHeight[i])
- maxRowHeight[i] = child.item->height();
+ QGraphicsItemPrivate *childPrivate = QGraphicsItemPrivate::get(child.item);
+ if (childPrivate->width() > maxColWidth[j])
+ maxColWidth[j] = childPrivate->width();
+ if (childPrivate->height() > maxRowHeight[i])
+ maxRowHeight[i] = childPrivate->height();
}
}
}
@@ -858,7 +880,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
}
if (m_flow == LeftToRight) {
- contentSize->setWidth(qMax(contentSize->width(), xoffset + child.item->width()));
+ contentSize->setWidth(qMax(contentSize->width(), xoffset + QGraphicsItemPrivate::get(child.item)->width()));
contentSize->setHeight(yoffset + maxRowHeight[curRow]);
xoffset+=maxColWidth[curCol]+spacing();
@@ -872,7 +894,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
break;
}
} else {
- contentSize->setHeight(qMax(contentSize->height(), yoffset + child.item->height()));
+ contentSize->setHeight(qMax(contentSize->height(), yoffset + QGraphicsItemPrivate::get(child.item)->height()));
contentSize->setWidth(xoffset + maxColWidth[curCol]);
yoffset+=maxRowHeight[curRow]+spacing();
@@ -894,8 +916,8 @@ void QDeclarativeGrid::reportConflictingAnchors()
QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this));
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
- if (child.item) {
- QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors;
+ if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) {
+ QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast<QDeclarativeItem *>(child.item))->_anchors;
if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) {
d->anchorConflict = true;
break;
@@ -1030,14 +1052,15 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
if (!child.item || isInvisible(child.item))
continue;
+ QGraphicsItemPrivate *childPrivate = QGraphicsItemPrivate::get(child.item);
if (d->flow == LeftToRight) {
- if (widthValid() && hoffset && hoffset + child.item->width() > width()) {
+ if (widthValid() && hoffset && hoffset + childPrivate->width() > width()) {
hoffset = 0;
voffset += linemax + spacing();
linemax = 0;
}
} else {
- if (heightValid() && voffset && voffset + child.item->height() > height()) {
+ if (heightValid() && voffset && voffset + childPrivate->height() > height()) {
voffset = 0;
hoffset += linemax + spacing();
linemax = 0;
@@ -1049,17 +1072,17 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
positionY(voffset, child);
}
- contentSize->setWidth(qMax(contentSize->width(), hoffset + child.item->width()));
- contentSize->setHeight(qMax(contentSize->height(), voffset + child.item->height()));
+ contentSize->setWidth(qMax(contentSize->width(), hoffset + childPrivate->width()));
+ contentSize->setHeight(qMax(contentSize->height(), voffset + childPrivate->height()));
if (d->flow == LeftToRight) {
- hoffset += child.item->width();
+ hoffset += childPrivate->width();
hoffset += spacing();
- linemax = qMax(linemax, qCeil(child.item->height()));
+ linemax = qMax(linemax, qCeil(childPrivate->height()));
} else {
- voffset += child.item->height();
+ voffset += childPrivate->height();
voffset += spacing();
- linemax = qMax(linemax, qCeil(child.item->width()));
+ linemax = qMax(linemax, qCeil(childPrivate->width()));
}
}
}
@@ -1069,8 +1092,8 @@ void QDeclarativeFlow::reportConflictingAnchors()
Q_D(QDeclarativeFlow);
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
- if (child.item) {
- QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors;
+ if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) {
+ QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast<QDeclarativeItem *>(child.item))->_anchors;
if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) {
d->anchorConflict = true;
break;
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
index c03e518..f9ecc0a 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
@@ -91,14 +91,16 @@ Q_SIGNALS:
protected Q_SLOTS:
void prePositioning();
+ void graphicsWidgetGeometryChanged();
protected:
virtual void doPositioning(QSizeF *contentSize)=0;
virtual void reportConflictingAnchors()=0;
- struct PositionedItem {
- PositionedItem(QDeclarativeItem *i) : item(i), isNew(false), isVisible(true) {}
+ class PositionedItem {
+ public :
+ PositionedItem(QGraphicsObject *i) : item(i), isNew(false), isVisible(true) {}
bool operator==(const PositionedItem &other) const { return other.item == item; }
- QDeclarativeItem *item;
+ QGraphicsObject *item;
bool isNew;
bool isVisible;
};
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
index 822079b..35946e9 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
@@ -94,8 +94,8 @@ public:
QDeclarativeTransitionManager addTransitionManager;
QDeclarativeTransitionManager moveTransitionManager;
- void watchChanges(QDeclarativeItem *other);
- void unwatchChanges(QDeclarativeItem* other);
+ void watchChanges(QGraphicsObject *other);
+ void unwatchChanges(QGraphicsObject* other);
bool queuedPositioning : 1;
bool doingPositioning : 1;
bool anchorConflict : 1;
@@ -123,6 +123,7 @@ public:
if (newGeometry.size() != oldGeometry.size())
q->prePositioning();
}
+
virtual void itemVisibilityChanged(QDeclarativeItem *)
{
schedulePositioning();
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index 8828d3e..4a951a2 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -246,8 +246,8 @@ void QDeclarativeRepeater::setModel(const QVariant &model)
connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
*/
regenerate();
- emit countChanged();
}
+ emit countChanged();
}
/*!
@@ -378,6 +378,7 @@ void QDeclarativeRepeater::itemsInserted(int index, int count)
d->deletables.insert(modelIndex, item);
}
}
+ emit countChanged();
}
void QDeclarativeRepeater::itemsRemoved(int index, int count)
@@ -392,6 +393,7 @@ void QDeclarativeRepeater::itemsRemoved(int index, int count)
else
break;
}
+ emit countChanged();
}
void QDeclarativeRepeater::itemsMoved(int from, int to, int count)
@@ -421,6 +423,7 @@ void QDeclarativeRepeater::modelReset()
if (!isComponentComplete())
return;
regenerate();
+ emit countChanged();
}
QT_END_NAMESPACE