From a89259d47d4cf4f57d056734ff46aeef46492ca2 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 11 May 2020 17:39:54 +0300 Subject: [PATCH] Fix issue with VMainGraphicsView. --- src/app/puzzle/puzzle.pri | 2 - src/app/puzzle/vpuzzlemaingraphicsscene.cpp | 35 ---------------- src/app/puzzle/vpuzzlemaingraphicsscene.h | 44 --------------------- src/app/puzzle/vpuzzlemaingraphicsview.cpp | 21 ++++------ src/app/puzzle/vpuzzlemaingraphicsview.h | 19 +++++---- 5 files changed, 16 insertions(+), 105 deletions(-) delete mode 100644 src/app/puzzle/vpuzzlemaingraphicsscene.cpp delete mode 100644 src/app/puzzle/vpuzzlemaingraphicsscene.h diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 47095dbab..e55760817 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -14,7 +14,6 @@ SOURCES += \ $$PWD/vpuzzlegraphicspiece.cpp \ $$PWD/vpuzzlelayout.cpp \ $$PWD/vpuzzlelayer.cpp \ - $$PWD/vpuzzlemaingraphicsscene.cpp \ $$PWD/vpuzzlemaingraphicsview.cpp \ $$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlepiece.cpp \ @@ -40,7 +39,6 @@ HEADERS += \ $$PWD/vpuzzlegraphicspiece.h \ $$PWD/vpuzzlelayout.h \ $$PWD/vpuzzlelayer.h \ - $$PWD/vpuzzlemaingraphicsscene.h \ $$PWD/vpuzzlemaingraphicsview.h \ $$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlepiece.h \ diff --git a/src/app/puzzle/vpuzzlemaingraphicsscene.cpp b/src/app/puzzle/vpuzzlemaingraphicsscene.cpp deleted file mode 100644 index 5a4d1d17f..000000000 --- a/src/app/puzzle/vpuzzlemaingraphicsscene.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************ - ** - ** @file vpuzzlemaingraphicsscene.cpp - ** @author Ronan Le Tiec - ** @date 3 5, 2020 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentina project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2020 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#include "vpuzzlemaingraphicsscene.h" - -//--------------------------------------------------------------------------------------------------------------------- -VPuzzleMainGraphicsScene::VPuzzleMainGraphicsScene(QObject *parent): QGraphicsScene(parent) -{ - -} diff --git a/src/app/puzzle/vpuzzlemaingraphicsscene.h b/src/app/puzzle/vpuzzlemaingraphicsscene.h deleted file mode 100644 index 199ed0e8f..000000000 --- a/src/app/puzzle/vpuzzlemaingraphicsscene.h +++ /dev/null @@ -1,44 +0,0 @@ -/************************************************************************ - ** - ** @file vpuzzlemaingraphicsscene.cpp - ** @author Ronan Le Tiec - ** @date 3 5, 2020 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentina project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2020 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#ifndef VPUZZLEMAINGRAPHICSSCENE_H -#define VPUZZLEMAINGRAPHICSSCENE_H - -#include - -// TODO: When ready, extend from QGraphicsScene instead - -class VPuzzleMainGraphicsScene : public QGraphicsScene -{ - Q_OBJECT -public: - VPuzzleMainGraphicsScene(QObject *parent = nullptr); - -}; - -#endif // VPUZZLEMAINGRAPHICSSCENE_H diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.cpp b/src/app/puzzle/vpuzzlemaingraphicsview.cpp index d4740eeb1..4be5cf375 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.cpp +++ b/src/app/puzzle/vpuzzlemaingraphicsview.cpp @@ -34,6 +34,7 @@ #include "vpuzzlemimedatapiece.h" #include "vpuzzlelayer.h" +#include "../vwidgets/vmaingraphicsscene.h" #include @@ -42,30 +43,22 @@ Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView") //--------------------------------------------------------------------------------------------------------------------- VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent) : - QGraphicsView(parent), - m_layout(layout), - m_graphicsPieces(QList()) + VMainGraphicsView(parent), + m_layout(layout) { - m_scene = new VPuzzleMainGraphicsScene(this); + m_scene = new VMainGraphicsScene(this); setScene(m_scene); m_graphicsLayout = new VPuzzleGraphicsLayout(layout); - m_graphicsLayout->setPos(0,0); + m_graphicsLayout->setPos(0, 0); m_scene->addItem(m_graphicsLayout); - setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - setAcceptDrops(true); // add the connections connect(m_layout, &VPuzzleLayout::PieceMovedToLayer, this, &VPuzzleMainGraphicsView::on_PieceMovedToLayer); - connect(m_scene, &VPuzzleMainGraphicsScene::selectionChanged, this, &VPuzzleMainGraphicsView::on_SceneSelectionChanged); -} - -//--------------------------------------------------------------------------------------------------------------------- -VPuzzleMainGraphicsView::~VPuzzleMainGraphicsView() -{ - + connect(m_scene, &VMainGraphicsScene::selectionChanged, this, + &VPuzzleMainGraphicsView::on_SceneSelectionChanged); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.h b/src/app/puzzle/vpuzzlemaingraphicsview.h index fea0d7947..bccff359c 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.h +++ b/src/app/puzzle/vpuzzlemaingraphicsview.h @@ -29,21 +29,19 @@ #ifndef VPUZZLEMAINGRAPHICSVIEW_H #define VPUZZLEMAINGRAPHICSVIEW_H -#include - #include "vpuzzlegraphicslayout.h" -#include "vpuzzlemaingraphicsscene.h" #include "vpuzzlegraphicspiece.h" +#include "../vwidgets/vmaingraphicsview.h" + +class VMainGraphicsScene; -// TODO: when ready, extend the VMainGrapchisView instead - -class VPuzzleMainGraphicsView : public QGraphicsView +class VPuzzleMainGraphicsView : public VMainGraphicsView { Q_OBJECT public: VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent); - ~VPuzzleMainGraphicsView(); + ~VPuzzleMainGraphicsView() = default; /** * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin @@ -60,7 +58,8 @@ protected: private slots: /** - * @brief on_PieceMovedToLayer The slot is called when the given piece was moved from the given layer to the other given layer + * @brief on_PieceMovedToLayer The slot is called when the given piece was moved from the given layer to the other + * given layer * @param piece the piece that was moved * @param layerBefore the layer before the move * @param layerAfter the layer after the move @@ -75,12 +74,12 @@ private slots: private: Q_DISABLE_COPY(VPuzzleMainGraphicsView) - VPuzzleMainGraphicsScene *m_scene{nullptr}; + VMainGraphicsScene *m_scene{nullptr}; VPuzzleGraphicsLayout *m_graphicsLayout{nullptr}; VPuzzleLayout *m_layout{nullptr}; - QList m_graphicsPieces; + QList m_graphicsPieces{}; };