From 8b52db90c5a775fd976276186e11bac34a79eaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Br=C3=A6strup=20Sayoc?= Date: Wed, 6 Jul 2022 18:01:43 +0200 Subject: [PATCH] [TechDraw] Use function overloadin and avoid code repeat --- src/Mod/TechDraw/Gui/QGCustomBorder.cpp | 7 +------ src/Mod/TechDraw/Gui/QGCustomClip.cpp | 2 +- src/Mod/TechDraw/Gui/QGCustomImage.cpp | 2 +- src/Mod/TechDraw/Gui/QGCustomLabel.cpp | 7 +------ src/Mod/TechDraw/Gui/QGCustomRect.cpp | 7 +------ src/Mod/TechDraw/Gui/QGCustomSvg.cpp | 2 +- src/Mod/TechDraw/Gui/QGCustomText.cpp | 2 +- src/Mod/TechDraw/Gui/QGDisplayArea.cpp | 2 +- 8 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGCustomBorder.cpp b/src/Mod/TechDraw/Gui/QGCustomBorder.cpp index c6f5901537..ac61f1b24e 100644 --- a/src/Mod/TechDraw/Gui/QGCustomBorder.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomBorder.cpp @@ -51,12 +51,7 @@ QGCustomBorder::QGCustomBorder() void QGCustomBorder::centerAt(QPointF centerPos) { - QRectF box = boundingRect(); - double width = box.width(); - double height = box.height(); - double newX = centerPos.x() - width/2.; - double newY = centerPos.y() - height/2.; - setPos(newX,newY); + centerAt(centerPos.x(), centerPos.y()); } void QGCustomBorder::centerAt(double cX, double cY) diff --git a/src/Mod/TechDraw/Gui/QGCustomClip.cpp b/src/Mod/TechDraw/Gui/QGCustomClip.cpp index 44e6c441cd..06173b0852 100644 --- a/src/Mod/TechDraw/Gui/QGCustomClip.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomClip.cpp @@ -55,7 +55,7 @@ QGCustomClip::QGCustomClip() void QGCustomClip::centerAt(QPointF centerPos) { - centerAt(centerPos.x(),centerPos.y()); + centerAt(centerPos.x(), centerPos.y()); } void QGCustomClip::centerAt(double cX, double cY) diff --git a/src/Mod/TechDraw/Gui/QGCustomImage.cpp b/src/Mod/TechDraw/Gui/QGCustomImage.cpp index de42d4cb9f..663ec24abe 100644 --- a/src/Mod/TechDraw/Gui/QGCustomImage.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomImage.cpp @@ -51,7 +51,7 @@ QGCustomImage::~QGCustomImage() void QGCustomImage::centerAt(QPointF centerPos) { - centerAt(centerPos.x(),centerPos.y()); + centerAt(centerPos.x(), centerPos.y()); } void QGCustomImage::centerAt(double cX, double cY) diff --git a/src/Mod/TechDraw/Gui/QGCustomLabel.cpp b/src/Mod/TechDraw/Gui/QGCustomLabel.cpp index 2ea0037485..778312bfae 100644 --- a/src/Mod/TechDraw/Gui/QGCustomLabel.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomLabel.cpp @@ -55,12 +55,7 @@ QGCustomLabel::QGCustomLabel() void QGCustomLabel::centerAt(QPointF centerPos) { - QRectF box = boundingRect(); - double width = box.width(); - double height = box.height(); - double newX = centerPos.x() - width/2.; - double newY = centerPos.y() - height/2.; - setPos(newX,newY); + centerAt(centerPos.x(), centerPos.y()); } void QGCustomLabel::centerAt(double cX, double cY) diff --git a/src/Mod/TechDraw/Gui/QGCustomRect.cpp b/src/Mod/TechDraw/Gui/QGCustomRect.cpp index cf82c90f56..feb4c1cd38 100644 --- a/src/Mod/TechDraw/Gui/QGCustomRect.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomRect.cpp @@ -51,12 +51,7 @@ QGCustomRect::QGCustomRect() void QGCustomRect::centerAt(QPointF centerPos) { - QRectF box = boundingRect(); - double width = box.width(); - double height = box.height(); - double newX = centerPos.x() - width/2.; - double newY = centerPos.y() - height/2.; - setPos(newX,newY); + centerAt(centerPos.x(), centerPos.y()); } void QGCustomRect::centerAt(double cX, double cY) diff --git a/src/Mod/TechDraw/Gui/QGCustomSvg.cpp b/src/Mod/TechDraw/Gui/QGCustomSvg.cpp index 46754565d3..82471600c4 100644 --- a/src/Mod/TechDraw/Gui/QGCustomSvg.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomSvg.cpp @@ -51,7 +51,7 @@ QGCustomSvg::~QGCustomSvg() void QGCustomSvg::centerAt(QPointF centerPos) { - centerAt(centerPos.x(),centerPos.y()); + centerAt(centerPos.x(), centerPos.y()); } void QGCustomSvg::centerAt(double cX, double cY) diff --git a/src/Mod/TechDraw/Gui/QGCustomText.cpp b/src/Mod/TechDraw/Gui/QGCustomText.cpp index 3a8ac04327..44de673dd3 100644 --- a/src/Mod/TechDraw/Gui/QGCustomText.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomText.cpp @@ -65,7 +65,7 @@ QGCustomText::QGCustomText(QGraphicsItem* parent) : void QGCustomText::centerAt(QPointF centerPos) { - centerAt(centerPos.x(),centerPos.y()); + centerAt(centerPos.x(), centerPos.y()); } void QGCustomText::centerAt(double cX, double cY) diff --git a/src/Mod/TechDraw/Gui/QGDisplayArea.cpp b/src/Mod/TechDraw/Gui/QGDisplayArea.cpp index 0afaf632b5..00f2e51bad 100644 --- a/src/Mod/TechDraw/Gui/QGDisplayArea.cpp +++ b/src/Mod/TechDraw/Gui/QGDisplayArea.cpp @@ -52,7 +52,7 @@ QGDisplayArea::QGDisplayArea(void) void QGDisplayArea::centerAt(QPointF centerPos) { - centerAt(centerPos.x(),centerPos.y()); + centerAt(centerPos.x(), centerPos.y()); } void QGDisplayArea::centerAt(double cX, double cY)