Commit 387f906b authored by Marco Bubke's avatar Marco Bubke Committed by Kai Koehne

Fix the reflection of the visible property in the Formeditor

Task-Number: BAUHAUS-449
parent 24829c76
......@@ -61,7 +61,8 @@ FormEditorItem::FormEditorItem(const QmlItemNode &qmlItemNode, FormEditorScene*
m_snappingLineCreator(this),
m_qmlItemNode(qmlItemNode),
m_borderWidth(1.0),
m_highlightBoundingRect(false)
m_highlightBoundingRect(false),
m_isContentVisible(true)
{
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
setup();
......@@ -79,6 +80,8 @@ void FormEditorItem::setup()
if (QGraphicsItem::parentItem() == scene()->formLayerItem())
m_borderWidth = 0.0;
setContentVisible(qmlItemNode().instanceValue("visible").toBool());
setFlag(QGraphicsItem::ItemIsMovable, true);
updateGeometry();
updateVisibilty();
......@@ -171,6 +174,23 @@ void FormEditorItem::setHighlightBoundingRect(bool highlight)
}
}
void FormEditorItem::setContentVisible(bool visible)
{
if (visible == m_isContentVisible)
return;
m_isContentVisible = visible;
update();
}
bool FormEditorItem::isContentVisible() const
{
if (parentItem())
return parentItem()->isContentVisible() && m_isContentVisible;
return m_isContentVisible;
}
FormEditorItem::~FormEditorItem()
{
scene()->removeItemFromHash(this);
......@@ -248,7 +268,8 @@ void FormEditorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
qmlItemNode().paintInstance(painter);
if (isContentVisible())
qmlItemNode().paintInstance(painter);
painter->setRenderHint(QPainter::Antialiasing, false);
......
......@@ -100,6 +100,9 @@ public:
void setHighlightBoundingRect(bool highlight);
void setContentVisible(bool visible);
bool isContentVisible() const;
protected:
AbstractFormEditorTool* tool() const;
void paintBoundingRect(QPainter *painter) const;
......@@ -122,6 +125,7 @@ private: // variables
QRectF m_boundingRect;
double m_borderWidth;
bool m_highlightBoundingRect;
bool m_isContentVisible;
};
......
......@@ -168,6 +168,9 @@ void FormEditorScene::synchronizeOtherProperty(const QmlItemNode &qmlItemNode, c
if (propertyName == "clip")
item->setFlag(QGraphicsItem::ItemClipsChildrenToShape, qmlItemNode.instanceValue("clip").toBool());
if (propertyName == "visible")
item->setContentVisible(qmlItemNode.instanceValue("visible").toBool());
if (item)
item->update();
}
......
......@@ -119,7 +119,6 @@ public:
QVariant property(const QString &name) const;
QVariant defaultValue(const QString &name) const;
bool isVisible() const;
bool isValid() const;
void makeInvalid();
bool hasContent() const;
......@@ -172,9 +171,6 @@ private: // functions
void paintUpdate();
void show();
void hide();
QObject *internalObject() const; // should be not used outside of the nodeinstances!!!!
......
......@@ -38,7 +38,6 @@ namespace Internal {
GraphicsObjectNodeInstance::GraphicsObjectNodeInstance(QGraphicsObject *graphicsObject, bool hasContent)
: ObjectNodeInstance(graphicsObject),
m_isVisible(true),
m_hasContent(hasContent)
{
}
......@@ -54,16 +53,6 @@ bool GraphicsObjectNodeInstance::hasContent() const
return m_hasContent;
}
bool GraphicsObjectNodeInstance::isVisible() const
{
return m_isVisible;
}
void GraphicsObjectNodeInstance::setVisible(bool isVisible)
{
m_isVisible = isVisible;
}
QPointF GraphicsObjectNodeInstance::position() const
{
return graphicsObject()->pos();
......@@ -148,19 +137,11 @@ bool GraphicsObjectNodeInstance::isGraphicsObject() const
void GraphicsObjectNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{
if (name == "visible") {
setVisible(value.toBool());
return;
}
ObjectNodeInstance::setPropertyVariant(name, value);
}
QVariant GraphicsObjectNodeInstance::property(const QString &name) const
{
if (name == "visible")
return isVisible();
return ObjectNodeInstance::property(name);
}
......@@ -187,17 +168,16 @@ void GraphicsObjectNodeInstance::paint(QPainter *painter) const
{
painter->save();
Q_ASSERT(graphicsObject());
if (isVisible()) {
if (hasContent())
graphicsObject()->paint(painter, 0);
foreach(QGraphicsItem *graphicsItem, graphicsObject()->childItems()) {
QGraphicsObject *graphicsObject = qgraphicsitem_cast<QGraphicsObject*>(graphicsItem);
if (graphicsObject && !nodeInstanceView()->hasInstanceForObject(graphicsObject))
paintRecursively(graphicsItem, painter);
}
if (hasContent())
graphicsObject()->paint(painter, 0);
foreach(QGraphicsItem *graphicsItem, graphicsObject()->childItems()) {
QGraphicsObject *graphicsObject = qgraphicsitem_cast<QGraphicsObject*>(graphicsItem);
if (graphicsObject && !nodeInstanceView()->hasInstanceForObject(graphicsObject))
paintRecursively(graphicsItem, painter);
}
painter->restore();
}
......
......@@ -67,9 +67,6 @@ public:
bool equalGraphicsItem(QGraphicsItem *item) const;
bool isVisible() const;
void setVisible(bool isVisible);
void setPropertyVariant(const QString &name, const QVariant &value);
QVariant property(const QString &name) const;
......@@ -82,7 +79,6 @@ protected:
void paintRecursively(QGraphicsItem *graphicsItem, QPainter *painter) const;
static QPair<QGraphicsObject*, bool> createGraphicsObject(const NodeMetaInfo &metaInfo, QDeclarativeContext *context);
private: // variables
bool m_isVisible;
bool m_hasContent;
};
......
......@@ -422,24 +422,6 @@ QVariant NodeInstance::defaultValue(const QString &name) const
return m_nodeInstance->resetValue(name);
}
/*!
\brief Returns if the NodeInstance is visible.
\returns true if the NodeInstance is visible
*/
bool NodeInstance::isVisible() const
{
return m_nodeInstance->isVisible();
}
void NodeInstance::show()
{
m_nodeInstance->setVisible(true);
}
void NodeInstance::hide()
{
m_nodeInstance->setVisible(false);
}
/*!
\brief Returns if the NodeInstance is valid.
\returns true if the NodeInstance is valid
......
......@@ -144,8 +144,7 @@ void NodeInstanceView::modelAboutToBeDetached(Model * model)
*/
void NodeInstanceView::nodeCreated(const ModelNode &createdNode)
{
NodeInstance instance(loadNode(createdNode));
instance.show();
loadNode(createdNode);
}
/*! \brief Notifing the view that a node was created.
......@@ -663,7 +662,6 @@ QRectF NodeInstanceView::sceneRect() const
return QRectF();
}
}
QFileSystemWatcher *NodeInstanceView::fileSystemWatcher()
{
......@@ -702,3 +700,5 @@ void NodeInstanceView::refreshLocalFileProperty(const QString &path)
}
}
}
}
......@@ -725,15 +725,6 @@ int ObjectNodeInstance::penWidth() const
return 0;
}
bool ObjectNodeInstance::isVisible() const
{
return false;
}
void ObjectNodeInstance::setVisible(bool /*isVisible*/)
{
}
static bool metaObjectHasNotPropertyName(NodeInstanceMetaObject *metaObject, const QString &propertyName)
{
for (int i = 0; i < metaObject->count(); i++) {
......
......@@ -144,8 +144,6 @@ public:
virtual QVariant property(const QString &name) const;
virtual void resetProperty(const QString &name);
virtual void refreshProperty(const QString &name);
virtual bool isVisible() const;
virtual void setVisible(bool isVisible);
void createDynamicProperty(const QString &name, const QString &typeName);
void setDeleteHeldInstance(bool deleteInstance);
......
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