Commit 8e5bcfce authored by Marco Bubke's avatar Marco Bubke

Highlight selectable item under the mouse in the formeditor

parent 5a1f1d5e
......@@ -160,6 +160,14 @@ void FormEditorItem::setAttentionHighlight(double value)
update();
}
void FormEditorItem::setHighlightBoundingRect(bool highlight)
{
if (m_highlightBoundingRect != highlight) {
m_highlightBoundingRect = highlight;
update();
}
}
FormEditorItem::~FormEditorItem()
{
scene()->removeItemFromHash(this);
......@@ -202,7 +210,10 @@ void FormEditorItem::paintBoundingRect(QPainter *painter) const
}
break;
case FormEditorScene::NormalMode: {
pen.setColor(Qt::gray);
if (m_highlightBoundingRect)
pen.setColor("#AAAAAA");
else
pen.setColor("#888888");
}
break;
}
......@@ -232,7 +243,7 @@ void FormEditorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
painter->setRenderHint(QPainter::Antialiasing, false);
if (scene()->showBoundingRects())
if (scene()->showBoundingRects() || m_highlightBoundingRect)
paintBoundingRect(painter);
painter->restore();
......
......@@ -96,6 +96,8 @@ public:
FormEditorView *formEditorView() const;
void setHighlightBoundingRect(bool highlight);
protected:
AbstractFormEditorTool* tool() const;
void paintBoundingRect(QPainter *painter) const;
......@@ -118,6 +120,7 @@ private: // variables
QRectF m_boundingRect;
double m_borderWidth;
double m_opacity;
bool m_highlightBoundingRect;
};
......
......@@ -360,6 +360,16 @@ void FormEditorScene::clearFormEditorItems()
}
}
void FormEditorScene::highlightBoundingRect(FormEditorItem *highlighItem)
{
foreach(FormEditorItem *item, allFormEditorItems()) {
if (item == highlighItem)
item->setHighlightBoundingRect(true);
else
item->setHighlightBoundingRect(false);
}
}
void FormEditorScene::setShowBoundingRects(bool show)
{
m_showBoundingRects = show;
......
......@@ -93,6 +93,8 @@ public:
void clearFormEditorItems();
void highlightBoundingRect(FormEditorItem *formEditorItem);
public slots:
void setShowBoundingRects(bool show);
bool showBoundingRects() const;
......
......@@ -134,6 +134,24 @@ void SelectionTool::hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
if (topSelectedItemIsMovable(itemList))
view()->changeToMoveTool();
FormEditorItem *topSelectableItem = 0;
foreach(QGraphicsItem* item, itemList)
{
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem
&& !formEditorItem->qmlItemNode().isRootNode()
&& (formEditorItem->qmlItemNode().hasShowContent() || !m_selectOnlyContentItems))
{
topSelectableItem = formEditorItem;
break;
}
}
scene()->highlightBoundingRect(topSelectableItem);
}
void SelectionTool::mouseReleaseEvent(const QList<QGraphicsItem*> &/*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