Refactoring.

Overriding member functions should do more than simply call the same member in the base class.
This commit is contained in:
Roman Telezhynskyi 2024-04-16 15:12:54 +03:00
parent 8c90fd0367
commit 0080ce8ef5
11 changed files with 9 additions and 69 deletions

View File

@ -1989,20 +1989,20 @@ void MainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int m
csv.toCSV(fileName, error, withHeader, separator, VTextCodec::codecForMib(mib)); csv.toCSV(fileName, error, withHeader, separator, VTextCodec::codecForMib(mib));
} }
#if defined(Q_OS_MAC)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolBarStyle(QToolBar *bar) const void MainWindow::ToolBarStyle(QToolBar *bar) const
{ {
MainWindowsNoGUI::ToolBarStyle(bar); MainWindowsNoGUI::ToolBarStyle(bar);
#if defined(Q_OS_MAC)
// Temporary fix issue with toolbar black background on mac with OpenGL render // Temporary fix issue with toolbar black background on mac with OpenGL render
if (VAbstractValApplication::VApp()->getSceneView() && if (VAbstractValApplication::VApp()->getSceneView() &&
VAbstractValApplication::VApp()->getSceneView()->IsOpenGLRender()) VAbstractValApplication::VApp()->getSceneView()->IsOpenGLRender())
{ {
bar->setStyle(QStyleFactory::create("fusion")); bar->setStyle(QStyleFactory::create("fusion"));
} }
#endif
} }
#endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ScaleChanged(qreal scale) void MainWindow::ScaleChanged(qreal scale)

View File

@ -121,7 +121,9 @@ protected:
void CleanLayout() override; void CleanLayout() override;
void PrepareSceneList(PreviewQuatilty quality) override; void PrepareSceneList(PreviewQuatilty quality) override;
void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator) override; void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator) override;
#if defined(Q_OS_MAC)
void ToolBarStyle(QToolBar *bar) const override; void ToolBarStyle(QToolBar *bar) const override;
#endif
private slots: private slots:
void ScaleChanged(qreal scale); void ScaleChanged(qreal scale);
void MouseMove(const QPointF &scenePos); void MouseMove(const QPointF &scenePos);

View File

@ -675,12 +675,6 @@ public:
flags = 0; flags = 0;
name = ""; name = "";
} }
protected:
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override
{
return DRW_TableEntry::parseCode(code, reader);
}
}; };
namespace DRW namespace DRW

View File

