From 0d4c6c2208b92a0aca179ebaad433b4599d04228 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 28 Mar 2016 17:10:19 +0300 Subject: [PATCH] By default user can select only labels by rubber band. --HG-- branch : develop --- .../tools/drawTools/toolcurve/vtoolarc.cpp | 2 -- .../drawTools/toolcurve/vtoolarcwithlength.cpp | 2 -- .../drawTools/toolcurve/vtoolcubicbezier.cpp | 2 -- .../drawTools/toolcurve/vtoolcubicbezierpath.cpp | 2 -- .../tools/drawTools/toolcurve/vtoolspline.cpp | 2 -- .../drawTools/toolcurve/vtoolsplinepath.cpp | 2 -- .../toolpoint/toolsinglepoint/vtoolbasepoint.cpp | 1 - .../toolsinglepoint/vtoolsinglepoint.cpp | 2 -- src/libs/vtools/tools/drawTools/vtoolline.cpp | 2 -- src/libs/vtools/tools/vtooldetail.cpp | 1 - src/libs/vwidgets/vcontrolpointspline.cpp | 1 - src/libs/vwidgets/vgraphicssimpletextitem.cpp | 14 -------------- src/libs/vwidgets/vgraphicssimpletextitem.h | 1 - src/libs/vwidgets/vmaingraphicsscene.cpp | 16 ++++++++-------- src/libs/vwidgets/vsimplepoint.cpp | 2 -- 15 files changed, 8 insertions(+), 44 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index c0f8ec410..df7114e16 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -58,8 +58,6 @@ VToolArc::VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const QS this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); ToolCreation(typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index 4da3643c7..3fb84429e 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -49,8 +49,6 @@ VToolArcWithLength::VToolArcWithLength(VAbstractPattern *doc, VContainer *data, this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); ToolCreation(typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp index 322523468..e3899059d 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp @@ -43,8 +43,6 @@ VToolCubicBezier::VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quin lineColor = color; this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); this->setPath(ToolPath()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp index 3ef93ebae..92b21142a 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp @@ -42,8 +42,6 @@ VToolCubicBezierPath::VToolCubicBezierPath(VAbstractPattern *doc, VContainer *da this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); ToolCreation(typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 8cced0338..0d5d5d098 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -61,8 +61,6 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co lineColor = color; this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setAcceptHoverEvents(true); this->setPath(ToolPath()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index caefaa68f..a5f7a5307 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -62,8 +62,6 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3 this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setAcceptHoverEvents(true); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index 645d8655f..7d4fb427b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -55,7 +55,6 @@ VToolBasePoint::VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32 this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, false); SetColorLabel(Qt::black); ToolCreation(typeCreation); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index fe9c75350..14ae5228b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -69,8 +69,6 @@ VToolSinglePoint::VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quin connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolSinglePoint::NameChangePosition); lineName = new QGraphicsLineItem(this); this->setBrush(QBrush(Qt::NoBrush)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); } diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index dfbb8da34..c10c88305 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -59,8 +59,6 @@ VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint3 const QSharedPointer second = data->GeometricObject(secondPoint); this->setLine(QLineF(first->toQPointF(), second->toQPointF())); this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, LineStyleToPenStyle(typeLine))); diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 366999acd..cb3a37709 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -111,7 +111,6 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 seamAllowance->setBrush(QBrush(Qt::FDiagPattern)); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); connect(scene, &VMainGraphicsScene::EnableToolMove, this, &VToolDetail::EnableToolMove); if (typeCreation == Source::FromGui || typeCreation == Source::FromTool) diff --git a/src/libs/vwidgets/vcontrolpointspline.cpp b/src/libs/vwidgets/vcontrolpointspline.cpp index c6edb340b..92fd3c931 100644 --- a/src/libs/vwidgets/vcontrolpointspline.cpp +++ b/src/libs/vwidgets/vcontrolpointspline.cpp @@ -74,7 +74,6 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP { Init(); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setAcceptHoverEvents(true); diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index 21b13359f..16ef6bc6e 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -50,7 +50,6 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent) this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); QFont font = this->font(); font.setPointSize(font.pointSize()+20); @@ -80,19 +79,6 @@ VGraphicsSimpleTextItem::~VGraphicsSimpleTextItem() RestoreOverrideCursor(cursorArrowOpenHand); } -//--------------------------------------------------------------------------------------------------------------------- -void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - /* From question on StackOverflow - * https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected - * - * There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way - * I can think of is derive your own items from the build-in ones and override the paint() function:*/ - QStyleOptionGraphicsItem myOption(*option); - myOption.state &= ~QStyle::State_Selected; - QGraphicsSimpleTextItem::paint(painter, &myOption, widget); -} - //--------------------------------------------------------------------------------------------------------------------- void VGraphicsSimpleTextItem::setEnabled(bool enabled) { diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.h b/src/libs/vwidgets/vgraphicssimpletextitem.h index 8968b65db..b84598e41 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.h +++ b/src/libs/vwidgets/vgraphicssimpletextitem.h @@ -45,7 +45,6 @@ public: virtual ~VGraphicsSimpleTextItem() Q_DECL_OVERRIDE; qint32 FontSize()const; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE; virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Vis::GraphicsSimpleTextItem)}; diff --git a/src/libs/vwidgets/vmaingraphicsscene.cpp b/src/libs/vwidgets/vmaingraphicsscene.cpp index b0c6f709a..59e0b0080 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.cpp +++ b/src/libs/vwidgets/vmaingraphicsscene.cpp @@ -80,14 +80,14 @@ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event) } QGraphicsScene::mousePressEvent(event); - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - QList items = selectedItems(); - for (int i=0; i< items.size(); i++) - { - items[i]->setSelected(false); - } - } +// if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) +// { +// QList items = selectedItems(); +// for (int i=0; i< items.size(); i++) +// { +// items[i]->setSelected(false); +// } +// } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vwidgets/vsimplepoint.cpp b/src/libs/vwidgets/vsimplepoint.cpp index 51447b629..1db213ff9 100644 --- a/src/libs/vwidgets/vsimplepoint.cpp +++ b/src/libs/vwidgets/vsimplepoint.cpp @@ -49,8 +49,6 @@ VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternU lineName = new QGraphicsLineItem(this); this->setBrush(QBrush(Qt::NoBrush)); SetPen(this, currentColor, WidthHairLine(patternUnit)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); }