From 83666c090f30db04e19ccb5b8eb164246b78f069 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 15:42:51 +0200 Subject: [PATCH] Refactoring VPuzzlePiece --- src/app/puzzle/puzzle.pri | 4 +- src/app/puzzle/vpcarrousel.cpp | 2 +- src/app/puzzle/vpcarrousel.h | 2 +- src/app/puzzle/vpcarrouselpiece.cpp | 6 +- src/app/puzzle/vpcarrouselpiece.h | 8 +-- src/app/puzzle/vpcarrouselpiecelist.cpp | 8 +-- src/app/puzzle/vpcarrouselpiecelist.h | 4 +- src/app/puzzle/vpgraphicspiece.cpp | 12 ++-- src/app/puzzle/vpgraphicspiece.h | 8 +-- src/app/puzzle/vplayout.cpp | 8 +-- src/app/puzzle/vplayout.h | 8 +-- src/app/puzzle/vpmaingraphicsview.cpp | 6 +- src/app/puzzle/vpmaingraphicsview.h | 2 +- src/app/puzzle/vpmainwindow.cpp | 22 +++---- src/app/puzzle/vpmainwindow.h | 6 +- src/app/puzzle/vpmimedatapiece.cpp | 4 +- src/app/puzzle/vpmimedatapiece.h | 8 +-- .../puzzle/{vpuzzlepiece.cpp => vppiece.cpp} | 62 +++++++++---------- src/app/puzzle/{vpuzzlepiece.h => vppiece.h} | 16 ++--- src/app/puzzle/vppiecelist.cpp | 6 +- src/app/puzzle/vppiecelist.h | 14 ++--- src/app/puzzle/xml/vplayoutfilereader.cpp | 4 +- src/app/puzzle/xml/vplayoutfilereader.h | 4 +- src/app/puzzle/xml/vplayoutfilewriter.cpp | 6 +- src/app/puzzle/xml/vplayoutfilewriter.h | 4 +- 25 files changed, 117 insertions(+), 117 deletions(-) rename src/app/puzzle/{vpuzzlepiece.cpp => vppiece.cpp} (85%) rename src/app/puzzle/{vpuzzlepiece.h => vppiece.h} (97%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 5fe7c72a1..94b394f38 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -17,8 +17,8 @@ SOURCES += \ $$PWD/vpmaingraphicsview.cpp \ $$PWD/vpmainwindow.cpp \ $$PWD/vpmimedatapiece.cpp \ + $$PWD/vppiece.cpp \ $$PWD/vppiecelist.cpp \ - $$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlesettings.cpp \ $$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \ @@ -41,9 +41,9 @@ HEADERS += \ $$PWD/vpmaingraphicsview.h \ $$PWD/vpmainwindow.h \ $$PWD/vpmimedatapiece.h \ + $$PWD/vppiece.h \ $$PWD/vppiecelist.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlesettings.h \ $$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutfilewriter.h \ diff --git a/src/app/puzzle/vpcarrousel.cpp b/src/app/puzzle/vpcarrousel.cpp index 8573ce873..f57bf2cb9 100644 --- a/src/app/puzzle/vpcarrousel.cpp +++ b/src/app/puzzle/vpcarrousel.cpp @@ -106,7 +106,7 @@ void VPCarrousel::on_ActivePieceListChanged(int index) if (pieceList) { - QList pieces = pieceList->GetPieces(); + QList pieces = pieceList->GetPieces(); for (auto piece : pieces) { diff --git a/src/app/puzzle/vpcarrousel.h b/src/app/puzzle/vpcarrousel.h index e0ca7cfe6..f4aed9aff 100644 --- a/src/app/puzzle/vpcarrousel.h +++ b/src/app/puzzle/vpcarrousel.h @@ -33,7 +33,7 @@ #include #include #include "vplayout.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" namespace Ui { diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index 83ee455e6..165553482 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -47,7 +47,7 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") //--------------------------------------------------------------------------------------------------------------------- -VPCarrouselPiece::VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselPieceList) : +VPCarrouselPiece::VPCarrouselPiece(VPPiece *piece, VPCarrouselPieceList *carrouselPieceList) : m_piece(piece), m_carrouselPieceList(carrouselPieceList), m_dragStart(QPoint()) @@ -98,7 +98,7 @@ void VPCarrouselPiece::Init() // connect the signals - connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPCarrouselPiece::on_PieceSelectionChanged); + connect(m_piece, &VPPiece::SelectionChanged, this, &VPCarrouselPiece::on_PieceSelectionChanged); // then refresh the data Refresh(); @@ -147,7 +147,7 @@ void VPCarrouselPiece::Refresh() } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece * VPCarrouselPiece::GetPiece() +VPPiece * VPCarrouselPiece::GetPiece() { return m_piece; } diff --git a/src/app/puzzle/vpcarrouselpiece.h b/src/app/puzzle/vpcarrouselpiece.h index 4ef95083d..8512abf54 100644 --- a/src/app/puzzle/vpcarrouselpiece.h +++ b/src/app/puzzle/vpcarrouselpiece.h @@ -33,7 +33,7 @@ #include #include -#include "vpuzzlepiece.h" +#include "vppiece.h" #include "vpcarrouselpiecepreview.h" @@ -43,7 +43,7 @@ class VPCarrouselPiece : public QFrame { Q_OBJECT public: - explicit VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselPieceList); + explicit VPCarrouselPiece(VPPiece *piece, VPCarrouselPieceList *carrouselPieceList); ~VPCarrouselPiece(); void Init(); @@ -59,7 +59,7 @@ public: * @brief GetPiece Returns the corresponding layout piece * @return the corresponding layout piece */ - VPuzzlePiece * GetPiece(); + VPPiece * GetPiece(); public slots: void on_PieceSelectionChanged(); @@ -81,7 +81,7 @@ private slots: private: Q_DISABLE_COPY(VPCarrouselPiece) - VPuzzlePiece *m_piece; + VPPiece *m_piece; VPCarrouselPieceList *m_carrouselPieceList; diff --git a/src/app/puzzle/vpcarrouselpiecelist.cpp b/src/app/puzzle/vpcarrouselpiecelist.cpp index 5d3044ed8..00f23e8b6 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/vpcarrouselpiecelist.cpp @@ -73,11 +73,11 @@ void VPCarrouselPieceList::Refresh() Clear(); // Updates the carrousel pieces from the pieces list - QList pieces = m_pieceList->GetPieces(); + QList pieces = m_pieceList->GetPieces(); // sort the pieces in alphabetical order std::sort(pieces.begin(), pieces.end(), - [](const VPuzzlePiece* a, const VPuzzlePiece* b) -> bool { return a->GetName() < b->GetName();}); + [](const VPPiece* a, const VPPiece* b) -> bool { return a->GetName() < b->GetName();}); // create the corresponding carrousel pieces @@ -129,7 +129,7 @@ VPPieceList* VPCarrouselPieceList::GetPieceList() } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPieceList::on_PieceAdded(VPuzzlePiece* piece) +void VPCarrouselPieceList::on_PieceAdded(VPPiece* piece) { Q_UNUSED(piece) @@ -139,7 +139,7 @@ void VPCarrouselPieceList::on_PieceAdded(VPuzzlePiece* piece) } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPieceList::on_PieceRemoved(VPuzzlePiece* piece) +void VPCarrouselPieceList::on_PieceRemoved(VPPiece* piece) { for (auto carrouselPiece : m_carrouselPieces) { diff --git a/src/app/puzzle/vpcarrouselpiecelist.h b/src/app/puzzle/vpcarrouselpiecelist.h index 735b98c1c..e32cf1ab4 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.h +++ b/src/app/puzzle/vpcarrouselpiecelist.h @@ -72,12 +72,12 @@ private slots: /** * @brief on_PieceUpdated This slot is called when a piece was added */ - void on_PieceAdded(VPuzzlePiece* piece); + void on_PieceAdded(VPPiece* piece); /** * @brief on_PieceUpdated This slot is called when a piece was removed */ - void on_PieceRemoved(VPuzzlePiece* piece); + void on_PieceRemoved(VPPiece* piece); }; diff --git a/src/app/puzzle/vpgraphicspiece.cpp b/src/app/puzzle/vpgraphicspiece.cpp index 3908ae3e6..0fb07e083 100644 --- a/src/app/puzzle/vpgraphicspiece.cpp +++ b/src/app/puzzle/vpgraphicspiece.cpp @@ -39,7 +39,7 @@ #include #include -#include "vpuzzlepiece.h" +#include "vppiece.h" #include "vppiecelist.h" #include "vplayout.h" @@ -47,7 +47,7 @@ Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") //--------------------------------------------------------------------------------------------------------------------- -VPGraphicsPiece::VPGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent) : +VPGraphicsPiece::VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent) : QGraphicsObject(parent), m_piece(piece), m_cuttingLine(QPainterPath()), @@ -102,13 +102,13 @@ void VPGraphicsPiece::Init() // TODO : initialises the other elements labels, passmarks etc. // Initialises the connectors - connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPGraphicsPiece::on_PieceSelectionChanged); - connect(m_piece, &VPuzzlePiece::PositionChanged, this, &VPGraphicsPiece::on_PiecePositionChanged); - connect(m_piece, &VPuzzlePiece::RotationChanged, this, &VPGraphicsPiece::on_PieceRotationChanged); + connect(m_piece, &VPPiece::SelectionChanged, this, &VPGraphicsPiece::on_PieceSelectionChanged); + connect(m_piece, &VPPiece::PositionChanged, this, &VPGraphicsPiece::on_PiecePositionChanged); + connect(m_piece, &VPPiece::RotationChanged, this, &VPGraphicsPiece::on_PieceRotationChanged); } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece* VPGraphicsPiece::GetPiece() +VPPiece* VPGraphicsPiece::GetPiece() { return m_piece; } diff --git a/src/app/puzzle/vpgraphicspiece.h b/src/app/puzzle/vpgraphicspiece.h index 954fcd195..66f49f401 100644 --- a/src/app/puzzle/vpgraphicspiece.h +++ b/src/app/puzzle/vpgraphicspiece.h @@ -31,13 +31,13 @@ #include -class VPuzzlePiece; +class VPPiece; class VPGraphicsPiece : public QGraphicsObject { Q_OBJECT public: - VPGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent = nullptr); + VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent = nullptr); ~VPGraphicsPiece(); void Init(); @@ -45,7 +45,7 @@ public: * @brief GetPiece Returns the piece that corresponds to the graphics piece * @return the piece */ - VPuzzlePiece* GetPiece(); + VPPiece* GetPiece(); public slots: /** @@ -87,7 +87,7 @@ private slots: private: Q_DISABLE_COPY(VPGraphicsPiece) - VPuzzlePiece *m_piece; + VPPiece *m_piece; QPainterPath m_cuttingLine; QPainterPath m_seamLine; diff --git a/src/app/puzzle/vplayout.cpp b/src/app/puzzle/vplayout.cpp index b823d45c8..1f9087836 100644 --- a/src/app/puzzle/vplayout.cpp +++ b/src/app/puzzle/vplayout.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "vplayout.h" #include "vppiecelist.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" //--------------------------------------------------------------------------------------------------------------------- VPLayout::VPLayout() : @@ -79,9 +79,9 @@ QList VPLayout::GetPiecesLists() } //--------------------------------------------------------------------------------------------------------------------- -QList VPLayout::GetSelectedPieces() +QList VPLayout::GetSelectedPieces() { - QList result = QList(); + QList result = QList(); QList pieceLists = m_pieceLists; pieceLists.prepend(m_unplacedPieceList); @@ -303,7 +303,7 @@ VPPieceList* VPLayout::GetFocusedPieceList() } //--------------------------------------------------------------------------------------------------------------------- -void VPLayout::MovePieceToPieceList(VPuzzlePiece* piece, VPPieceList* pieceList) +void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList) { VPPieceList* pieceListBefore = piece->GetPieceList(); diff --git a/src/app/puzzle/vplayout.h b/src/app/puzzle/vplayout.h index 7c45a29ff..b03668685 100644 --- a/src/app/puzzle/vplayout.h +++ b/src/app/puzzle/vplayout.h @@ -35,7 +35,7 @@ #include "def.h" class VPPieceList; -class VPuzzlePiece; +class VPPiece; // is this the right place for the definition? enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2}; @@ -61,7 +61,7 @@ public: * @brief GetSelectedPieces Returns the list of the selected pieces * @return the selected pieces */ - QList GetSelectedPieces(); + QList GetSelectedPieces(); /** * @brief SetUnit Sets the unit of the layout to the given unit @@ -224,11 +224,11 @@ public: * @param piece the piece to move * @param pieceList the piece list to move the piece to */ - void MovePieceToPieceList(VPuzzlePiece* piece, VPPieceList* pieceList); + void MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList); signals: - void PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); + void PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); private: Q_DISABLE_COPY(VPLayout) diff --git a/src/app/puzzle/vpmaingraphicsview.cpp b/src/app/puzzle/vpmaingraphicsview.cpp index 2100a1e27..17ec5ee48 100644 --- a/src/app/puzzle/vpmaingraphicsview.cpp +++ b/src/app/puzzle/vpmaingraphicsview.cpp @@ -113,7 +113,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event) { const VPMimeDataPiece *mimePiece = qobject_cast (mime); - VPuzzlePiece *piece = mimePiece->GetPiecePtr(); + VPPiece *piece = mimePiece->GetPiecePtr(); if(piece != nullptr) { qCDebug(pMainGraphicsView(), "element dropped, %s", qUtf8Printable(piece->GetName())); @@ -141,7 +141,7 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event) for(auto graphicsPiece : tmpGraphicsPieces) { - VPuzzlePiece *piece = graphicsPiece->GetPiece(); + VPPiece *piece = graphicsPiece->GetPiece(); if(piece->GetIsSelected()) { @@ -153,7 +153,7 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void VPMainGraphicsView::on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter) +void VPMainGraphicsView::on_PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter) { Q_UNUSED(pieceListBefore) diff --git a/src/app/puzzle/vpmaingraphicsview.h b/src/app/puzzle/vpmaingraphicsview.h index ac802549d..15709c520 100644 --- a/src/app/puzzle/vpmaingraphicsview.h +++ b/src/app/puzzle/vpmaingraphicsview.h @@ -64,7 +64,7 @@ private slots: * @param pieceListBefore the piece list before the move * @param pieceListAfter the piece list after the move */ - void on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); + void on_PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); /** * @brief on_SceneSelectionChanged Slot is called when the scene selection has changed diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 24ce82e64..3b39815f3 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -164,7 +164,7 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) // TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece() - VPuzzlePiece *piece = CreatePiece(rawPiece); + VPPiece *piece = CreatePiece(rawPiece); m_layout->GetUnplacedPieceList()->AddPiece(piece); } @@ -183,9 +183,9 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece) +VPPiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece) { - VPuzzlePiece *piece = new VPuzzlePiece(); + VPPiece *piece = new VPPiece(); piece->SetName(rawPiece.GetName()); piece->SetUuid(rawPiece.GetUUID()); @@ -202,9 +202,9 @@ VPuzzlePiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece) // TODO : set all the information we need for the piece! // - connect(piece, &VPuzzlePiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged); - connect(piece, &VPuzzlePiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged); - connect(piece, &VPuzzlePiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged); + connect(piece, &VPPiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged); + connect(piece, &VPPiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged); + connect(piece, &VPPiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged); return piece; @@ -355,7 +355,7 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() ui->containerCurrentPieceData->setVisible(true); ui->containerCurrentPieceMultipleData->setVisible(false); - VPuzzlePiece *selectedPiece = m_selectedPieces.first(); + VPPiece *selectedPiece = m_selectedPieces.first(); // set the value to the current piece ui->lineEditCurrentPieceName->setText(selectedPiece->GetName()); @@ -938,7 +938,7 @@ void VPMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value) { if(m_selectedPieces.count() == 1) { - VPuzzlePiece *piece = m_selectedPieces.first(); + VPPiece *piece = m_selectedPieces.first(); piece->SetRotation(value); } } @@ -949,7 +949,7 @@ void VPMainWindow::on_CurrentPiecePositionEdited() { if(m_selectedPieces.count() == 1) { - VPuzzlePiece *piece = m_selectedPieces.first(); + VPPiece *piece = m_selectedPieces.first(); QPointF pos(UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), m_layout->GetUnit(), Unit::Px), UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), m_layout->GetUnit(), Unit::Px)); piece->SetPosition(pos); @@ -984,7 +984,7 @@ void VPMainWindow::on_PiecePositionChanged() { if(m_selectedPieces.count() == 1) { - VPuzzlePiece *piece = m_selectedPieces.first(); + VPPiece *piece = m_selectedPieces.first(); QPointF pos = piece->GetPosition(); SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX, @@ -999,7 +999,7 @@ void VPMainWindow::on_PieceRotationChanged() { if(m_selectedPieces.count() == 1) { - VPuzzlePiece *piece = m_selectedPieces.first(); + VPPiece *piece = m_selectedPieces.first(); qreal angle = piece->GetRotation(); SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle); diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index a2c7cd962..275f2fb00 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -36,7 +36,7 @@ #include "vpcarrousel.h" #include "vpmaingraphicsview.h" #include "vplayout.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" #include "../vlayout/vlayoutpiece.h" #include "vpcommandline.h" @@ -96,13 +96,13 @@ private: VPCommandLinePtr m_cmd; VPLayout *m_layout{nullptr}; - QListm_selectedPieces{QList()}; + QListm_selectedPieces{QList()}; /** * @brief CreatePiece creates a piece from the given VLayoutPiece data * @param rawPiece the raw piece data */ - VPuzzlePiece* CreatePiece(const VLayoutPiece &rawPiece); + VPPiece* CreatePiece(const VLayoutPiece &rawPiece); /** * @brief InitMenuBar Inits the menu bar (File, Edit, Help ...) diff --git a/src/app/puzzle/vpmimedatapiece.cpp b/src/app/puzzle/vpmimedatapiece.cpp index 5f7cb6c4b..a92f724e5 100644 --- a/src/app/puzzle/vpmimedatapiece.cpp +++ b/src/app/puzzle/vpmimedatapiece.cpp @@ -41,13 +41,13 @@ VPMimeDataPiece::~VPMimeDataPiece() } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece* VPMimeDataPiece::GetPiecePtr() const +VPPiece* VPMimeDataPiece::GetPiecePtr() const { return m_piece; } //--------------------------------------------------------------------------------------------------------------------- -void VPMimeDataPiece::SetPiecePtr(VPuzzlePiece* piece) +void VPMimeDataPiece::SetPiecePtr(VPPiece* piece) { m_piece = piece; } diff --git a/src/app/puzzle/vpmimedatapiece.h b/src/app/puzzle/vpmimedatapiece.h index f1bba271e..cb5ba0ca7 100644 --- a/src/app/puzzle/vpmimedatapiece.h +++ b/src/app/puzzle/vpmimedatapiece.h @@ -31,7 +31,7 @@ #include -#include "vpuzzlepiece.h" +#include "vppiece.h" class VPMimeDataPiece : public QMimeData { @@ -46,18 +46,18 @@ public: * @brief GetPiecePtr Returns the piece pointer of the mime data * @return piece pointer */ - VPuzzlePiece* GetPiecePtr() const; + VPPiece* GetPiecePtr() const; /** * @brief SetPiecePtr sets the piece pointer to the given value * @param piece the piece pointer */ - void SetPiecePtr(VPuzzlePiece* piece); + void SetPiecePtr(VPPiece* piece); private: Q_DISABLE_COPY(VPMimeDataPiece) - VPuzzlePiece *m_piece{nullptr}; + VPPiece *m_piece{nullptr}; }; diff --git a/src/app/puzzle/vpuzzlepiece.cpp b/src/app/puzzle/vppiece.cpp similarity index 85% rename from src/app/puzzle/vpuzzlepiece.cpp rename to src/app/puzzle/vppiece.cpp index 02c000465..f0c7aa71e 100644 --- a/src/app/puzzle/vpuzzlepiece.cpp +++ b/src/app/puzzle/vppiece.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlepiece.cpp + ** @file vppiece.cpp ** @author Ronan Le Tiec ** @date 13 4, 2020 ** @@ -25,7 +25,7 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "vpuzzlepiece.h" +#include "vppiece.h" #include @@ -39,77 +39,77 @@ Q_LOGGING_CATEGORY(pPiece, "p.piece") //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece::VPuzzlePiece() +VPPiece::VPPiece() { } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece::~VPuzzlePiece() +VPPiece::~VPPiece() { } //--------------------------------------------------------------------------------------------------------------------- -QString VPuzzlePiece::GetName() const +QString VPPiece::GetName() const { return m_name; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetName(const QString &name) +void VPPiece::SetName(const QString &name) { m_name = name; } //--------------------------------------------------------------------------------------------------------------------- -QUuid VPuzzlePiece::GetUuid() const +QUuid VPPiece::GetUuid() const { return m_uuid; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetUuid(const QUuid &uuid) +void VPPiece::SetUuid(const QUuid &uuid) { m_uuid = uuid; } //--------------------------------------------------------------------------------------------------------------------- -QVector VPuzzlePiece::GetCuttingLine() const +QVector VPPiece::GetCuttingLine() const { return m_cuttingLine; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetCuttingLine(const QVector &cuttingLine) +void VPPiece::SetCuttingLine(const QVector &cuttingLine) { m_cuttingLine = cuttingLine; } //--------------------------------------------------------------------------------------------------------------------- -QVector VPuzzlePiece::GetSeamLine() const +QVector VPPiece::GetSeamLine() const { return m_seamLine; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetSeamLine(const QVector &seamLine) +void VPPiece::SetSeamLine(const QVector &seamLine) { m_seamLine = seamLine; } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzlePiece::GetShowSeamLine() const +bool VPPiece::GetShowSeamLine() const { return m_showSeamline; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetShowSeamLine(bool value) +void VPPiece::SetShowSeamLine(bool value) { m_showSeamline = value; @@ -117,13 +117,13 @@ void VPuzzlePiece::SetShowSeamLine(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzlePiece::GetPieceMirrored() const +bool VPPiece::GetPieceMirrored() const { return m_mirrorPiece; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetPieceMirrored(bool value) +void VPPiece::SetPieceMirrored(bool value) { m_mirrorPiece = value; @@ -131,7 +131,7 @@ void VPuzzlePiece::SetPieceMirrored(bool value) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetPosition(QPointF point) +void VPPiece::SetPosition(QPointF point) { m_transform.translate(point.x() - m_transform.dx(), point.y() - m_transform.dy()); @@ -139,13 +139,13 @@ void VPuzzlePiece::SetPosition(QPointF point) } //--------------------------------------------------------------------------------------------------------------------- -QPointF VPuzzlePiece::GetPosition() +QPointF VPPiece::GetPosition() { return QPointF(m_transform.dx(), m_transform.dy()); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetRotation(qreal angle) +void VPPiece::SetRotation(qreal angle) { // qreal currentAngle = GetRotation(); // qreal newAngle = angle - currentAngle; @@ -172,7 +172,7 @@ void VPuzzlePiece::SetRotation(qreal angle) } //--------------------------------------------------------------------------------------------------------------------- -qreal VPuzzlePiece::GetRotation() +qreal VPPiece::GetRotation() { return m_pieceAngle; @@ -191,7 +191,7 @@ qreal VPuzzlePiece::GetRotation() } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetIsSelected(bool value) +void VPPiece::SetIsSelected(bool value) { if(m_isSelected != value) { @@ -201,54 +201,54 @@ void VPuzzlePiece::SetIsSelected(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzlePiece::GetIsSelected() +bool VPPiece::GetIsSelected() { return m_isSelected; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetIsGrainlineEnabled(bool value) +void VPPiece::SetIsGrainlineEnabled(bool value) { m_isGrainlineEnabled = value; } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzlePiece::GetIsGrainlineEnabled() +bool VPPiece::GetIsGrainlineEnabled() { return m_isGrainlineEnabled; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetGrainlineAngle(qreal value) +void VPPiece::SetGrainlineAngle(qreal value) { m_grainlineAngle = value; } //--------------------------------------------------------------------------------------------------------------------- -qreal VPuzzlePiece::GetGrainlineAngle() +qreal VPPiece::GetGrainlineAngle() { return m_grainlineAngle; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetGrainline(QVector grainline) +void VPPiece::SetGrainline(QVector grainline) { m_grainline = grainline; } //--------------------------------------------------------------------------------------------------------------------- -QVector VPuzzlePiece::GetGrainline() +QVector VPPiece::GetGrainline() { return m_grainline; } //--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPuzzlePiece::GetPieceList() +VPPieceList* VPPiece::GetPieceList() { return m_pieceList; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetPieceList(VPPieceList* pieceList) +void VPPiece::SetPieceList(VPPieceList* pieceList) { if(pieceList != m_pieceList) { @@ -257,7 +257,7 @@ void VPuzzlePiece::SetPieceList(VPPieceList* pieceList) } //--------------------------------------------------------------------------------------------------------------------- -QIcon VPuzzlePiece::PieceIcon(const QSize &size) const +QIcon VPPiece::PieceIcon(const QSize &size) const { QVector points = GetSeamLine(); if(points.isEmpty()) diff --git a/src/app/puzzle/vpuzzlepiece.h b/src/app/puzzle/vppiece.h similarity index 97% rename from src/app/puzzle/vpuzzlepiece.h rename to src/app/puzzle/vppiece.h index a1536c224..759909631 100644 --- a/src/app/puzzle/vpuzzlepiece.h +++ b/src/app/puzzle/vppiece.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlepiece.h + ** @file vpiece.h ** @author Ronan Le Tiec ** @date 13 4, 2020 ** @@ -25,8 +25,8 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef VPUZZLEPIECE_H -#define VPUZZLEPIECE_H +#ifndef VPPIECE_H +#define VPPIECE_H #include #include @@ -35,12 +35,12 @@ class VPPieceList; -class VPuzzlePiece : public QObject +class VPPiece : public QObject { Q_OBJECT public: - VPuzzlePiece(); - ~VPuzzlePiece(); + VPPiece(); + ~VPPiece(); /** * @brief GetName Returns the name of the piece @@ -226,7 +226,7 @@ signals: void PropertiesChanged(); private: - Q_DISABLE_COPY(VPuzzlePiece) + Q_DISABLE_COPY(VPPiece) QUuid m_uuid{QUuid()}; QString m_name{QString()}; QVector m_cuttingLine{QVector()}; @@ -247,4 +247,4 @@ private: VPPieceList *m_pieceList{nullptr}; }; -#endif // VPUZZLEPIECE_H +#endif // VPPIECE_H diff --git a/src/app/puzzle/vppiecelist.cpp b/src/app/puzzle/vppiecelist.cpp index 85c25454b..f6d074797 100644 --- a/src/app/puzzle/vppiecelist.cpp +++ b/src/app/puzzle/vppiecelist.cpp @@ -53,7 +53,7 @@ VPLayout* VPPieceList::GetLayout() } //--------------------------------------------------------------------------------------------------------------------- -QList VPPieceList::GetPieces() +QList VPPieceList::GetPieces() { return m_pieces; } @@ -69,7 +69,7 @@ void VPPieceList::ClearSelection() } //--------------------------------------------------------------------------------------------------------------------- -void VPPieceList::AddPiece(VPuzzlePiece *piece) +void VPPieceList::AddPiece(VPPiece *piece) { qCDebug(pPieceList(), "piece -- %s -- added to %s", qUtf8Printable(piece->GetName()), qUtf8Printable(this->GetName())); @@ -80,7 +80,7 @@ void VPPieceList::AddPiece(VPuzzlePiece *piece) } //--------------------------------------------------------------------------------------------------------------------- -void VPPieceList::RemovePiece(VPuzzlePiece *piece) +void VPPieceList::RemovePiece(VPPiece *piece) { m_pieces.removeAll(piece); piece->SetPieceList(nullptr); diff --git a/src/app/puzzle/vppiecelist.h b/src/app/puzzle/vppiecelist.h index 384f1b81f..283a0d03e 100644 --- a/src/app/puzzle/vppiecelist.h +++ b/src/app/puzzle/vppiecelist.h @@ -29,7 +29,7 @@ #define VPPIECELIST_H #include -#include "vpuzzlepiece.h" +#include "vppiece.h" class VPLayout; @@ -40,9 +40,9 @@ public: VPPieceList(VPLayout *layout); ~VPPieceList(); - QList GetPieces(); - void AddPiece(VPuzzlePiece *piece); - void RemovePiece(VPuzzlePiece *piece); + QList GetPieces(); + void AddPiece(VPPiece *piece); + void RemovePiece(VPPiece *piece); // here add some more function if we want to add/move a piece at a // certain position in the list @@ -68,18 +68,18 @@ signals: /** * @brief PieceAdded The signal is emited when a piece was added */ - void PieceAdded(VPuzzlePiece *piece); + void PieceAdded(VPPiece *piece); /** * @brief PieceRemoved The signal is emited when a piece was removed */ - void PieceRemoved(VPuzzlePiece *piece); + void PieceRemoved(VPPiece *piece); private: Q_DISABLE_COPY(VPPieceList) QString m_name{}; - QList m_pieces{}; + QList m_pieces{}; VPLayout *m_layout{nullptr}; diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 722cb8c73..59ce5d1ca 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -229,7 +229,7 @@ void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList) { if (name() == ML::TagPiece) { - VPuzzlePiece *piece = new VPuzzlePiece(); + VPPiece *piece = new VPPiece(); ReadPiece(piece); pieceList->AddPiece(piece); } @@ -242,7 +242,7 @@ void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileReader::ReadPiece(VPuzzlePiece *piece) +void VPLayoutFileReader::ReadPiece(VPPiece *piece) { Q_UNUSED(piece); SCASSERT(isStartElement() && name() == ML::TagPiece); diff --git a/src/app/puzzle/xml/vplayoutfilereader.h b/src/app/puzzle/xml/vplayoutfilereader.h index d340811b9..db38265d6 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.h +++ b/src/app/puzzle/xml/vplayoutfilereader.h @@ -33,7 +33,7 @@ #include "../ifc/xml/vabstractconverter.h" #include "vplayout.h" #include "vppiecelist.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" class VPLayoutFileReader : public QXmlStreamReader { @@ -52,7 +52,7 @@ private: void ReadTiles(VPLayout *layout); void ReadPieceLists(VPLayout *layout); void ReadPieceList(VPPieceList *pieceList); - void ReadPiece(VPuzzlePiece *piece); + void ReadPiece(VPPiece *piece); QMarginsF ReadMargins(); QSizeF ReadSize(); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index 97d738928..92832f6c0 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -29,7 +29,7 @@ #include "vplayoutfilewriter.h" #include "vplayout.h" #include "vppiecelist.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" #include "vplayoutliterals.h" #include "../ifc/xml/vlayoutconverter.h" @@ -148,7 +148,7 @@ void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList, const QString &t //SetAttribute("selected", pieceList->GetIsSelected()); - QList pieces = pieceList->GetPieces(); + QList pieces = pieceList->GetPieces(); for (auto piece : pieces) { WritePiece(piece); @@ -158,7 +158,7 @@ void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList, const QString &t } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WritePiece(VPuzzlePiece *piece) +void VPLayoutFileWriter::WritePiece(VPPiece *piece) { Q_UNUSED(piece); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h index 522b2ad8a..a63ee4f0b 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -36,7 +36,7 @@ class VPLayout; class VPPieceList; -class VPuzzlePiece; +class VPPiece; class QFile; class QMarginsF; @@ -56,7 +56,7 @@ private: void WritePieceLists(VPLayout *layout); void WritePieceList(VPPieceList *pieceList); void WritePieceList(VPPieceList *pieceList, const QString &tagName); - void WritePiece(VPuzzlePiece *piece); + void WritePiece(VPPiece *piece); void WriteMargins(const QMarginsF &margins); void WriteSize(QSizeF size);