Merged in BojanKverh/valentina-issue24/feature (pull request #134)
Fixed issue #24. New feature: Label on detail. --HG-- branch : develop
This commit is contained in:
commit
da91ed974a
|
@ -59,6 +59,7 @@ VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent)
|
||||||
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
|
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
|
||||||
SetSize(MIN_W, m_iMinH);
|
SetSize(MIN_W, m_iMinH);
|
||||||
setZValue(TOP_Z);
|
setZValue(TOP_Z);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -164,6 +165,16 @@ void VTextGraphicsItem::Reset()
|
||||||
setZValue(TOP_Z);
|
setZValue(TOP_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief VTextGraphicsItem::IsIdle checks if the item is in normal mode.
|
||||||
|
* @return true, if item is in normal mode and false otherwise.
|
||||||
|
*/
|
||||||
|
bool VTextGraphicsItem::IsIdle() const
|
||||||
|
{
|
||||||
|
return m_eMode == mNormal;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VTextGraphicsItem::AddLine adds a line of text to the label list. If necessary, it also resizes the
|
* @brief VTextGraphicsItem::AddLine adds a line of text to the label list. If necessary, it also resizes the
|
||||||
|
@ -355,6 +366,10 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
|
||||||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||||
|
}
|
||||||
// raise the label and redraw it
|
// raise the label and redraw it
|
||||||
setZValue(TOP_Z + 1);
|
setZValue(TOP_Z + 1);
|
||||||
UpdateBox();
|
UpdateBox();
|
||||||
|
@ -436,7 +451,7 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
|
||||||
if (pME->button() == Qt::LeftButton)
|
if (pME->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
// restore the cursor
|
// restore the cursor
|
||||||
if (m_eMode == mMove)
|
if (m_eMode == mMove || m_eMode == mRotate)
|
||||||
{
|
{
|
||||||
RestoreOverrideCursor(cursorArrowCloseHand);
|
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||||
}
|
}
|
||||||
|
@ -488,6 +503,37 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief VTextGraphicsItem::hoverMoveEvent checks if cursor has to be changed
|
||||||
|
* @param pHE pointer to the scene hover event
|
||||||
|
*/
|
||||||
|
void VTextGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent* pHE)
|
||||||
|
{
|
||||||
|
if (m_eMode == mMove || m_eMode == mResize)
|
||||||
|
{
|
||||||
|
if (m_rectResize.contains(pHE->pos()) == true)
|
||||||
|
{
|
||||||
|
SetOverrideCursor(Qt::SizeFDiagCursor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RestoreOverrideCursor(Qt::SizeFDiagCursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief VTextGraphicsItem::hoverLeaveEvent tries to restore normal mouse cursor
|
||||||
|
* @param pHE not used
|
||||||
|
*/
|
||||||
|
void VTextGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE)
|
||||||
|
{
|
||||||
|
Q_UNUSED(pHE);
|
||||||
|
RestoreOverrideCursor(Qt::SizeFDiagCursor);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VTextGraphicsItem::UpdateBox redraws the label content
|
* @brief VTextGraphicsItem::UpdateBox redraws the label content
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
bool IsIdle() const;
|
||||||
|
|
||||||
int GetFontSize() const;
|
int GetFontSize() const;
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
@ -75,6 +76,8 @@ protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent* pME);
|
void mousePressEvent(QGraphicsSceneMouseEvent* pME);
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* pME);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent* pME);
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME);
|
||||||
|
void hoverMoveEvent(QGraphicsSceneHoverEvent* pHE);
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE);
|
||||||
void UpdateBox();
|
void UpdateBox();
|
||||||
void UpdateFont();
|
void UpdateFont();
|
||||||
|
|
||||||
|
|
|
@ -331,6 +331,22 @@ void VToolDetail::FullUpdateFromGuiOk(int result)
|
||||||
dialog = nullptr;
|
dialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief VToolDetail::paint draws a bounding box around detail, if one of its text items is not idle.
|
||||||
|
*/
|
||||||
|
void VToolDetail::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
if (dataLabel->IsIdle() == false || patternInfo->IsIdle() == false)
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
painter->setPen(QPen(Qt::black, 3, Qt::DashLine));
|
||||||
|
painter->drawRect(boundingRect().adjusted(1, 1, -1, -1));
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
VNoBrushScalePathItem::paint(painter, option, widget);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief AddToFile add tag with informations about tool into file.
|
* @brief AddToFile add tag with informations about tool into file.
|
||||||
|
|
|
@ -96,6 +96,8 @@ public slots:
|
||||||
virtual void ResetChildren(QGraphicsItem* pItem);
|
virtual void ResetChildren(QGraphicsItem* pItem);
|
||||||
virtual void UpdateAll();
|
virtual void UpdateAll();
|
||||||
protected:
|
protected:
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget) Q_DECL_OVERRIDE;
|
||||||
virtual void AddToFile () Q_DECL_OVERRIDE;
|
virtual void AddToFile () Q_DECL_OVERRIDE;
|
||||||
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
|
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
|
||||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user