Commit a3310d32 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner.FormEditor: The scene rectangle isn't set anymore

So the scene rectangle is the bounding rectangle of all items.
parent 40eea090
......@@ -46,8 +46,8 @@ FormEditorGraphicsView::FormEditorGraphicsView(QWidget *parent) :
{
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
setResizeAnchor(QGraphicsView::AnchorViewCenter);
// setCacheMode(QGraphicsView::CacheNone);
setCacheMode(QGraphicsView::CacheBackground);
setCacheMode(QGraphicsView::CacheNone);
// setCacheMode(QGraphicsView::CacheBackground);
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
setOptimizationFlags(QGraphicsView::DontSavePainterState);
// setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
......@@ -110,6 +110,16 @@ void FormEditorGraphicsView::keyPressEvent(QKeyEvent *event)
QGraphicsView::keyPressEvent(event);
}
void FormEditorGraphicsView::setRootItemRect(const QRectF &rect)
{
m_rootItemRect = rect;
qDebug() << __FUNCTION__ << m_rootItemRect;
}
QRectF FormEditorGraphicsView::rootItemRect() const
{
return m_rootItemRect;
}
void FormEditorGraphicsView::mouseReleaseEvent(QMouseEvent *event)
{
......@@ -298,11 +308,10 @@ void FormEditorGraphicsView::drawBackground(QPainter *painter, const QRectF &rec
{
painter->save();
painter->setBrushOrigin(0, 0);
painter->fillRect(rect.intersected(sceneRect()), backgroundBrush());
painter->fillRect(rect.intersected(rootItemRect()), backgroundBrush());
// paint rect around editable area
painter->setPen(Qt::black);
QRectF frameRect = sceneRect().adjusted(0, 0, 0, 0);
painter->drawRect(frameRect);
painter->drawRect( rootItemRect());
painter->restore();
}
......
......@@ -46,6 +46,8 @@ public:
explicit FormEditorGraphicsView(QWidget *parent = 0);
void setFeedbackNode(const QmlItemNode &node);
void setRootItemRect(const QRectF &rect);
QRectF rootItemRect() const;
protected:
void drawForeground(QPainter *painter, const QRectF &rect );
......@@ -55,6 +57,8 @@ protected:
void mouseReleaseEvent(QMouseEvent *event);
void leaveEvent(QEvent *);
void keyPressEvent(QKeyEvent *event);
private:
QmlItemNode m_feedbackNode;
QmlObjectNode m_parentNode;
......@@ -72,6 +76,7 @@ private:
bool m_beginHeightHasExpression;
QPoint m_feedbackOriginPoint;
QPixmap m_bubblePixmap;
QRectF m_rootItemRect;
};
} // namespace QmlDesigner
......
......@@ -65,8 +65,6 @@ FormEditorScene::FormEditorScene(FormEditorWidget *view, FormEditorView *editorV
m_paintMode(NormalMode),
m_showBoundingRects(true)
{
setSceneRect(0, 0, 1, 1); // prevent automatic calculation (causing a recursion), right size will be set later
m_manipulatorLayerItem->setZValue(1.0);
m_formLayerItem->setZValue(0.0);
m_formLayerItem->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
......@@ -150,9 +148,6 @@ void FormEditorScene::synchronizeTransformation(const QmlItemNode &qmlItemNode)
item->updateGeometry();
if (qmlItemNode.isRootNode()) {
QRectF sceneRect(qmlItemNode.instanceBoundingRect());
setSceneRect(sceneRect);
formLayerItem()->update();
manipulatorLayerItem()->update();
}
......@@ -198,9 +193,6 @@ FormEditorItem *FormEditorScene::addFormEditorItem(const QmlItemNode &qmlItemNod
m_qmlItemNodeItemHash.insert(qmlItemNode, formEditorItem);
if (qmlItemNode.isRootNode()) {
QRectF sceneRect(qmlItemNode.instanceBoundingRect());
setSceneRect(sceneRect);
formLayerItem()->update();
manipulatorLayerItem()->update();
}
......
......@@ -486,6 +486,9 @@ void FormEditorView::customNotification(const AbstractView *view, const QString
QmlItemNode qmlItemNode(node);
if (qmlItemNode.isValid() && scene()->hasItemForQmlItemNode(qmlItemNode)) {
scene()->synchronizeTransformation(qmlItemNode);
if (qmlItemNode.isRootModelNode())
widget()->setRootItemRect(qmlItemNode.instanceBoundingRect());
itemNodeList.append(scene()->itemForQmlItemNode(qmlItemNode));
}
}
......
......@@ -280,6 +280,16 @@ QString FormEditorWidget::contextHelpId() const
return helpId;
}
void FormEditorWidget::setRootItemRect(const QRectF &rect)
{
m_graphicsView->setRootItemRect(rect);
}
QRectF FormEditorWidget::rootItemRect() const
{
return m_graphicsView->rootItemRect();
}
}
......@@ -74,6 +74,9 @@ public:
QString contextHelpId() const;
void setRootItemRect(const QRectF &rect);
QRectF rootItemRect() const;
protected:
void enterEvent(QEvent *event);
void wheelEvent(QWheelEvent *event);
......
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