Show cursor if item can move.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-19 14:16:00 +03:00
parent 2bdc5f3771
commit 4e1742ded5
16 changed files with 181 additions and 30 deletions

View File

@ -19,5 +19,7 @@
<file>cursor/splinepath_cut_point_cursor.png</file>
<file>cursor/union_cursor.png</file>
<file>cursor/arc_cut_cursor.png</file>
<file>cursor/cursor-arrow-closehand.png</file>
<file>cursor/cursor-arrow-openhand.png</file>
</qresource>
</RCC>

View File

@ -34,7 +34,7 @@ const QString VAbstractSpline::TagName = QStringLiteral("spline");
//---------------------------------------------------------------------------------------------------------------------
VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>()),
sceneType(SceneObject::Unknown)
sceneType(SceneObject::Unknown), isHovered(false)
{
ignoreFullUpdate = true;
}
@ -117,15 +117,17 @@ void VAbstractSpline::SetFactor(qreal factor)
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
* @brief hoverEnterEvent handle hover enter events.
* @param event hover enter event.
*/
// cppcheck-suppress unusedFunction
void VAbstractSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine, Qt::RoundCap));
this->setPath(ToolPath(PathDirection::Show));
isHovered = true;
QGraphicsPathItem::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
@ -139,6 +141,8 @@ void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
this->setPath(ToolPath());
isHovered = false;
QGraphicsPathItem::hoverLeaveEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -64,6 +64,7 @@ protected:
*/
QVector<VControlPointSpline *> controlPoints;
SceneObject sceneType;
bool isHovered;
/**
* @brief RefreshGeometry refresh item on scene.
*/
@ -71,7 +72,7 @@ protected:
virtual void ChangedActivDraw ( const QString &newName );
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
virtual void SetFactor(qreal factor);
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);

View File

@ -279,10 +279,10 @@ void VToolLine::RefreshDataInFile()
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
* @brief hoverEnterEvent handle hover enter events.
* @param event hover enter event.
*/
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, LineStyle(typeLine)));

View File

@ -58,7 +58,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );

View File

@ -185,18 +185,19 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
emit ChoosedTool(id, SceneObject::Point);
}
QGraphicsItem::mouseReleaseEvent(event);
QGraphicsEllipseItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
* @brief hoverEnterEvent handle hover enter events.
* @param event hover enter event.
*/
void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor));
QGraphicsEllipseItem::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
@ -314,5 +315,5 @@ void VToolPoint::keyReleaseEvent(QKeyEvent *event)
default:
break;
}
QGraphicsItem::keyReleaseEvent ( event );
QGraphicsEllipseItem::keyReleaseEvent ( event );
}

View File

@ -65,7 +65,7 @@ protected:
virtual void UpdateNamePosition(qreal mx, qreal my);
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RefreshPointGeometry(const VPointF &point);
void RefreshLine();

View File

@ -215,6 +215,54 @@ void VToolSinglePoint::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(p.y())));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
VToolPoint::hoverEnterEvent(event);
#ifndef QT_NO_CURSOR
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-openhand.png"));
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
#endif
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
VToolPoint::hoverLeaveEvent(event);
//Disable cursor-arrow-openhand
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
#ifndef QT_NO_CURSOR
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-closehand.png"));
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
#endif
}
VToolPoint::mousePressEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
//Disable cursor-arrow-closehand
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
VToolPoint::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setColorLabel change color for label and label line.
@ -233,6 +281,10 @@ void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color)
*/
void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event )
{
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
quint32 ref = _referens; // store referens
_referens = 1; // make available delete pattern piece
if (doc->CountPP() > 1)

View File

@ -61,6 +61,10 @@ protected:
virtual void decrementReferens();
virtual void DeleteTool(bool ask = true);
virtual void SaveDialog(QDomElement &domElement);
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
private:
QString namePP;
QString mPath;

View File

@ -319,8 +319,15 @@ void VToolSpline::SaveDialog(QDomElement &domElement)
*/
void VToolSpline::RefreshGeometry()
{
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
this->setPath(ToolPath());
//this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
if(isHovered)
{
this->setPath(ToolPath(PathDirection::Show));
}
else
{
this->setPath(ToolPath());
}
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
QPointF splinePoint = VAbstractTool::data.GeometricObject<const VPointF *>(spl->GetP1().id())->toQPointF();

View File

@ -358,8 +358,14 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement)
*/
void VToolSplinePath::RefreshGeometry()
{
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
this->setPath(ToolPath());
if(isHovered)
{
this->setPath(ToolPath(PathDirection::Show));
}
else
{
this->setPath(ToolPath());
}
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
for (qint32 i = 1; i<=splPath->Count(); ++i)

View File

@ -82,20 +82,28 @@ void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsIte
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @brief hoverEnterEvent handle hover enter events.
* @param event hover move event.
*/
void VControlPointSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine())));
#ifndef QT_NO_CURSOR
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-openhand.png"));
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
#endif
QGraphicsEllipseItem::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())));
//Disable cursor-arrow-openhand
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
QGraphicsEllipseItem::hoverLeaveEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
@ -116,6 +124,32 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang
return QGraphicsItem::itemChange(change, value);
}
//---------------------------------------------------------------------------------------------------------------------
void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
#ifndef QT_NO_CURSOR
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-closehand.png"));
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
#endif
}
QGraphicsEllipseItem::mousePressEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
//Disable cursor-arrow-closehand
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
QGraphicsEllipseItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshLine refresh line control point.

View File

@ -63,9 +63,11 @@ protected:
/** @brief controlLine pointer to line control point. */
QGraphicsLineItem *controlLine;
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
private:
Q_DISABLE_COPY(VControlPointSpline)
/** @brief indexSpline index spline in list.. */

View File

@ -97,13 +97,18 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
* @brief hoverEnterEvent handle hover enter events.
* @param event hover enter event.
*/
void VGraphicsSimpleTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setBrush(Qt::green);
#ifndef QT_NO_CURSOR
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-openhand.png"));
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
#endif
QGraphicsSimpleTextItem::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
@ -115,6 +120,12 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setBrush(Qt::black);
//Disable cursor-arrow-openhand
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
QGraphicsSimpleTextItem::hoverLeaveEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
@ -126,3 +137,29 @@ void VGraphicsSimpleTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *e
{
emit ShowContextMenu(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
#ifndef QT_NO_CURSOR
QPixmap pixmap(QLatin1String("://cursor/cursor-arrow-closehand.png"));
QApplication::setOverrideCursor(QCursor(pixmap, 1, 1));
#endif
}
QGraphicsSimpleTextItem::mousePressEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
//Disable cursor-arrow-closehand
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
QGraphicsSimpleTextItem::mouseReleaseEvent(event);
}

View File

@ -57,9 +57,11 @@ signals:
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent *event );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent *event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent *event );
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent *event );
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
private:
/** @brief fontSize label font size. */
qint32 fontSize;

View File

@ -227,7 +227,6 @@ bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString
Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty");
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
bool ok = false;
QString parametr;
bool val = true;