By default user can select only labels by rubber band.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-03-28 17:10:19 +03:00
parent 2339a95585
commit 0d4c6c2208
15 changed files with 8 additions and 44 deletions

View File

@ -58,8 +58,6 @@ VToolArc::VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const QS
this->setPath(ToolPath()); this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); 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->setAcceptHoverEvents(true);
ToolCreation(typeCreation); ToolCreation(typeCreation);

View File

@ -49,8 +49,6 @@ VToolArcWithLength::VToolArcWithLength(VAbstractPattern *doc, VContainer *data,
this->setPath(ToolPath()); this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); 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->setAcceptHoverEvents(true);
ToolCreation(typeCreation); ToolCreation(typeCreation);

View File

@ -43,8 +43,6 @@ VToolCubicBezier::VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quin
lineColor = color; lineColor = color;
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); 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->setAcceptHoverEvents(true);
this->setPath(ToolPath()); this->setPath(ToolPath());

View File

@ -42,8 +42,6 @@ VToolCubicBezierPath::VToolCubicBezierPath(VAbstractPattern *doc, VContainer *da
this->setPath(ToolPath()); this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); 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->setAcceptHoverEvents(true);
ToolCreation(typeCreation); ToolCreation(typeCreation);

View File

@ -61,8 +61,6 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co
lineColor = color; lineColor = color;
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); 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->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
this->setPath(ToolPath()); this->setPath(ToolPath());

View File

@ -62,8 +62,6 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
this->setPath(ToolPath()); this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); 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->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);

View File

@ -55,7 +55,6 @@ VToolBasePoint::VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, false);
SetColorLabel(Qt::black); SetColorLabel(Qt::black);
ToolCreation(typeCreation); ToolCreation(typeCreation);
} }

View File

@ -69,8 +69,6 @@ VToolSinglePoint::VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quin
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolSinglePoint::NameChangePosition); connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolSinglePoint::NameChangePosition);
lineName = new QGraphicsLineItem(this); lineName = new QGraphicsLineItem(this);
this->setBrush(QBrush(Qt::NoBrush)); this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id)); RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
} }

View File

@ -59,8 +59,6 @@ VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint3
const QSharedPointer<VPointF> second = data->GeometricObject<VPointF>(secondPoint); const QSharedPointer<VPointF> second = data->GeometricObject<VPointF>(secondPoint);
this->setLine(QLineF(first->toQPointF(), second->toQPointF())); this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(typeLine))); LineStyleToPenStyle(typeLine)));

View File

@ -111,7 +111,6 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
seamAllowance->setBrush(QBrush(Qt::FDiagPattern)); seamAllowance->setBrush(QBrush(Qt::FDiagPattern));
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
connect(scene, &VMainGraphicsScene::EnableToolMove, this, &VToolDetail::EnableToolMove); connect(scene, &VMainGraphicsScene::EnableToolMove, this, &VToolDetail::EnableToolMove);
if (typeCreation == Source::FromGui || typeCreation == Source::FromTool) if (typeCreation == Source::FromGui || typeCreation == Source::FromTool)

View File

@ -74,7 +74,6 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
{ {
Init(); Init();
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);

View File

@ -50,7 +50,6 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent)
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
QFont font = this->font(); QFont font = this->font();
font.setPointSize(font.pointSize()+20); font.setPointSize(font.pointSize()+20);
@ -80,19 +79,6 @@ VGraphicsSimpleTextItem::~VGraphicsSimpleTextItem()
RestoreOverrideCursor(cursorArrowOpenHand); 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) void VGraphicsSimpleTextItem::setEnabled(bool enabled)
{ {

View File

@ -45,7 +45,6 @@ public:
virtual ~VGraphicsSimpleTextItem() Q_DECL_OVERRIDE; virtual ~VGraphicsSimpleTextItem() Q_DECL_OVERRIDE;
qint32 FontSize()const; 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;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::GraphicsSimpleTextItem)}; enum { Type = UserType + static_cast<int>(Vis::GraphicsSimpleTextItem)};

View File

@ -80,14 +80,14 @@ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
QGraphicsScene::mousePressEvent(event); QGraphicsScene::mousePressEvent(event);
if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) // if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier)
{ // {
QList<QGraphicsItem *> items = selectedItems(); // QList<QGraphicsItem *> items = selectedItems();
for (int i=0; i< items.size(); i++) // for (int i=0; i< items.size(); i++)
{ // {
items[i]->setSelected(false); // items[i]->setSelected(false);
} // }
} // }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -49,8 +49,6 @@ VSimplePoint::VSimplePoint(quint32 id, const QColor &currentColor, Unit patternU
lineName = new QGraphicsLineItem(this); lineName = new QGraphicsLineItem(this);
this->setBrush(QBrush(Qt::NoBrush)); this->setBrush(QBrush(Qt::NoBrush));
SetPen(this, currentColor, WidthHairLine(patternUnit)); SetPen(this, currentColor, WidthHairLine(patternUnit));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
} }