Commit 37947336 authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Marco Bubke

QmlDesigner.formEditor: fix for delegates

Hide the items which are part of delegates.

Change-Id: I3c27210fd2bf8618c69e861d952a14c6f7e3be6a
Reviewed-on: http://codereview.qt.nokia.com/1442Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarMarco Bubke <marco.bubke@nokia.com>
parent 219ef23c
......@@ -65,7 +65,8 @@ FormEditorItem::FormEditorItem(const QmlItemNode &qmlItemNode, FormEditorScene*
m_qmlItemNode(qmlItemNode),
m_borderWidth(1.0),
m_highlightBoundingRect(false),
m_isContentVisible(true)
m_isContentVisible(true),
m_isFormEditorVisible(true)
{
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
setup();
......@@ -195,6 +196,17 @@ bool FormEditorItem::isContentVisible() const
return m_isContentVisible;
}
bool FormEditorItem::isFormEditorVisible() const
{
return m_isFormEditorVisible;
}
void FormEditorItem::setFormEditorVisible(bool isVisible)
{
m_isFormEditorVisible = isVisible;
setVisible(isVisible);
}
FormEditorItem::~FormEditorItem()
{
scene()->removeItemFromHash(this);
......
......@@ -106,6 +106,9 @@ public:
void setContentVisible(bool visible);
bool isContentVisible() const;
bool isFormEditorVisible() const;
void setFormEditorVisible(bool isVisible);
protected:
AbstractFormEditorTool* tool() const;
void paintBoundingRect(QPainter *painter) const;
......@@ -129,6 +132,7 @@ private: // variables
double m_borderWidth;
bool m_highlightBoundingRect;
bool m_isContentVisible;
bool m_isFormEditorVisible;
};
......
......@@ -131,6 +131,41 @@ void FormEditorView::setupFormEditorItemTree(const QmlItemNode &qmlItemNode)
setupFormEditorItemTree(nextNode.toQmlItemNode());
}
void FormEditorView::removeNodeFromScene(const QmlItemNode &qmlItemNode)
{
if (qmlItemNode.isValid()) {
FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode);
QList<QmlItemNode> nodeList;
nodeList.append(qmlItemNode.allSubModelNodes());
nodeList.append(qmlItemNode);
QList<FormEditorItem*> removedItemList;
removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
m_currentTool->itemsAboutToRemoved(removedItemList);
qDeleteAll(removedItemList);
}
}
void FormEditorView::hideNodeFromScene(const QmlItemNode &qmlItemNode)
{
if (qmlItemNode.isValid()) {
FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode);
QList<QmlItemNode> nodeList;
nodeList.append(qmlItemNode.allSubModelNodes());
nodeList.append(qmlItemNode);
QList<FormEditorItem*> removedItemList;
removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
m_currentTool->itemsAboutToRemoved(removedItemList);
item->setFormEditorVisible(false);
}
}
void FormEditorView::nodeCreated(const ModelNode &createdNode)
{
QmlModelView::nodeCreated(createdNode);
......@@ -164,20 +199,7 @@ void FormEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode)
{
QmlItemNode qmlItemNode(removedNode);
if (qmlItemNode.isValid()) {
FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode);
QList<QmlItemNode> nodeList;
nodeList.append(qmlItemNode.allSubModelNodes());
nodeList.append(qmlItemNode);
QList<FormEditorItem*> removedItemList;
removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
m_currentTool->itemsAboutToRemoved(removedItemList);
delete item;
}
removeNodeFromScene(qmlItemNode);
QmlModelView::nodeAboutToBeRemoved(removedNode);
}
......@@ -227,8 +249,23 @@ void FormEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& p
QmlModelView::propertiesAboutToBeRemoved(propertyList);
}
static inline bool hasNodeSourceParent(const ModelNode &node)
{
if (node.parentProperty().isValid() && node.parentProperty().parentModelNode().isValid()) {
ModelNode parent = node.parentProperty().parentModelNode();
if (parent.nodeSourceType() != ModelNode::NodeWithoutSource)
return true;
return hasNodeSourceParent(parent);
}
return false;
}
void FormEditorView::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange)
{
if (hasNodeSourceParent(node))
hideNodeFromScene(node);
QmlModelView::nodeReparented(node, newPropertyParent, oldPropertyParent, propertyChange);
}
......@@ -435,7 +472,8 @@ void FormEditorView::auxiliaryDataChanged(const ModelNode &node, const QString &
if (name == "invisible" && m_scene->hasItemForQmlItemNode(QmlItemNode(node))) {
FormEditorItem *item(m_scene->itemForQmlItemNode(QmlItemNode(node)));
bool isInvisible = data.toBool();
item->setVisible(!isInvisible);
if (item->isFormEditorVisible())
item->setVisible(!isInvisible);
ModelNode newNode(node);
if (isInvisible)
newNode.deselectNode();
......
......@@ -137,7 +137,8 @@ protected slots:
private: //functions
void setupFormEditorItemTree(const QmlItemNode &qmlItemNode);
void removeNodeFromScene(const QmlItemNode &qmlItemNode);
void hideNodeFromScene(const QmlItemNode &qmlItemNode);
private: //variables
QWeakPointer<FormEditorWidget> m_formEditorWidget;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment