Commit 6dce72ff authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Update ContentNotEditableIndicator for movements

Task-number: QTCREATORBUG-10644
Change-Id: I23a02dae01faf703dbf9bd5bd643dc091a947eba
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 00704e34
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include "contentnoteditableindicator.h" #include "contentnoteditableindicator.h"
#include "nodemetainfo.h" #include "nodemetainfo.h"
#include <QSet>
namespace QmlDesigner { namespace QmlDesigner {
ContentNotEditableIndicator::ContentNotEditableIndicator(LayerItem *layerItem) ContentNotEditableIndicator::ContentNotEditableIndicator(LayerItem *layerItem)
...@@ -68,6 +70,24 @@ void ContentNotEditableIndicator::setItems(const QList<FormEditorItem*> &itemLis ...@@ -68,6 +70,24 @@ void ContentNotEditableIndicator::setItems(const QList<FormEditorItem*> &itemLis
addAddiationEntries(itemList); addAddiationEntries(itemList);
} }
void ContentNotEditableIndicator::updateItems(const QList<FormEditorItem *> &itemList)
{
QSet<FormEditorItem*> affectedFormEditorItemItems;
affectedFormEditorItemItems.unite(itemList.toSet());
foreach (FormEditorItem *formEditorItem, itemList)
affectedFormEditorItemItems.unite(formEditorItem->offspringFormEditorItems().toSet());
foreach (const EntryPair &entryPair, m_entryList) {
foreach (FormEditorItem *formEditorItem, affectedFormEditorItemItems) {
if (formEditorItem == entryPair.first) {
QRectF boundingRectangleInSceneSpace = formEditorItem->qmlItemNode().instanceSceneTransform().mapRect(formEditorItem->qmlItemNode().instanceBoundingRect());
entryPair.second->setRect(boundingRectangleInSceneSpace);
entryPair.second->update();
}
}
}
}
void ContentNotEditableIndicator::addAddiationEntries(const QList<FormEditorItem *> &itemList) void ContentNotEditableIndicator::addAddiationEntries(const QList<FormEditorItem *> &itemList)
{ {
foreach (FormEditorItem *formEditorItem, itemList) { foreach (FormEditorItem *formEditorItem, itemList) {
......
...@@ -49,6 +49,7 @@ public: ...@@ -49,6 +49,7 @@ public:
void clear(); void clear();
void setItems(const QList<FormEditorItem*> &itemList); void setItems(const QList<FormEditorItem*> &itemList);
void updateItems(const QList<FormEditorItem*> &itemList);
protected: protected:
void addAddiationEntries(const QList<FormEditorItem*> &itemList); void addAddiationEntries(const QList<FormEditorItem*> &itemList);
......
...@@ -289,6 +289,20 @@ void FormEditorItem::paintComponentContentVisualisation(QPainter *painter, const ...@@ -289,6 +289,20 @@ void FormEditorItem::paintComponentContentVisualisation(QPainter *painter, const
painter->fillRect(clippinRectangle, Qt::BDiagPattern); painter->fillRect(clippinRectangle, Qt::BDiagPattern);
} }
QList<FormEditorItem *> FormEditorItem::offspringFormEditorItemsRecursive(const FormEditorItem *formEditorItem) const
{
QList<FormEditorItem*> formEditorItemList;
foreach (QGraphicsItem *item, formEditorItem->childItems()) {
FormEditorItem *formEditorItem = fromQGraphicsItem(item);
if (formEditorItem) {
formEditorItemList.append(formEditorItem);
}
}
return formEditorItemList;
}
void FormEditorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) void FormEditorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{ {
if (!painter->isActive()) if (!painter->isActive())
...@@ -394,6 +408,11 @@ QList<FormEditorItem*> FormEditorItem::childFormEditorItems() const ...@@ -394,6 +408,11 @@ QList<FormEditorItem*> FormEditorItem::childFormEditorItems() const
return formEditorItemList; return formEditorItemList;
} }
QList<FormEditorItem *> FormEditorItem::offspringFormEditorItems() const
{
return offspringFormEditorItemsRecursive(this);
}
bool FormEditorItem::isContainer() const bool FormEditorItem::isContainer() const
{ {
NodeMetaInfo nodeMetaInfo = qmlItemNode().modelNode().metaInfo(); NodeMetaInfo nodeMetaInfo = qmlItemNode().modelNode().metaInfo();
......
...@@ -86,6 +86,8 @@ public: ...@@ -86,6 +86,8 @@ public:
SnapLineMap rightSnappingOffsets() const; SnapLineMap rightSnappingOffsets() const;
QList<FormEditorItem*> childFormEditorItems() const; QList<FormEditorItem*> childFormEditorItems() const;
QList<FormEditorItem*> offspringFormEditorItems() const;
FormEditorScene *scene() const; FormEditorScene *scene() const;
FormEditorItem *parentItem() const; FormEditorItem *parentItem() const;
...@@ -114,6 +116,7 @@ protected: ...@@ -114,6 +116,7 @@ protected:
void paintBoundingRect(QPainter *painter) const; void paintBoundingRect(QPainter *painter) const;
void paintPlaceHolderForInvisbleItem(QPainter *painter) const; void paintPlaceHolderForInvisbleItem(QPainter *painter) const;
void paintComponentContentVisualisation(QPainter *painter, const QRectF &clippinRectangle) const; void paintComponentContentVisualisation(QPainter *painter, const QRectF &clippinRectangle) const;
QList<FormEditorItem*> offspringFormEditorItemsRecursive(const FormEditorItem *formEditorItem) const;
private: // functions private: // functions
FormEditorItem(const QmlItemNode &qmlItemNode, FormEditorScene* scene); FormEditorItem(const QmlItemNode &qmlItemNode, FormEditorScene* scene);
......
...@@ -401,6 +401,7 @@ void MoveTool::formEditorItemsChanged(const QList<FormEditorItem*> &itemList) ...@@ -401,6 +401,7 @@ void MoveTool::formEditorItemsChanged(const QList<FormEditorItem*> &itemList)
m_resizeIndicator.updateItems(selectedItemList); m_resizeIndicator.updateItems(selectedItemList);
m_anchorIndicator.updateItems(selectedItemList); m_anchorIndicator.updateItems(selectedItemList);
m_bindingIndicator.updateItems(selectedItemList); m_bindingIndicator.updateItems(selectedItemList);
m_contentNotEditableIndicator.updateItems(selectedItemList);
} }
} }
...@@ -271,6 +271,7 @@ void SelectionTool::formEditorItemsChanged(const QList<FormEditorItem*> &itemLis ...@@ -271,6 +271,7 @@ void SelectionTool::formEditorItemsChanged(const QList<FormEditorItem*> &itemLis
m_resizeIndicator.updateItems(selectedItemList); m_resizeIndicator.updateItems(selectedItemList);
m_anchorIndicator.updateItems(selectedItemList); m_anchorIndicator.updateItems(selectedItemList);
m_bindingIndicator.updateItems(selectedItemList); m_bindingIndicator.updateItems(selectedItemList);
m_contentNotEditableIndicator.updateItems(selectedItemList);
} }
void SelectionTool::instancesCompleted(const QList<FormEditorItem*> &/*itemList*/) void SelectionTool::instancesCompleted(const QList<FormEditorItem*> &/*itemList*/)
......
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