From 9aaf90bf5bb6a3e96195cd94900df89ed4cc24a8 Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 25 Jun 2014 12:56:19 +0300 Subject: [PATCH] Refactoring VToolArc. --HG-- branch : develop --- src/app/dialogs/app/configdialog.cpp | 1 - src/app/main.cpp | 1 - src/app/mainwindow.cpp | 1 - src/app/tools/drawTools/vtoolarc.cpp | 125 +------------------- src/app/tools/drawTools/vtoolarc.h | 14 +-- src/app/tools/drawTools/vtoolspline.cpp | 6 - src/app/tools/drawTools/vtoolspline.h | 1 - src/app/tools/drawTools/vtoolsplinepath.cpp | 6 - src/app/tools/drawTools/vtoolsplinepath.h | 1 - 9 files changed, 4 insertions(+), 152 deletions(-) diff --git a/src/app/dialogs/app/configdialog.cpp b/src/app/dialogs/app/configdialog.cpp index 05d34ad67..daa7b7677 100644 --- a/src/app/dialogs/app/configdialog.cpp +++ b/src/app/dialogs/app/configdialog.cpp @@ -28,7 +28,6 @@ #include "configdialog.h" #include -#include #include #include #include diff --git a/src/app/main.cpp b/src/app/main.cpp index 78fb8c8ee..7cbecae0f 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -29,7 +29,6 @@ #include "mainwindow.h" #include "widgets/vapplication.h" #include -#include #include #include #include "tablewindow.h" diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 10a9ee8ba..a12d1e99c 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -42,7 +42,6 @@ #include "widgets/undoevent.h" #include -#include #include #include #include diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index a3f7a8709..c61cc782d 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -44,9 +44,8 @@ const QString VToolArc::ToolType = QStringLiteral("simple"); * @param typeCreation way we create this tool. * @param parent parent object */ -VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, - QGraphicsItem *parent) - :VDrawTool(doc, data, id), QGraphicsPathItem(parent) +VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent) + :VAbstractSpline(doc, data, id, parent) { const VArc *arc = data->GeometricObject(id); QPainterPath path; @@ -174,59 +173,6 @@ void VToolArc::FullUpdateFromFile() RefreshGeometry(); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ -void VToolArc::ChangedActivDraw(const QString &newName) -{ - bool selectable = false; - if (nameActivDraw == newName) - { - selectable = true; - currentColor = Qt::black; - } - else - { - selectable = false; - currentColor = Qt::gray; - } - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); - this->setAcceptHoverEvents (selectable); - VDrawTool::ChangedActivDraw(newName); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ShowTool highlight tool. - * @param id object id in container - * @param color highlight color. - * @param enable enable or disable highlight. - */ -void VToolArc::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) -{ - ShowItem(this, id, color, enable); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ -void VToolArc::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolArc::Disable(bool disable) -{ - DisableItem(this, disable); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief contextMenuEvent handle context menu events. @@ -287,30 +233,6 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) QGraphicsItem::mouseReleaseEvent(event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ -//cppcheck-suppress unusedFunction -void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor)); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ -//cppcheck-suppress unusedFunction -void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RemoveReferens decrement value of reference. @@ -321,49 +243,6 @@ void VToolArc::RemoveReferens() doc->DecrementReferens(arc->GetCenter().id()); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief itemChange handle tool change. - * @param change change. - * @param value value. - * @return value. - */ -QVariant VToolArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) -{ - if (change == QGraphicsItem::ItemSelectedChange) - { - if (value == true) - { - // do stuff if selected - this->setFocus(); - } - else - { - // do stuff if not selected - } - } - - return QGraphicsItem::itemChange(change, value); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief keyReleaseEvent handle key release events. - * @param event key release event. - */ -void VToolArc::keyReleaseEvent(QKeyEvent *event) -{ - switch (event->key()) - { - case Qt::Key_Delete: - DeleteTool(this); - break; - default: - break; - } - QGraphicsItem::keyReleaseEvent ( event ); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SaveDialog save options into file after change in dialog. diff --git a/src/app/tools/drawTools/vtoolarc.h b/src/app/tools/drawTools/vtoolarc.h index b1eee21f2..9ee5d727f 100644 --- a/src/app/tools/drawTools/vtoolarc.h +++ b/src/app/tools/drawTools/vtoolarc.h @@ -29,14 +29,12 @@ #ifndef VTOOLARC_H #define VTOOLARC_H -#include "vdrawtool.h" -#include -#include "../../widgets/vcontrolpointspline.h" +#include "vabstractspline.h" /** * @brief The VToolArc class tool for creation arc. */ -class VToolArc :public VDrawTool, public QGraphicsPathItem +class VToolArc :public VAbstractSpline { Q_OBJECT public: @@ -50,20 +48,12 @@ public: static const QString ToolType; public slots: virtual void FullUpdateFromFile(); - virtual void ChangedActivDraw(const QString &newName); - virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); - virtual void SetFactor(qreal factor); - void Disable(bool disable); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void AddToFile(); virtual void RefreshDataInFile(); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void RemoveReferens(); - virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - virtual void keyReleaseEvent(QKeyEvent * event); virtual void SaveDialog(QDomElement &domElement); private: void RefreshGeometry(); diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index 3daceaa58..ac660d505 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -205,12 +205,6 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp qApp->getUndoStack()->push(moveSpl); } -//--------------------------------------------------------------------------------------------------------------------- -void VToolSpline::Disable(bool disable) -{ - DisableItem(this, disable); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief contextMenuEvent handle context menu events. diff --git a/src/app/tools/drawTools/vtoolspline.h b/src/app/tools/drawTools/vtoolspline.h index 873e9e97a..a75726a94 100644 --- a/src/app/tools/drawTools/vtoolspline.h +++ b/src/app/tools/drawTools/vtoolspline.h @@ -51,7 +51,6 @@ public: public slots: void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position, const QPointF &pos); - void Disable(bool disable); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void AddToFile (); diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index d96a7350b..ff1e95df2 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -187,12 +187,6 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons qApp->getUndoStack()->push(moveSplPath); } -//--------------------------------------------------------------------------------------------------------------------- -void VToolSplinePath::Disable(bool disable) -{ - DisableItem(this, disable); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief UpdateControlPoints update position points control points in file. diff --git a/src/app/tools/drawTools/vtoolsplinepath.h b/src/app/tools/drawTools/vtoolsplinepath.h index ae739b3ae..793bc70fe 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.h +++ b/src/app/tools/drawTools/vtoolsplinepath.h @@ -65,7 +65,6 @@ public slots: void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, const QPointF &pos); - void Disable(bool disable); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void AddToFile();