forked from qt-creator/qt-creator
QmlDesigner: Add container item support in node instances
Change-Id: I30e0d11346b8c63188d052b46656e7ede179e55d Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -55,7 +55,9 @@ enum InformationName
|
||||
IsAnchoredBySibling,
|
||||
HasContent,
|
||||
HasBindingForProperty,
|
||||
ContentTransform
|
||||
ContentTransform,
|
||||
ContentItemTransform,
|
||||
ContentItemBoundingRect
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -887,8 +887,10 @@ static QVector<InformationContainer> createInformationVector(const QList<ServerN
|
||||
informationVector.append(InformationContainer(instance.instanceId(), SceneTransform, instance.sceneTransform()));
|
||||
informationVector.append(InformationContainer(instance.instanceId(), Size, instance.size()));
|
||||
informationVector.append(InformationContainer(instance.instanceId(), BoundingRect, instance.boundingRect()));
|
||||
informationVector.append(InformationContainer(instance.instanceId(), ContentItemBoundingRect, instance.contentItemBoundingRect()));
|
||||
informationVector.append(InformationContainer(instance.instanceId(), Transform, instance.transform()));
|
||||
informationVector.append(InformationContainer(instance.instanceId(), ContentTransform, instance.contentTransform()));
|
||||
informationVector.append(InformationContainer(instance.instanceId(), ContentItemTransform, instance.contentItemTransform()));
|
||||
informationVector.append(InformationContainer(instance.instanceId(), HasContent, instance.hasContent()));
|
||||
informationVector.append(InformationContainer(instance.instanceId(), IsMovable, instance.isMovable()));
|
||||
informationVector.append(InformationContainer(instance.instanceId(), IsResizable, instance.isResizable()));
|
||||
|
@@ -255,6 +255,11 @@ QTransform ObjectNodeInstance::customTransform() const
|
||||
return QTransform();
|
||||
}
|
||||
|
||||
QTransform ObjectNodeInstance::contentItemTransform() const
|
||||
{
|
||||
return QTransform();
|
||||
}
|
||||
|
||||
QTransform ObjectNodeInstance::sceneTransform() const
|
||||
{
|
||||
return QTransform();
|
||||
@@ -1064,6 +1069,11 @@ QObject *ObjectNodeInstance::object() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
QQuickItem *ObjectNodeInstance::contentItem() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ObjectNodeInstance::hasContent() const
|
||||
{
|
||||
return false;
|
||||
@@ -1210,7 +1220,12 @@ ObjectNodeInstance::Pointer ObjectNodeInstance::parentInstance() const
|
||||
|
||||
QRectF ObjectNodeInstance::boundingRect() const
|
||||
{
|
||||
return QRect();
|
||||
return QRectF();
|
||||
}
|
||||
|
||||
QRectF ObjectNodeInstance::contentItemBoundingBox() const
|
||||
{
|
||||
return QRectF();
|
||||
}
|
||||
|
||||
QPointF ObjectNodeInstance::position() const
|
||||
|
@@ -44,6 +44,7 @@ class QQmlContext;
|
||||
class QQmlEngine;
|
||||
class QQmlProperty;
|
||||
class QQmlAbstractBinding;
|
||||
class QQuickItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -104,12 +105,14 @@ public:
|
||||
virtual bool equalGraphicsItem(QGraphicsItem *item) const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual QRectF contentItemBoundingBox() const;
|
||||
|
||||
virtual QPointF position() const;
|
||||
virtual QSizeF size() const;
|
||||
virtual QTransform transform() const;
|
||||
virtual QTransform contentTransform() const;
|
||||
virtual QTransform customTransform() const;
|
||||
virtual QTransform contentItemTransform() const;
|
||||
virtual QTransform sceneTransform() const;
|
||||
virtual double opacity() const;
|
||||
|
||||
@@ -153,6 +156,7 @@ public:
|
||||
void setResetValue(const PropertyName &propertyName, const QVariant &value);
|
||||
|
||||
QObject *object() const;
|
||||
virtual QQuickItem *contentItem() const;
|
||||
|
||||
virtual bool hasContent() const;
|
||||
virtual bool isResizable() const;
|
||||
|
@@ -56,11 +56,24 @@ QuickItemNodeInstance::~QuickItemNodeInstance()
|
||||
{
|
||||
}
|
||||
|
||||
static bool isContentItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer)
|
||||
{
|
||||
|
||||
return item->parentItem()
|
||||
&& nodeInstanceServer->hasInstanceForObject(item->parentItem())
|
||||
&& nodeInstanceServer->instanceForObject(item->parentItem()).internalInstance()->contentItem() == item;
|
||||
}
|
||||
|
||||
static QTransform transformForItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer)
|
||||
{
|
||||
if (isContentItem(item, nodeInstanceServer))
|
||||
return QTransform();
|
||||
|
||||
QTransform toParentTransform = DesignerSupport::parentTransform(item);
|
||||
if (item->parentItem() && !nodeInstanceServer->hasInstanceForObject(item->parentItem()))
|
||||
if (item->parentItem() && !nodeInstanceServer->hasInstanceForObject(item->parentItem())) {
|
||||
|
||||
return transformForItem(item->parentItem(), nodeInstanceServer) * toParentTransform;
|
||||
}
|
||||
|
||||
return toParentTransform;
|
||||
}
|
||||
@@ -109,6 +122,35 @@ QuickItemNodeInstance::Pointer QuickItemNodeInstance::create(QObject *object)
|
||||
return instance;
|
||||
}
|
||||
|
||||
QQuickItem *QuickItemNodeInstance::contentItem() const
|
||||
{
|
||||
return m_contentItem.data();
|
||||
}
|
||||
|
||||
void QuickItemNodeInstance::doComponentComplete()
|
||||
{
|
||||
GraphicalNodeInstance::doComponentComplete();
|
||||
|
||||
QQmlProperty contentItemProperty(quickItem(), "contentItem", engine());
|
||||
if (contentItemProperty.isValid())
|
||||
m_contentItem = contentItemProperty.read().value<QQuickItem*>();
|
||||
}
|
||||
|
||||
QRectF QuickItemNodeInstance::contentItemBoundingBox() const
|
||||
{
|
||||
if (contentItem()) {
|
||||
QTransform contentItemTransform = DesignerSupport::parentTransform(contentItem());
|
||||
return contentItemTransform.mapRect(contentItem()->boundingRect());
|
||||
}
|
||||
|
||||
return QRectF();
|
||||
}
|
||||
|
||||
QTransform QuickItemNodeInstance::contentItemTransform() const
|
||||
{
|
||||
return DesignerSupport::parentTransform(contentItem());
|
||||
}
|
||||
|
||||
|
||||
bool QuickItemNodeInstance::isQuickItem() const
|
||||
{
|
||||
|
@@ -50,7 +50,12 @@ public:
|
||||
|
||||
static Pointer create(QObject *objectToBeWrapped);
|
||||
|
||||
virtual QQuickItem *contentItem() const;
|
||||
|
||||
QRectF contentItemBoundingBox() const Q_DECL_OVERRIDE;
|
||||
|
||||
QTransform transform() const Q_DECL_OVERRIDE;
|
||||
QTransform contentItemTransform() const Q_DECL_OVERRIDE;
|
||||
|
||||
QObject *parent() const Q_DECL_OVERRIDE;
|
||||
|
||||
@@ -61,6 +66,8 @@ public:
|
||||
bool isMovable() const Q_DECL_OVERRIDE;
|
||||
bool isQuickItem() const Q_DECL_OVERRIDE;
|
||||
|
||||
void doComponentComplete();
|
||||
|
||||
protected:
|
||||
QuickItemNodeInstance(QQuickItem*);
|
||||
QQuickItem *quickItem() const;
|
||||
@@ -68,6 +75,7 @@ protected:
|
||||
void setResizable(bool resizable);
|
||||
|
||||
private: //variables
|
||||
QPointer<QQuickItem> m_contentItem;
|
||||
bool m_isResizable;
|
||||
bool m_isMovable;
|
||||
};
|
||||
|
@@ -88,7 +88,6 @@ QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object
|
||||
QQuickItemPrivate *privateItem = static_cast<QQuickItemPrivate*>(QObjectPrivate::get(quickWindow->contentItem()));
|
||||
|
||||
if (privateItem->window) {
|
||||
qDebug() << "removing from window";
|
||||
if (!privateItem->parentItem)
|
||||
QQuickWindowPrivate::get(privateItem->window)->parentlessItems.remove(quickWindow->contentItem());
|
||||
privateItem->derefWindow();
|
||||
|
@@ -315,6 +315,11 @@ QRectF ServerNodeInstance::boundingRect() const
|
||||
return boundingRect;
|
||||
}
|
||||
|
||||
QRectF ServerNodeInstance::contentItemBoundingRect() const
|
||||
{
|
||||
return m_nodeInstance->contentItemBoundingBox();
|
||||
}
|
||||
|
||||
void ServerNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
|
||||
{
|
||||
m_nodeInstance->setPropertyVariant(name, value);
|
||||
@@ -515,6 +520,11 @@ QTransform ServerNodeInstance::contentTransform() const
|
||||
return m_nodeInstance->contentTransform();
|
||||
}
|
||||
|
||||
QTransform ServerNodeInstance::contentItemTransform() const
|
||||
{
|
||||
return m_nodeInstance->contentItemTransform();
|
||||
}
|
||||
|
||||
double ServerNodeInstance::rotation() const
|
||||
{
|
||||
return m_nodeInstance->rotation();
|
||||
@@ -631,11 +641,6 @@ qint32 ServerNodeInstance::instanceId() const
|
||||
}
|
||||
}
|
||||
|
||||
QObject* ServerNodeInstance::testHandle() const
|
||||
{
|
||||
return internalObject();
|
||||
}
|
||||
|
||||
QList<ServerNodeInstance> ServerNodeInstance::stateInstances() const
|
||||
{
|
||||
return m_nodeInstance->stateInstances();
|
||||
|
@@ -105,12 +105,14 @@ public:
|
||||
bool equalGraphicsItem(QGraphicsItem *item) const;
|
||||
|
||||
QRectF boundingRect() const;
|
||||
QRectF contentItemBoundingRect() const;
|
||||
QPointF position() const;
|
||||
QSizeF size() const;
|
||||
QTransform transform() const;
|
||||
QTransform customTransform() const;
|
||||
QTransform sceneTransform() const;
|
||||
QTransform contentTransform() const;
|
||||
QTransform contentItemTransform() const;
|
||||
double rotation() const;
|
||||
double scale() const;
|
||||
QList<QGraphicsTransform *> transformations() const;
|
||||
@@ -156,7 +158,6 @@ public:
|
||||
QString id() const;
|
||||
qint32 instanceId() const;
|
||||
|
||||
QObject* testHandle() const;
|
||||
QSharedPointer<Internal::ObjectNodeInstance> internalInstance() const;
|
||||
|
||||
QList<ServerNodeInstance> stateInstances() const;
|
||||
|
@@ -91,7 +91,7 @@ void FormEditorItem::updateGeometry()
|
||||
prepareGeometryChange();
|
||||
m_boundingRect = qmlItemNode().instanceBoundingRect().adjusted(0, 0, 1., 1.);
|
||||
m_paintedBoundingRect = qmlItemNode().instancePaintedBoundingRect().united(m_boundingRect);
|
||||
setTransform(qmlItemNode().instanceTransform());
|
||||
setTransform(qmlItemNode().instanceTransformWithContentTransform());
|
||||
setTransform(m_attentionTransform, true);
|
||||
//the property for zValue is called z in QGraphicsObject
|
||||
if (qmlItemNode().instanceValue("z").isValid())
|
||||
@@ -142,7 +142,7 @@ void FormEditorItem::setAttentionScale(double sinusScale)
|
||||
m_attentionTransform.translate(-centerPoint.x(), -centerPoint.y());
|
||||
m_inverseAttentionTransform = m_attentionTransform.inverted();
|
||||
prepareGeometryChange();
|
||||
setTransform(qmlItemNode().instanceTransform());
|
||||
setTransform(qmlItemNode().instanceTransformWithContentTransform());
|
||||
setTransform(m_attentionTransform, true);
|
||||
} else {
|
||||
m_attentionTransform.reset();
|
||||
@@ -391,7 +391,7 @@ SnapLineMap FormEditorItem::rightSnappingOffsets() const
|
||||
void FormEditorItem::updateSnappingLines(const QList<FormEditorItem*> &exceptionList,
|
||||
FormEditorItem *transformationSpaceItem)
|
||||
{
|
||||
m_snappingLineCreator.update(exceptionList, transformationSpaceItem);
|
||||
m_snappingLineCreator.update(exceptionList, transformationSpaceItem, this);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -116,8 +116,9 @@ void MoveManipulator::updateHashes()
|
||||
// foreach (FormEditorItem* item, m_itemList)
|
||||
// m_beginItemRectHash[item] = item->mapRectToParent(item->qmlItemNode().instanceBoundingRect());
|
||||
|
||||
QTransform fromSceneToContentItemTransform = m_snapper.containerFormEditorItem()->qmlItemNode().instanceSceneContentItemTransform().inverted();
|
||||
foreach (FormEditorItem* item, m_itemList) {
|
||||
QPointF positionInParentSpace = m_snapper.containerFormEditorItem()->mapFromScene(m_beginPositionInSceneSpaceHash.value(item));
|
||||
QPointF positionInParentSpace = fromSceneToContentItemTransform.map(m_beginPositionInSceneSpaceHash.value(item));
|
||||
m_beginItemRectHash[item].translate(positionInParentSpace - m_beginPositionHash.value(item));
|
||||
m_beginPositionHash.insert(item, positionInParentSpace);
|
||||
}
|
||||
@@ -147,17 +148,19 @@ void MoveManipulator::begin(const QPointF &beginPoint)
|
||||
m_beginItemRectHash.insert(item, m_snapper.containerFormEditorItem()->mapRectFromItem(item, item->qmlItemNode().instanceBoundingRect()));
|
||||
}
|
||||
|
||||
QTransform fromContentItemToSceneTransform = m_snapper.containerFormEditorItem()->qmlItemNode().instanceSceneContentItemTransform();
|
||||
foreach (FormEditorItem* item, m_itemList) {
|
||||
if (item && item->qmlItemNode().isValid()) {
|
||||
QPointF positionInParentSpace(item->qmlItemNode().instancePosition());
|
||||
QPointF positionInScenesSpace = m_snapper.containerFormEditorItem()->mapToScene(positionInParentSpace);
|
||||
QPointF positionInScenesSpace = fromContentItemToSceneTransform.map(positionInParentSpace);
|
||||
m_beginPositionInSceneSpaceHash.insert(item, positionInScenesSpace);
|
||||
}
|
||||
}
|
||||
|
||||
QTransform fromSceneToContentItemTransform = m_snapper.containerFormEditorItem()->qmlItemNode().instanceSceneContentItemTransform().inverted();
|
||||
foreach (FormEditorItem* item, m_itemList) {
|
||||
if (item && item->qmlItemNode().isValid()) {
|
||||
QPointF positionInParentSpace = m_snapper.containerFormEditorItem()->mapFromScene(m_beginPositionInSceneSpaceHash.value(item));
|
||||
QPointF positionInParentSpace = fromSceneToContentItemTransform.map(m_beginPositionInSceneSpaceHash.value(item));
|
||||
m_beginPositionHash.insert(item, positionInParentSpace);
|
||||
|
||||
QmlAnchors anchors(item->qmlItemNode().anchors());
|
||||
@@ -270,8 +273,9 @@ void MoveManipulator::update(const QPointF& updatePoint, Snapper::Snapping useSn
|
||||
if (m_itemList.isEmpty()) {
|
||||
return;
|
||||
} else {
|
||||
QPointF updatePointInContainerSpace(m_snapper.containerFormEditorItem()->mapFromScene(updatePoint));
|
||||
QPointF beginPointInContainerSpace(m_snapper.containerFormEditorItem()->mapFromScene(m_beginPoint));
|
||||
QTransform fromSceneToContentItemTransform = m_snapper.containerFormEditorItem()->qmlItemNode().instanceSceneContentItemTransform().inverted();
|
||||
QPointF updatePointInContainerSpace(fromSceneToContentItemTransform.map(updatePoint));
|
||||
QPointF beginPointInContainerSpace(fromSceneToContentItemTransform.map(m_beginPoint));
|
||||
|
||||
QPointF offsetVector(updatePointInContainerSpace - beginPointInContainerSpace);
|
||||
|
||||
|
@@ -77,8 +77,9 @@ void ResizeManipulator::begin(const QPointF &/*beginPoint*/)
|
||||
if (m_resizeController.isValid()) {
|
||||
m_isActive = true;
|
||||
m_beginBoundingRect = m_resizeController.formEditorItem()->qmlItemNode().instanceBoundingRect();
|
||||
m_beginToSceneTransform = m_resizeController.formEditorItem()->qmlItemNode().instanceSceneTransform();
|
||||
m_beginFromSceneTransform = m_beginToSceneTransform.inverted();
|
||||
m_beginFromContentItemToSceneTransform = m_resizeController.formEditorItem()->qmlItemNode().instanceSceneContentItemTransform();
|
||||
m_beginFromSceneToContentItemTransform = m_beginFromContentItemToSceneTransform.inverted();
|
||||
m_beginFromItemToSceneTransform = m_resizeController.formEditorItem()->qmlItemNode().instanceSceneTransform();
|
||||
m_beginToParentTransform = m_resizeController.formEditorItem()->qmlItemNode().instanceTransform();
|
||||
m_rewriterTransaction = m_view->beginRewriterTransaction();
|
||||
m_snapper.updateSnappingLines(m_resizeController.formEditorItem());
|
||||
@@ -116,7 +117,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
|
||||
if (!containerItem)
|
||||
return;
|
||||
|
||||
QPointF updatePointInLocalSpace = m_beginFromSceneTransform.map(updatePoint);
|
||||
QPointF updatePointInLocalSpace = m_beginFromSceneToContentItemTransform.map(updatePoint);
|
||||
QmlAnchors anchors(formEditorItem->qmlItemNode().anchors());
|
||||
|
||||
QRectF boundingRect(m_beginBoundingRect);
|
||||
@@ -372,7 +373,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
|
||||
if (snap)
|
||||
m_graphicsLineList = m_snapper.generateSnappingLines(boundingRect,
|
||||
m_layerItem.data(),
|
||||
m_beginToSceneTransform);
|
||||
m_beginFromItemToSceneTransform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,8 +485,9 @@ void ResizeManipulator::clear()
|
||||
|
||||
deleteSnapLines();
|
||||
m_beginBoundingRect = QRectF();
|
||||
m_beginFromSceneTransform = QTransform();
|
||||
m_beginToSceneTransform = QTransform();
|
||||
m_beginFromSceneToContentItemTransform = QTransform();
|
||||
m_beginFromContentItemToSceneTransform = QTransform();
|
||||
m_beginFromItemToSceneTransform = QTransform();
|
||||
m_beginToParentTransform = QTransform();
|
||||
m_beginTopMargin = 0.0;
|
||||
m_beginLeftMargin = 0.0;
|
||||
|
@@ -72,8 +72,9 @@ private:
|
||||
QWeakPointer<FormEditorView> m_view;
|
||||
QList<QGraphicsItem*> m_graphicsLineList;
|
||||
ResizeController m_resizeController; // hold the controller so that the handle cant be deleted
|
||||
QTransform m_beginFromSceneTransform;
|
||||
QTransform m_beginToSceneTransform;
|
||||
QTransform m_beginFromSceneToContentItemTransform;
|
||||
QTransform m_beginFromContentItemToSceneTransform;
|
||||
QTransform m_beginFromItemToSceneTransform;
|
||||
QTransform m_beginToParentTransform;
|
||||
QRectF m_beginBoundingRect;
|
||||
QPointF m_beginBottomRightPoint;
|
||||
|
@@ -32,6 +32,8 @@
|
||||
#include "formeditoritem.h"
|
||||
#include "formeditorview.h"
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
SnappingLineCreator::SnappingLineCreator(FormEditorItem *formEditorItem)
|
||||
@@ -117,7 +119,7 @@ void SnappingLineCreator::generateLines(const QList<FormEditorItem*> &exceptionL
|
||||
}
|
||||
}
|
||||
|
||||
void SnappingLineCreator::setContainerPadding(double containerPadding)
|
||||
void SnappingLineCreator::setContainerPaddingByGloablPadding(double containerPadding)
|
||||
{
|
||||
m_topPadding = containerPadding;
|
||||
m_bottomPadding = containerPadding;
|
||||
@@ -125,6 +127,14 @@ void SnappingLineCreator::setContainerPadding(double containerPadding)
|
||||
m_rightPadding = containerPadding;
|
||||
}
|
||||
|
||||
void SnappingLineCreator::setContainerPaddingByContentItem(const QRectF &contentRectangle, const QRectF &itemBoundingRectangle)
|
||||
{
|
||||
m_topPadding = contentRectangle.top() - itemBoundingRectangle.top();
|
||||
m_bottomPadding = itemBoundingRectangle.bottom() - contentRectangle.bottom();
|
||||
m_leftPadding = contentRectangle.left() - itemBoundingRectangle.left();
|
||||
m_rightPadding = itemBoundingRectangle.right() - contentRectangle.right();
|
||||
}
|
||||
|
||||
void SnappingLineCreator::setSpacing(double spacing)
|
||||
{
|
||||
m_topOffset = spacing;
|
||||
@@ -134,10 +144,11 @@ void SnappingLineCreator::setSpacing(double spacing)
|
||||
}
|
||||
|
||||
void SnappingLineCreator::update(const QList<FormEditorItem*> &exceptionList,
|
||||
FormEditorItem *transformationSpaceItem)
|
||||
FormEditorItem *transformationSpaceItem,
|
||||
FormEditorItem *containerFormEditorItem)
|
||||
{
|
||||
clearLines();
|
||||
setContainerPadding(m_formEditorItem->formEditorView()->containerPadding());
|
||||
setContainerPaddingItem(containerFormEditorItem);
|
||||
setSpacing(m_formEditorItem->formEditorView()->spacing());
|
||||
generateLines(exceptionList, transformationSpaceItem);
|
||||
}
|
||||
@@ -192,4 +203,15 @@ SnapLineMap SnappingLineCreator::rightOffsets() const
|
||||
return m_rightOffsetMap;
|
||||
}
|
||||
|
||||
void SnappingLineCreator::setContainerPaddingItem(FormEditorItem *transformationSpaceItem)
|
||||
{
|
||||
QmlItemNode containerItemNode = transformationSpaceItem->qmlItemNode();
|
||||
QRectF contentRect = containerItemNode.instanceContentItemBoundingRect();
|
||||
|
||||
if (contentRect.isValid())
|
||||
setContainerPaddingByContentItem(contentRect, containerItemNode.instanceBoundingRect());
|
||||
else
|
||||
setContainerPaddingByGloablPadding(m_formEditorItem->formEditorView()->containerPadding());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -48,7 +48,8 @@ public:
|
||||
SnappingLineCreator(FormEditorItem *formEditorItem);
|
||||
|
||||
void update(const QList<FormEditorItem*> &exceptionList,
|
||||
FormEditorItem *transformationSpaceItem);
|
||||
FormEditorItem *transformationSpaceItem,
|
||||
FormEditorItem *containerFormEditorItem);
|
||||
|
||||
|
||||
SnapLineMap topLines() const;
|
||||
@@ -63,7 +64,9 @@ public:
|
||||
SnapLineMap leftOffsets() const;
|
||||
SnapLineMap rightOffsets() const;
|
||||
|
||||
void setContainerPadding(double containerPadding);
|
||||
void setContainerPaddingItem(FormEditorItem *transformationSpaceItem);
|
||||
void setContainerPaddingByGloablPadding(double containerPadding);
|
||||
void setContainerPaddingByContentItem(const QRectF &contentRectangle, const QRectF &itemBoundingRectangle);
|
||||
void setSpacing(double spacing);
|
||||
|
||||
protected:
|
||||
|
@@ -59,6 +59,7 @@ public:
|
||||
bool isValid() const;
|
||||
void makeInvalid();
|
||||
QRectF boundingRect() const;
|
||||
QRectF contentItemBoundingRect() const;
|
||||
bool hasContent() const;
|
||||
bool isAnchoredBySibling() const;
|
||||
bool isAnchoredByChildren() const;
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
bool isResizable() const;
|
||||
QTransform transform() const;
|
||||
QTransform contentTransform() const;
|
||||
QTransform contentItemTransform() const;
|
||||
QTransform sceneTransform() const;
|
||||
bool isInLayoutable() const;
|
||||
QPointF position() const;
|
||||
@@ -93,8 +95,10 @@ protected:
|
||||
|
||||
InformationName setInformationSize(const QSizeF &size);
|
||||
InformationName setInformationBoundingRect(const QRectF &rectangle);
|
||||
InformationName setInformationContentItemBoundingRect(const QRectF &rectangle);
|
||||
InformationName setInformationTransform(const QTransform &transform);
|
||||
InformationName setInformationContentTransform(const QTransform &contentTransform);
|
||||
InformationName setInformationContentItemTransform(const QTransform &contentItemTransform);
|
||||
InformationName setInformationPenWith(int penWidth);
|
||||
InformationName setInformationPosition(const QPointF &position);
|
||||
InformationName setInformationIsInLayoutable(bool isInLayoutable);
|
||||
|
@@ -53,6 +53,8 @@ public:
|
||||
bool isValid() const;
|
||||
bool isRootNode() const;
|
||||
|
||||
static bool isItemOrWindow(const ModelNode &modelNode);
|
||||
|
||||
QmlModelStateGroup states() const;
|
||||
QList<QmlItemNode> children() const;
|
||||
QList<QmlObjectNode> resources() const;
|
||||
@@ -75,8 +77,12 @@ public:
|
||||
|
||||
QRectF instanceBoundingRect() const;
|
||||
QRectF instancePaintedBoundingRect() const;
|
||||
QRectF instanceContentItemBoundingRect() const;
|
||||
QTransform instanceTransform() const;
|
||||
QTransform instanceTransformWithContentTransform() const;
|
||||
QTransform instanceTransformWithContentItemTransform() const;
|
||||
QTransform instanceSceneTransform() const;
|
||||
QTransform instanceSceneContentItemTransform() const;
|
||||
QPointF instanceScenePosition() const;
|
||||
QPointF instancePosition() const;
|
||||
QSizeF instanceSize() const;
|
||||
|
@@ -50,8 +50,10 @@ public:
|
||||
|
||||
bool hasNodeParent() const;
|
||||
bool hasInstanceParent() const;
|
||||
bool hasInstanceParentItem() const;
|
||||
void setParentProperty(const NodeAbstractProperty &parentProeprty);
|
||||
QmlObjectNode instanceParent() const;
|
||||
QmlItemNode instanceParentItem() const;
|
||||
|
||||
void setId(const QString &id);
|
||||
QString id() const;
|
||||
@@ -105,6 +107,7 @@ public:
|
||||
protected:
|
||||
NodeInstance nodeInstance() const;
|
||||
QmlObjectNode nodeForInstance(const NodeInstance &instance) const;
|
||||
QmlItemNode itemForInstance(const NodeInstance &instance) const;
|
||||
|
||||
protected:
|
||||
QList<QmlModelState> allDefinedStates() const;
|
||||
|
@@ -53,10 +53,12 @@ public:
|
||||
qint32 parentInstanceId;
|
||||
ModelNode modelNode;
|
||||
QRectF boundingRect;
|
||||
QRectF contentItemBoundingRect;
|
||||
QPointF position;
|
||||
QSizeF size;
|
||||
QTransform transform;
|
||||
QTransform contentTransform;
|
||||
QTransform contentItemTransform;
|
||||
QTransform sceneTransform;
|
||||
int penWidth;
|
||||
bool isAnchoredBySibling;
|
||||
@@ -144,6 +146,14 @@ QRectF NodeInstance::boundingRect() const
|
||||
return QRectF();
|
||||
}
|
||||
|
||||
QRectF NodeInstance::contentItemBoundingRect() const
|
||||
{
|
||||
if (isValid())
|
||||
return d->contentItemBoundingRect;
|
||||
else
|
||||
return QRectF();
|
||||
}
|
||||
|
||||
bool NodeInstance::hasContent() const
|
||||
{
|
||||
if (isValid())
|
||||
@@ -199,6 +209,14 @@ QTransform NodeInstance::contentTransform() const
|
||||
else
|
||||
return QTransform();
|
||||
}
|
||||
|
||||
QTransform NodeInstance::contentItemTransform() const
|
||||
{
|
||||
if (isValid())
|
||||
return d->contentItemTransform;
|
||||
else
|
||||
return QTransform();
|
||||
}
|
||||
QTransform NodeInstance::sceneTransform() const
|
||||
{
|
||||
if (isValid())
|
||||
@@ -333,6 +351,16 @@ InformationName NodeInstance::setInformationBoundingRect(const QRectF &rectangle
|
||||
return NoInformationChange;
|
||||
}
|
||||
|
||||
InformationName NodeInstance::setInformationContentItemBoundingRect(const QRectF &rectangle)
|
||||
{
|
||||
if (d->contentItemBoundingRect != rectangle) {
|
||||
d->contentItemBoundingRect = rectangle;
|
||||
return ContentItemBoundingRect;
|
||||
}
|
||||
|
||||
return NoInformationChange;
|
||||
}
|
||||
|
||||
InformationName NodeInstance::setInformationTransform(const QTransform &transform)
|
||||
{
|
||||
if (d->transform != transform) {
|
||||
@@ -353,6 +381,16 @@ InformationName NodeInstance::setInformationContentTransform(const QTransform &c
|
||||
return NoInformationChange;
|
||||
}
|
||||
|
||||
InformationName NodeInstance::setInformationContentItemTransform(const QTransform &contentItemTransform)
|
||||
{
|
||||
if (d->contentItemTransform != contentItemTransform) {
|
||||
d->contentItemTransform = contentItemTransform;
|
||||
return ContentItemTransform;
|
||||
}
|
||||
|
||||
return NoInformationChange;
|
||||
}
|
||||
|
||||
InformationName NodeInstance::setInformationPenWith(int penWidth)
|
||||
{
|
||||
if (d->penWidth != penWidth) {
|
||||
@@ -489,8 +527,10 @@ InformationName NodeInstance::setInformation(InformationName name, const QVarian
|
||||
switch (name) {
|
||||
case Size: return setInformationSize(information.toSizeF());
|
||||
case BoundingRect: return setInformationBoundingRect(information.toRectF());
|
||||
case ContentItemBoundingRect: setInformationContentItemBoundingRect(information.toRectF());
|
||||
case Transform: return setInformationTransform(information.value<QTransform>());
|
||||
case ContentTransform: return setInformationContentTransform(information.value<QTransform>());
|
||||
case ContentItemTransform: return setInformationContentItemTransform(information.value<QTransform>());
|
||||
case PenWidth: return setInformationPenWith(information.toInt());
|
||||
case Position: return setInformationPosition(information.toPointF());
|
||||
case IsInLayoutable: return setInformationIsInLayoutable(information.toBool());
|
||||
|
@@ -37,9 +37,7 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
namespace {
|
||||
|
||||
bool isItemOrWindow(const ModelNode &modelNode)
|
||||
bool QmlItemNode::isItemOrWindow(const ModelNode &modelNode)
|
||||
{
|
||||
if (modelNode.metaInfo().isSubclassOf("QtQuick.Item", -1, -1))
|
||||
return true;
|
||||
@@ -50,8 +48,6 @@ bool isItemOrWindow(const ModelNode &modelNode)
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool QmlItemNode::isValid() const
|
||||
{
|
||||
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isValid() && isItemOrWindow(modelNode());
|
||||
@@ -239,16 +235,36 @@ QRectF QmlItemNode::instancePaintedBoundingRect() const
|
||||
return nodeInstance().boundingRect();
|
||||
}
|
||||
|
||||
QRectF QmlItemNode::instanceContentItemBoundingRect() const
|
||||
{
|
||||
return nodeInstance().contentItemBoundingRect();
|
||||
}
|
||||
|
||||
QTransform QmlItemNode::instanceTransform() const
|
||||
{
|
||||
return nodeInstance().transform();
|
||||
}
|
||||
|
||||
QTransform QmlItemNode::instanceTransformWithContentTransform() const
|
||||
{
|
||||
return nodeInstance().transform() * nodeInstance().contentTransform();
|
||||
}
|
||||
|
||||
QTransform QmlItemNode::instanceTransformWithContentItemTransform() const
|
||||
{
|
||||
return nodeInstance().transform() * nodeInstance().contentItemTransform();
|
||||
}
|
||||
|
||||
QTransform QmlItemNode::instanceSceneTransform() const
|
||||
{
|
||||
return nodeInstance().sceneTransform();
|
||||
}
|
||||
|
||||
QTransform QmlItemNode::instanceSceneContentItemTransform() const
|
||||
{
|
||||
return nodeInstance().sceneTransform() * nodeInstance().contentItemTransform();
|
||||
}
|
||||
|
||||
QPointF QmlItemNode::instanceScenePosition() const
|
||||
{
|
||||
QmlItemNode parentNode = instanceParent().toQmlItemNode();
|
||||
|
@@ -444,6 +444,11 @@ QmlObjectNode QmlObjectNode::nodeForInstance(const NodeInstance &instance) const
|
||||
return QmlObjectNode(ModelNode(instance.modelNode(), qmlModelView()));
|
||||
}
|
||||
|
||||
QmlItemNode QmlObjectNode::itemForInstance(const NodeInstance &instance) const
|
||||
{
|
||||
return QmlItemNode(ModelNode(instance.modelNode(), qmlModelView()));
|
||||
}
|
||||
|
||||
bool QmlObjectNode::hasNodeParent() const
|
||||
{
|
||||
return modelNode().hasParentProperty();
|
||||
@@ -454,6 +459,13 @@ bool QmlObjectNode::hasInstanceParent() const
|
||||
return nodeInstance().parentId() >= 0 && qmlModelView()->nodeInstanceView()->hasInstanceForId(nodeInstance().parentId());
|
||||
}
|
||||
|
||||
bool QmlObjectNode::hasInstanceParentItem() const
|
||||
{
|
||||
return nodeInstance().parentId() >= 0
|
||||
&& qmlModelView()->nodeInstanceView()->hasInstanceForId(nodeInstance().parentId())
|
||||
&& QmlItemNode::isItemOrWindow(qmlModelView()->modelNodeForInternalId(nodeInstance().parentId()));
|
||||
}
|
||||
|
||||
|
||||
void QmlObjectNode::setParentProperty(const NodeAbstractProperty &parentProeprty)
|
||||
{
|
||||
@@ -468,6 +480,14 @@ QmlObjectNode QmlObjectNode::instanceParent() const
|
||||
return QmlObjectNode();
|
||||
}
|
||||
|
||||
QmlItemNode QmlObjectNode::instanceParentItem() const
|
||||
{
|
||||
if (hasInstanceParentItem())
|
||||
return itemForInstance(qmlModelView()->nodeInstanceView()->instanceForId(nodeInstance().parentId()));
|
||||
|
||||
return QmlItemNode();
|
||||
}
|
||||
|
||||
void QmlObjectNode::setId(const QString &id)
|
||||
{
|
||||
modelNode().setId(id);
|
||||
|
Reference in New Issue
Block a user