|
@@ -80,6 +80,28 @@ void CNodeItem::setYMargin(qreal y)
|
|
|
updateItemsGeometry();
|
|
|
}
|
|
|
|
|
|
+qreal CNodeItem::minWidth() const
|
|
|
+{
|
|
|
+ return m_minWidth;
|
|
|
+}
|
|
|
+
|
|
|
+void CNodeItem::setMinWidth(qreal w)
|
|
|
+{
|
|
|
+ m_minWidth = w;
|
|
|
+ updateItemsGeometry();
|
|
|
+}
|
|
|
+
|
|
|
+qreal CNodeItem::minHeight() const
|
|
|
+{
|
|
|
+ return m_minHeight;
|
|
|
+}
|
|
|
+
|
|
|
+void CNodeItem::setMinHeight(qreal h)
|
|
|
+{
|
|
|
+ m_minHeight = h;
|
|
|
+ updateItemsGeometry();
|
|
|
+}
|
|
|
+
|
|
|
void CNodeItem::connectSignalsAndSlots()
|
|
|
{
|
|
|
connect(m_rectItem->selectAction(), &QAction::triggered, this, &CNodeItem::slotSelect);
|
|
@@ -89,9 +111,12 @@ void CNodeItem::connectSignalsAndSlots()
|
|
|
|
|
|
void CNodeItem::updateItemsGeometry()
|
|
|
{
|
|
|
- QSizeF s = m_textItem->boundingRect().size() + QSizeF(m_xMargin * 2, m_yMargin * 2);
|
|
|
- m_rectItem->setRect(QRectF(m_pos, s));
|
|
|
- m_textItem->setPos(m_pos + QPointF(m_xMargin, m_yMargin));
|
|
|
+ QRectF tr = m_textItem->boundingRect();
|
|
|
+ qreal w = std::max(tr.width() + m_xMargin * 2, m_minWidth);
|
|
|
+ qreal h = std::max(tr.height() + m_yMargin * 2, m_minHeight);
|
|
|
+
|
|
|
+ m_rectItem->setRect(QRectF(m_pos, QSizeF(w, h)));
|
|
|
+ m_textItem->setPos(m_pos + QPointF(m_xMargin, (h - tr.height()) / 2));
|
|
|
}
|
|
|
|
|
|
void CNodeItem::slotSelect()
|