From e43f970ea8a1c19ce8eaccb82eeccb2ddd39b516 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:48:31 +0200 Subject: [PATCH] Refactoring VPuzzleGraphicsLayout --- src/app/puzzle/puzzle.pri | 4 ++-- src/app/puzzle/vpcarrouselpiece.cpp | 6 +++--- ...zlegraphicslayout.cpp => vpgraphicssheet.cpp} | 16 ++++++++-------- ...vpuzzlegraphicslayout.h => vpgraphicssheet.h} | 16 ++++++++-------- src/app/puzzle/vpmainwindow.cpp | 2 +- src/app/puzzle/vpmainwindow.h | 6 +++--- src/app/puzzle/vpuzzlemaingraphicsview.cpp | 8 ++++---- src/app/puzzle/vpuzzlemaingraphicsview.h | 4 ++-- 8 files changed, 31 insertions(+), 31 deletions(-) rename src/app/puzzle/{vpuzzlegraphicslayout.cpp => vpgraphicssheet.cpp} (85%) rename src/app/puzzle/{vpuzzlegraphicslayout.h => vpgraphicssheet.h} (81%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 7727db3bb..2b0317e0b 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -11,8 +11,8 @@ SOURCES += \ $$PWD/vpcarrouselpiecepreview.cpp \ $$PWD/vpcommandline.cpp \ $$PWD/vpcommands.cpp \ + $$PWD/vpgraphicssheet.cpp \ $$PWD/vpmainwindow.cpp \ - $$PWD/vpuzzlegraphicslayout.cpp \ $$PWD/vpuzzlegraphicspiece.cpp \ $$PWD/vpuzzlelayout.cpp \ $$PWD/vpuzzlelayer.cpp \ @@ -35,9 +35,9 @@ HEADERS += \ $$PWD/vpcarrouselpiecepreview.h \ $$PWD/vpcommandline.h \ $$PWD/vpcommands.h \ + $$PWD/vpgraphicssheet.h \ $$PWD/vpmainwindow.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlegraphicslayout.h \ $$PWD/vpuzzlegraphicspiece.h \ $$PWD/vpuzzlelayout.h \ $$PWD/vpuzzlelayer.h \ diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index 7cc6c7173..d96d39e02 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -256,7 +256,7 @@ void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) QVariant data = QVariant::fromValue(layer); moveToLayer->setData(data); - connect(moveToLayer, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToLayer); + connect(moveToLayer, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); } } @@ -266,14 +266,14 @@ void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) QAction *removeAction = contextMenu.addAction(tr("Remove from Layout")); QVariant data = QVariant::fromValue(m_piece->GetLayer()->GetLayout()->GetUnplacedPiecesLayer()); removeAction->setData(data); - connect(removeAction, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToLayer); + connect(removeAction, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); } contextMenu.exec(event->globalPos()); } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiece::on_ActionPieceMovedToLayer() +void VPCarrouselPiece::on_ActionPieceMovedToPieceList() { QAction *act = qobject_cast(sender()); QVariant v = act->data(); diff --git a/src/app/puzzle/vpuzzlegraphicslayout.cpp b/src/app/puzzle/vpgraphicssheet.cpp similarity index 85% rename from src/app/puzzle/vpuzzlegraphicslayout.cpp rename to src/app/puzzle/vpgraphicssheet.cpp index 00185b9b5..e8ca73e16 100644 --- a/src/app/puzzle/vpuzzlegraphicslayout.cpp +++ b/src/app/puzzle/vpgraphicssheet.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlegraphicslayout.cpp + ** @file vpgraphicssheet.cpp ** @author Ronan Le Tiec ** @date 3 5, 2020 ** @@ -26,10 +26,10 @@ ** *************************************************************************/ -#include "vpuzzlegraphicslayout.h" +#include "vpgraphicssheet.h" //--------------------------------------------------------------------------------------------------------------------- -VPuzzleGraphicsLayout::VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsItem *parent): +VPGraphicsSheet::VPGraphicsSheet(VPuzzleLayout *layout, QGraphicsItem *parent): QGraphicsItem(parent), m_layout(layout), m_boundingRect(GetLayoutRect()) @@ -38,13 +38,13 @@ VPuzzleGraphicsLayout::VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsIte } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleGraphicsLayout::~VPuzzleGraphicsLayout() +VPGraphicsSheet::~VPGraphicsSheet() { } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsLayout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(widget); Q_UNUSED(option); @@ -66,14 +66,14 @@ void VPuzzleGraphicsLayout::paint(QPainter *painter, const QStyleOptionGraphicsI } //--------------------------------------------------------------------------------------------------------------------- -QRectF VPuzzleGraphicsLayout::GetLayoutRect() const +QRectF VPGraphicsSheet::GetLayoutRect() const { QRectF rect = QRectF(QPointF(0,0), m_layout->GetLayoutSize()); return rect; } //--------------------------------------------------------------------------------------------------------------------- -QRectF VPuzzleGraphicsLayout::GetMarginsRect() const +QRectF VPGraphicsSheet::GetMarginsRect() const { QMarginsF margins = m_layout->GetLayoutMargins(); QSizeF size = m_layout->GetLayoutSize(); @@ -86,7 +86,7 @@ QRectF VPuzzleGraphicsLayout::GetMarginsRect() const //--------------------------------------------------------------------------------------------------------------------- -QRectF VPuzzleGraphicsLayout::boundingRect() const +QRectF VPGraphicsSheet::boundingRect() const { return m_boundingRect; } diff --git a/src/app/puzzle/vpuzzlegraphicslayout.h b/src/app/puzzle/vpgraphicssheet.h similarity index 81% rename from src/app/puzzle/vpuzzlegraphicslayout.h rename to src/app/puzzle/vpgraphicssheet.h index a8c2c509e..b57d7001c 100644 --- a/src/app/puzzle/vpuzzlegraphicslayout.h +++ b/src/app/puzzle/vpgraphicssheet.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlegraphicslayout.h + ** @file vpgraphicssheet.h ** @author Ronan Le Tiec ** @date 3 5, 2020 ** @@ -26,19 +26,19 @@ ** *************************************************************************/ -#ifndef VPUZZLEGRAPHICSLAYOUT_H -#define VPUZZLEGRAPHICSLAYOUT_H +#ifndef VPGRAPHICSSHEET_H +#define VPGRAPHICSSHEET_H #include #include #include "vpuzzlelayout.h" -class VPuzzleGraphicsLayout : public QGraphicsItem +class VPGraphicsSheet : public QGraphicsItem { public: - explicit VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsItem *parent = nullptr); - ~VPuzzleGraphicsLayout(); + explicit VPGraphicsSheet(VPuzzleLayout *layout, QGraphicsItem *parent = nullptr); + ~VPGraphicsSheet(); QRectF boundingRect() const override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override; @@ -49,10 +49,10 @@ public: private: - Q_DISABLE_COPY(VPuzzleGraphicsLayout) + Q_DISABLE_COPY(VPGraphicsSheet) VPuzzleLayout *m_layout{nullptr}; QRectF m_boundingRect; }; -#endif // VPUZZLEGRAPHICSLAYOUT_H +#endif // VPGRAPHICSSHEET_H diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 59ba207ab..02defa906 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -52,7 +52,7 @@ Q_LOGGING_CATEGORY(pWindow, "p.window") QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- -VPMainWindow::VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) : +VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : QMainWindow(parent), ui(new Ui::VPMainWindow), m_cmd(cmd) diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index 463ae5fe3..1e3fb3cd5 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -38,7 +38,7 @@ #include "vpuzzlelayout.h" #include "vpuzzlepiece.h" #include "../vlayout/vlayoutpiece.h" -#include "vpuzzlecommandline.h" +#include "vpcommandline.h" namespace Ui { @@ -50,7 +50,7 @@ class VPMainWindow : public QMainWindow Q_OBJECT public: - explicit VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent = nullptr); + explicit VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent = nullptr); virtual ~VPMainWindow(); /** @@ -93,7 +93,7 @@ private: VPCarrousel *m_carrousel{nullptr}; VPuzzleMainGraphicsView *m_graphicsView{nullptr}; - VPuzzleCommandLinePtr m_cmd; + VPCommandLinePtr m_cmd; VPuzzleLayout *m_layout{nullptr}; QListm_selectedPieces{QList()}; diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.cpp b/src/app/puzzle/vpuzzlemaingraphicsview.cpp index 4be5cf375..da3589dc8 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.cpp +++ b/src/app/puzzle/vpuzzlemaingraphicsview.cpp @@ -49,9 +49,9 @@ VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget m_scene = new VMainGraphicsScene(this); setScene(m_scene); - m_graphicsLayout = new VPuzzleGraphicsLayout(layout); - m_graphicsLayout->setPos(0, 0); - m_scene->addItem(m_graphicsLayout); + m_graphicsSheet = new VPGraphicsSheet(layout); + m_graphicsSheet->setPos(0, 0); + m_scene->addItem(m_graphicsSheet); setAcceptDrops(true); @@ -66,7 +66,7 @@ void VPuzzleMainGraphicsView::RefreshLayout() { // FIXME: Is that the way to go? - m_graphicsLayout->update(); + m_graphicsSheet->update(); m_scene->update(); } diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.h b/src/app/puzzle/vpuzzlemaingraphicsview.h index bccff359c..e138f4cae 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.h +++ b/src/app/puzzle/vpuzzlemaingraphicsview.h @@ -29,7 +29,7 @@ #ifndef VPUZZLEMAINGRAPHICSVIEW_H #define VPUZZLEMAINGRAPHICSVIEW_H -#include "vpuzzlegraphicslayout.h" +#include "vpgraphicssheet.h" #include "vpuzzlegraphicspiece.h" #include "../vwidgets/vmaingraphicsview.h" @@ -76,7 +76,7 @@ private: VMainGraphicsScene *m_scene{nullptr}; - VPuzzleGraphicsLayout *m_graphicsLayout{nullptr}; + VPGraphicsSheet *m_graphicsSheet{nullptr}; VPuzzleLayout *m_layout{nullptr}; QList m_graphicsPieces{};