@ -309,12 +309,6 @@ void VDxfEngine::drawLines(const QLineF *lines, int lineCount)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawLines(const QLine *lines, int lineCount)
{
QPaintEngine::drawLines(lines, lineCount);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
{ {
@ -377,12 +371,6 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawPolygon(const QPoint *points, int pointCount, QPaintEngine::PolygonDrawMode mode)
{
QPaintEngine::drawPolygon(points, pointCount, mode);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawEllipse(const QRectF &rect) void VDxfEngine::drawEllipse(const QRectF &rect)
{ {
@ -424,12 +412,6 @@ void VDxfEngine::drawEllipse(const QRectF &rect)
m_input->AddEntity(ellipse); m_input->AddEntity(ellipse);
} }
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawEllipse(const QRect &rect)
{
QPaintEngine::drawEllipse(rect);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) void VDxfEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
{ {

View File

@ -79,11 +79,8 @@ public:
void drawPath(const QPainterPath &path) override; void drawPath(const QPainterPath &path) override;
void drawLines(const QLineF *lines, int lineCount) override; void drawLines(const QLineF *lines, int lineCount) override;
void drawLines(const QLine *lines, int lineCount) override;
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override;
void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override;
void drawEllipse(const QRectF &rect) override; void drawEllipse(const QRectF &rect) override;
void drawEllipse(const QRect &rect) override;
void drawTextItem(const QPointF &p, const QTextItem &textItem) override; void drawTextItem(const QPointF &p, const QTextItem &textItem) override;
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override;

View File

@ -246,12 +246,6 @@ void VObjEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
*stream << Qt::endl; *stream << Qt::endl;
} }
//---------------------------------------------------------------------------------------------------------------------
void VObjEngine::drawPolygon(const QPoint *points, int pointCount, QPaintEngine::PolygonDrawMode mode)
{
QPaintEngine::drawPolygon(points, pointCount, mode);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VObjEngine::type() const -> QPaintEngine::Type auto VObjEngine::type() const -> QPaintEngine::Type
{ {
@ -273,12 +267,6 @@ void VObjEngine::drawPoints(const QPointF *points, int pointCount)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VObjEngine::drawPoints(const QPoint *points, int pointCount)
{
QPaintEngine::drawPoints(points, pointCount);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
void VObjEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) void VObjEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)

View File

@ -54,10 +54,8 @@ public:
virtual void drawPath(const QPainterPath &path) override; virtual void drawPath(const QPainterPath &path) override;
virtual auto type() const -> Type override; virtual auto type() const -> Type override;
virtual void drawPoints(const QPointF *points, int pointCount) override; virtual void drawPoints(const QPointF *points, int pointCount) override;
virtual void drawPoints(const QPoint *points, int pointCount) override;
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override;
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override;
virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override;
auto getSize() const -> QSize; auto getSize() const -> QSize;
void setSize(const QSize &value); void setSize(const QSize &value);

View File

@ -42,13 +42,14 @@ auto InvalidImage() -> QPixmap
QImageReader imageReader(VBackgroundPatternImage::brokenImage); QImageReader imageReader(VBackgroundPatternImage::brokenImage);
return QPixmap::fromImageReader(&imageReader); return QPixmap::fromImageReader(&imageReader);
} }
} } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VBackgroundPixmapItem::VBackgroundPixmapItem(const VBackgroundPatternImage &image, VAbstractPattern *doc, VBackgroundPixmapItem::VBackgroundPixmapItem(const VBackgroundPatternImage &image, VAbstractPattern *doc,
QGraphicsItem *parent) QGraphicsItem *parent)
: VBackgroundImageItem(image, doc, parent) : VBackgroundImageItem(image, doc, parent)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VBackgroundPixmapItem::SetTransformationMode(Qt::TransformationMode mode) void VBackgroundPixmapItem::SetTransformationMode(Qt::TransformationMode mode)
@ -80,12 +81,6 @@ auto VBackgroundPixmapItem::shape() const -> QPainterPath
return Image().Matrix().map(m_shape); return Image().Matrix().map(m_shape);
} }
//---------------------------------------------------------------------------------------------------------------------
auto VBackgroundPixmapItem::contains(const QPointF &point) const -> bool
{
return QGraphicsItem::contains(point);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VBackgroundPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void VBackgroundPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
@ -102,12 +97,6 @@ void VBackgroundPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsI
VBackgroundImageItem::paint(painter, option, widget); VBackgroundImageItem::paint(painter, option, widget);
} }
//---------------------------------------------------------------------------------------------------------------------
auto VBackgroundPixmapItem::isObscuredBy(const QGraphicsItem *item) const -> bool
{
return QGraphicsItem::isObscuredBy(item);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VBackgroundPixmapItem::opaqueArea() const -> QPainterPath auto VBackgroundPixmapItem::opaqueArea() const -> QPainterPath
{ {
@ -219,8 +208,7 @@ auto VBackgroundPixmapItem::Pixmap() const -> QPixmap
const double ratioX = PrintDPI / (image.dotsPerMeterX() / 100. * 2.54); const double ratioX = PrintDPI / (image.dotsPerMeterX() / 100. * 2.54);
const double ratioY = PrintDPI / (image.dotsPerMeterY() / 100. * 2.54); const double ratioY = PrintDPI / (image.dotsPerMeterY() / 100. * 2.54);
const QSize imageSize = image.size(); const QSize imageSize = image.size();
return image.scaled(qRound(imageSize.width()*ratioX), return image.scaled(qRound(imageSize.width() * ratioX), qRound(imageSize.height() * ratioY),
qRound(imageSize.height()*ratioY),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation); Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}; };

View File

@ -52,11 +52,9 @@ public:
auto boundingRect() const -> QRectF override; auto boundingRect() const -> QRectF override;
auto shape() const -> QPainterPath override; auto shape() const -> QPainterPath override;
auto contains(const QPointF &point) const -> bool override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
auto isObscuredBy(const QGraphicsItem *item) const -> bool override;
auto opaqueArea() const -> QPainterPath override; auto opaqueArea() const -> QPainterPath override;
auto GetShapeMode() const -> ShapeMode; auto GetShapeMode() const -> ShapeMode;

View File

@ -62,12 +62,6 @@ VToolCut::VToolCut(const VToolCutInitData &initData, QGraphicsItem *parent)
Q_ASSERT_X(initData.baseCurveId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712 Q_ASSERT_X(initData.baseCurveId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolCut::Disable(bool disable, const QString &namePP)
{
VToolSinglePoint::Disable(disable, namePP);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolCut::SetDetailsMode(bool mode) void VToolCut::SetDetailsMode(bool mode)
{ {

View File

@ -79,7 +79,6 @@ public:
auto CurveName() const -> QString; auto CurveName() const -> QString;
public slots: public slots:
void Disable(bool disable, const QString &namePP) override;
void SetDetailsMode(bool mode) override; void SetDetailsMode(bool mode) override;
void FullUpdateFromFile() override; void FullUpdateFromFile() override;