forked from qt-creator/qt-creator
QmlDesigner: Split isAnchoredBy()
Split isAnchoredBy() in isAnchoredBySigbling() and isAnchoredByChildren()
This commit is contained in:
@@ -133,7 +133,8 @@ public:
|
||||
QVariant resetVariant(const QString &name) const;
|
||||
|
||||
bool hasAnchor(const QString &name) const;
|
||||
bool isAnchoredBy() const;
|
||||
bool isAnchoredBySibling() const;
|
||||
bool isAnchoredByChildren() const;
|
||||
QPair<QString, NodeInstance> anchor(const QString &name) const;
|
||||
|
||||
int penWidth() const;
|
||||
|
||||
@@ -66,7 +66,8 @@ public:
|
||||
bool hasShowContent() const;
|
||||
|
||||
bool canReparent() const;
|
||||
bool instanceIsAnchoredBy() const;
|
||||
bool instanceIsAnchoredBySibling() const;
|
||||
bool instanceIsAnchoredByChildren() const;
|
||||
|
||||
QRectF instanceBoundingRect() const;
|
||||
QTransform instanceTransform() const;
|
||||
|
||||
@@ -470,9 +470,14 @@ int NodeInstance::penWidth() const
|
||||
return m_nodeInstance->penWidth();
|
||||
}
|
||||
|
||||
bool NodeInstance::isAnchoredBy() const
|
||||
bool NodeInstance::isAnchoredBySibling() const
|
||||
{
|
||||
return m_nodeInstance->isAnchoredBy();
|
||||
return m_nodeInstance->isAnchoredBySibling();
|
||||
}
|
||||
|
||||
bool NodeInstance::isAnchoredByChildren() const
|
||||
{
|
||||
return m_nodeInstance->isAnchoredByChildren();
|
||||
}
|
||||
|
||||
QPair<QString, NodeInstance> NodeInstance::anchor(const QString &name) const
|
||||
|
||||
@@ -306,7 +306,12 @@ bool ObjectNodeInstance::hasAnchor(const QString &/*name*/) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ObjectNodeInstance::isAnchoredBy() const
|
||||
bool ObjectNodeInstance::isAnchoredBySibling() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ObjectNodeInstance::isAnchoredByChildren() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,8 @@ public:
|
||||
|
||||
virtual bool hasAnchor(const QString &name) const;
|
||||
virtual QPair<QString, NodeInstance> anchor(const QString &name) const;
|
||||
virtual bool isAnchoredBy() const;
|
||||
virtual bool isAnchoredBySibling() const;
|
||||
virtual bool isAnchoredByChildren() const;
|
||||
|
||||
virtual double rotation() const;
|
||||
virtual double scale() const;
|
||||
|
||||
@@ -591,8 +591,8 @@ bool isAnchoredTo(QDeclarativeItem *fromItem, QDeclarativeItem *toItem)
|
||||
|
||||
bool areChildrenAnchoredTo(QDeclarativeItem *fromItem, QDeclarativeItem *toItem)
|
||||
{
|
||||
foreach(QObject *childObject, fromItem->children()) {
|
||||
QDeclarativeItem *childItem = qobject_cast<QDeclarativeItem*>(childObject);
|
||||
foreach(QGraphicsItem *childGraphicsItem, fromItem->childItems()) {
|
||||
QDeclarativeItem *childItem = qobject_cast<QDeclarativeItem*>(childGraphicsItem->toGraphicsObject());
|
||||
if (childItem) {
|
||||
if (isAnchoredTo(childItem, toItem))
|
||||
return true;
|
||||
@@ -605,14 +605,11 @@ bool areChildrenAnchoredTo(QDeclarativeItem *fromItem, QDeclarativeItem *toItem)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QmlGraphicsItemNodeInstance::isAnchoredBy() const
|
||||
bool QmlGraphicsItemNodeInstance::isAnchoredBySibling() const
|
||||
{
|
||||
if (areChildrenAnchoredTo(qmlGraphicsItem(), qmlGraphicsItem())) // search in children for a anchor to this item
|
||||
return true;
|
||||
|
||||
if (qmlGraphicsItem()->parent()) {
|
||||
foreach(QObject *siblingObject, qmlGraphicsItem()->parent()->children()) { // search in siblings for a anchor to this item
|
||||
QDeclarativeItem *siblingItem = qobject_cast<QDeclarativeItem*>(siblingObject);
|
||||
if (qmlGraphicsItem()->parentItem()) {
|
||||
foreach(QGraphicsItem *siblingGraphicsItem, qmlGraphicsItem()->parentItem()->childItems()) { // search in siblings for a anchor to this item
|
||||
QDeclarativeItem *siblingItem = qobject_cast<QDeclarativeItem*>(siblingGraphicsItem->toGraphicsObject());
|
||||
if (siblingItem) {
|
||||
if (isAnchoredTo(siblingItem, qmlGraphicsItem()))
|
||||
return true;
|
||||
@@ -626,6 +623,14 @@ bool QmlGraphicsItemNodeInstance::isAnchoredBy() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QmlGraphicsItemNodeInstance::isAnchoredByChildren() const
|
||||
{
|
||||
if (areChildrenAnchoredTo(qmlGraphicsItem(), qmlGraphicsItem())) // search in children for a anchor to this item
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QDeclarativeItem *QmlGraphicsItemNodeInstance::qmlGraphicsItem() const
|
||||
{
|
||||
if (object() == 0)
|
||||
|
||||
@@ -64,7 +64,9 @@ public:
|
||||
|
||||
bool hasAnchor(const QString &name) const;
|
||||
QPair<QString, NodeInstance> anchor(const QString &name) const;
|
||||
bool isAnchoredBy() const;
|
||||
bool isAnchoredBySibling() const;
|
||||
bool isAnchoredByChildren() const;
|
||||
|
||||
protected:
|
||||
QmlGraphicsItemNodeInstance(QDeclarativeItem *item, bool hasContent);
|
||||
QDeclarativeItem *qmlGraphicsItem() const;
|
||||
|
||||
@@ -188,12 +188,17 @@ bool QmlItemNode::hasShowContent() const
|
||||
|
||||
bool QmlItemNode::canReparent() const
|
||||
{
|
||||
return QmlObjectNode::canReparent() && !anchors().instanceHasAnchors() && !instanceIsAnchoredBy();
|
||||
return QmlObjectNode::canReparent() && !anchors().instanceHasAnchors() && !instanceIsAnchoredBySibling();
|
||||
}
|
||||
|
||||
bool QmlItemNode::instanceIsAnchoredBy() const
|
||||
bool QmlItemNode::instanceIsAnchoredBySibling() const
|
||||
{
|
||||
return nodeInstance().isAnchoredBy();
|
||||
return nodeInstance().isAnchoredBySibling();
|
||||
}
|
||||
|
||||
bool QmlItemNode::instanceIsAnchoredByChildren() const
|
||||
{
|
||||
return nodeInstance().isAnchoredByChildren();
|
||||
}
|
||||
|
||||
QRectF QmlItemNode::instanceBoundingRect() const
|
||||
|
||||
Reference in New Issue
Block a user