Added mousePressEvent and changed QApplication::setOverrideCursor to SetOverrideCursor

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2015-12-02 23:07:23 +02:00
parent 75a4acaea7
commit dfa46dc1cd
2 changed files with 19 additions and 3 deletions

View File

@ -392,6 +392,20 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event)
QGraphicsItem::keyReleaseEvent ( event ); QGraphicsItem::keyReleaseEvent ( event );
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolDetail::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
event->accept();
}
}
QGraphicsPathItem::mousePressEvent(event);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief mouseReleaseEvent handle mouse release events. * @brief mouseReleaseEvent handle mouse release events.
@ -402,6 +416,8 @@ void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
{ {
emit ChoosedTool(id, SceneObject::Detail); emit ChoosedTool(id, SceneObject::Detail);
//Disable cursor-arrow-closehand
RestoreOverrideCursor(cursorArrowCloseHand);
} }
QGraphicsItem::mouseReleaseEvent(event); QGraphicsItem::mouseReleaseEvent(event);
} }
@ -410,7 +426,7 @@ void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VToolDetail::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void VToolDetail::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
QApplication::setOverrideCursor(QCursor(cursorArrowOpenHand, 1, 1)); SetOverrideCursor(cursorArrowOpenHand, 1, 1);
} }
////--------------------------------------------------------------------------------------------------------------------- ////---------------------------------------------------------------------------------------------------------------------
@ -418,7 +434,7 @@ void VToolDetail::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
//Disable cursor-arrow-openhand //Disable cursor-arrow-openhand
QApplication::restoreOverrideCursor(); RestoreOverrideCursor(cursorArrowOpenHand);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -93,6 +93,7 @@ protected:
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;
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
@ -100,7 +101,6 @@ protected:
virtual void RemoveReferens() Q_DECL_OVERRIDE; virtual void RemoveReferens() Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE; virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE {} virtual void SetVisualization() Q_DECL_OVERRIDE {}
private: private:
Q_DISABLE_COPY(VToolDetail) Q_DISABLE_COPY(VToolDetail)
/** @brief dialog dialog options. */ /** @brief dialog dialog options. */