Refactoring VPuzzlePiece

This commit is contained in:
Ronan Le Tiec 2020-05-23 15:42:51 +02:00
parent 6079d69c93
commit 83666c090f
25 changed files with 117 additions and 117 deletions

View File

@ -17,8 +17,8 @@ SOURCES += \
$$PWD/vpmaingraphicsview.cpp \ $$PWD/vpmaingraphicsview.cpp \
$$PWD/vpmainwindow.cpp \ $$PWD/vpmainwindow.cpp \
$$PWD/vpmimedatapiece.cpp \ $$PWD/vpmimedatapiece.cpp \
$$PWD/vppiece.cpp \
$$PWD/vppiecelist.cpp \ $$PWD/vppiecelist.cpp \
$$PWD/vpuzzlepiece.cpp \
$$PWD/vpuzzlesettings.cpp \ $$PWD/vpuzzlesettings.cpp \
$$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutfilereader.cpp \
$$PWD/xml/vplayoutfilewriter.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \
@ -41,9 +41,9 @@ HEADERS += \
$$PWD/vpmaingraphicsview.h \ $$PWD/vpmaingraphicsview.h \
$$PWD/vpmainwindow.h \ $$PWD/vpmainwindow.h \
$$PWD/vpmimedatapiece.h \ $$PWD/vpmimedatapiece.h \
$$PWD/vppiece.h \
$$PWD/vppiecelist.h \ $$PWD/vppiecelist.h \
$$PWD/vpstable.h \ $$PWD/vpstable.h \
$$PWD/vpuzzlepiece.h \
$$PWD/vpuzzlesettings.h \ $$PWD/vpuzzlesettings.h \
$$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutfilereader.h \
$$PWD/xml/vplayoutfilewriter.h \ $$PWD/xml/vplayoutfilewriter.h \

View File

@ -106,7 +106,7 @@ void VPCarrousel::on_ActivePieceListChanged(int index)
if (pieceList) if (pieceList)
{ {
QList<VPuzzlePiece*> pieces = pieceList->GetPieces(); QList<VPPiece*> pieces = pieceList->GetPieces();
for (auto piece : pieces) for (auto piece : pieces)
{ {

View File

@ -33,7 +33,7 @@
#include <QComboBox> #include <QComboBox>
#include <QScrollArea> #include <QScrollArea>
#include "vplayout.h" #include "vplayout.h"
#include "vpuzzlepiece.h" #include "vppiece.h"
namespace Ui namespace Ui
{ {

View File

@ -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_piece(piece),
m_carrouselPieceList(carrouselPieceList), m_carrouselPieceList(carrouselPieceList),
m_dragStart(QPoint()) m_dragStart(QPoint())
@ -98,7 +98,7 @@ void VPCarrouselPiece::Init()
// connect the signals // 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 // then refresh the data
Refresh(); Refresh();
@ -147,7 +147,7 @@ void VPCarrouselPiece::Refresh()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzlePiece * VPCarrouselPiece::GetPiece() VPPiece * VPCarrouselPiece::GetPiece()
{ {
return m_piece; return m_piece;
} }

View File

@ -33,7 +33,7 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <QMouseEvent> #include <QMouseEvent>
#include "vpuzzlepiece.h" #include "vppiece.h"
#include "vpcarrouselpiecepreview.h" #include "vpcarrouselpiecepreview.h"
@ -43,7 +43,7 @@ class VPCarrouselPiece : public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselPieceList); explicit VPCarrouselPiece(VPPiece *piece, VPCarrouselPieceList *carrouselPieceList);
~VPCarrouselPiece(); ~VPCarrouselPiece();
void Init(); void Init();
@ -59,7 +59,7 @@ public:
* @brief GetPiece Returns the corresponding layout piece * @brief GetPiece Returns the corresponding layout piece
* @return the corresponding layout piece * @return the corresponding layout piece
*/ */
VPuzzlePiece * GetPiece(); VPPiece * GetPiece();
public slots: public slots:
void on_PieceSelectionChanged(); void on_PieceSelectionChanged();
@ -81,7 +81,7 @@ private slots:
private: private:
Q_DISABLE_COPY(VPCarrouselPiece) Q_DISABLE_COPY(VPCarrouselPiece)
VPuzzlePiece *m_piece; VPPiece *m_piece;
VPCarrouselPieceList *m_carrouselPieceList; VPCarrouselPieceList *m_carrouselPieceList;

View File

@ -73,11 +73,11 @@ void VPCarrouselPieceList::Refresh()
Clear(); Clear();
// Updates the carrousel pieces from the pieces list // Updates the carrousel pieces from the pieces list
QList<VPuzzlePiece*> pieces = m_pieceList->GetPieces(); QList<VPPiece*> pieces = m_pieceList->GetPieces();
// sort the pieces in alphabetical order // sort the pieces in alphabetical order
std::sort(pieces.begin(), pieces.end(), 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 // 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) 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) for (auto carrouselPiece : m_carrouselPieces)
{ {

View File

@ -72,12 +72,12 @@ private slots:
/** /**
* @brief on_PieceUpdated This slot is called when a piece was added * @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 * @brief on_PieceUpdated This slot is called when a piece was removed
*/ */
void on_PieceRemoved(VPuzzlePiece* piece); void on_PieceRemoved(VPPiece* piece);
}; };

View File

@ -39,7 +39,7 @@
#include <QtMath> #include <QtMath>
#include <QGraphicsScene> #include <QGraphicsScene>
#include "vpuzzlepiece.h" #include "vppiece.h"
#include "vppiecelist.h" #include "vppiecelist.h"
#include "vplayout.h" #include "vplayout.h"
@ -47,7 +47,7 @@
Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPGraphicsPiece::VPGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent) : VPGraphicsPiece::VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent) :
QGraphicsObject(parent), QGraphicsObject(parent),
m_piece(piece), m_piece(piece),
m_cuttingLine(QPainterPath()), m_cuttingLine(QPainterPath()),
@ -102,13 +102,13 @@ void VPGraphicsPiece::Init()
// TODO : initialises the other elements labels, passmarks etc. // TODO : initialises the other elements labels, passmarks etc.
// Initialises the connectors // Initialises the connectors
connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPGraphicsPiece::on_PieceSelectionChanged); connect(m_piece, &VPPiece::SelectionChanged, this, &VPGraphicsPiece::on_PieceSelectionChanged);
connect(m_piece, &VPuzzlePiece::PositionChanged, this, &VPGraphicsPiece::on_PiecePositionChanged); connect(m_piece, &VPPiece::PositionChanged, this, &VPGraphicsPiece::on_PiecePositionChanged);
connect(m_piece, &VPuzzlePiece::RotationChanged, this, &VPGraphicsPiece::on_PieceRotationChanged); connect(m_piece, &VPPiece::RotationChanged, this, &VPGraphicsPiece::on_PieceRotationChanged);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzlePiece* VPGraphicsPiece::GetPiece() VPPiece* VPGraphicsPiece::GetPiece()
{ {
return m_piece; return m_piece;
} }

View File

@ -31,13 +31,13 @@
#include <QGraphicsItem> #include <QGraphicsItem>
class VPuzzlePiece; class VPPiece;
class VPGraphicsPiece : public QGraphicsObject class VPGraphicsPiece : public QGraphicsObject
{ {
Q_OBJECT Q_OBJECT
public: public:
VPGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent = nullptr); VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent = nullptr);
~VPGraphicsPiece(); ~VPGraphicsPiece();
void Init(); void Init();
@ -45,7 +45,7 @@ public:
* @brief GetPiece Returns the piece that corresponds to the graphics piece * @brief GetPiece Returns the piece that corresponds to the graphics piece
* @return the piece * @return the piece
*/ */
VPuzzlePiece* GetPiece(); VPPiece* GetPiece();
public slots: public slots:
/** /**
@ -87,7 +87,7 @@ private slots:
private: private:
Q_DISABLE_COPY(VPGraphicsPiece) Q_DISABLE_COPY(VPGraphicsPiece)
VPuzzlePiece *m_piece; VPPiece *m_piece;
QPainterPath m_cuttingLine; QPainterPath m_cuttingLine;
QPainterPath m_seamLine; QPainterPath m_seamLine;

View File

@ -27,7 +27,7 @@
*************************************************************************/ *************************************************************************/
#include "vplayout.h" #include "vplayout.h"
#include "vppiecelist.h" #include "vppiecelist.h"
#include "vpuzzlepiece.h" #include "vppiece.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPLayout::VPLayout() : VPLayout::VPLayout() :
@ -79,9 +79,9 @@ QList<VPPieceList *> VPLayout::GetPiecesLists()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QList<VPuzzlePiece *> VPLayout::GetSelectedPieces() QList<VPPiece *> VPLayout::GetSelectedPieces()
{ {
QList<VPuzzlePiece *> result = QList<VPuzzlePiece *>(); QList<VPPiece *> result = QList<VPPiece *>();
QList<VPPieceList *> pieceLists = m_pieceLists; QList<VPPieceList *> pieceLists = m_pieceLists;
pieceLists.prepend(m_unplacedPieceList); 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(); VPPieceList* pieceListBefore = piece->GetPieceList();

View File

@ -35,7 +35,7 @@
#include "def.h" #include "def.h"
class VPPieceList; class VPPieceList;
class VPuzzlePiece; class VPPiece;
// is this the right place for the definition? // is this the right place for the definition?
enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2}; enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2};
@ -61,7 +61,7 @@ public:
* @brief GetSelectedPieces Returns the list of the selected pieces * @brief GetSelectedPieces Returns the list of the selected pieces
* @return the selected pieces * @return the selected pieces
*/ */
QList<VPuzzlePiece *> GetSelectedPieces(); QList<VPPiece *> GetSelectedPieces();
/** /**
* @brief SetUnit Sets the unit of the layout to the given unit * @brief SetUnit Sets the unit of the layout to the given unit
@ -224,11 +224,11 @@ public:
* @param piece the piece to move * @param piece the piece to move
* @param pieceList the piece list to move the piece to * @param pieceList the piece list to move the piece to
*/ */
void MovePieceToPieceList(VPuzzlePiece* piece, VPPieceList* pieceList); void MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList);
signals: signals:
void PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); void PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter);
private: private:
Q_DISABLE_COPY(VPLayout) Q_DISABLE_COPY(VPLayout)

View File

@ -113,7 +113,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
{ {
const VPMimeDataPiece *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime); const VPMimeDataPiece *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime);
VPuzzlePiece *piece = mimePiece->GetPiecePtr(); VPPiece *piece = mimePiece->GetPiecePtr();
if(piece != nullptr) if(piece != nullptr)
{ {
qCDebug(pMainGraphicsView(), "element dropped, %s", qUtf8Printable(piece->GetName())); qCDebug(pMainGraphicsView(), "element dropped, %s", qUtf8Printable(piece->GetName()));
@ -141,7 +141,7 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
for(auto graphicsPiece : tmpGraphicsPieces) for(auto graphicsPiece : tmpGraphicsPieces)
{ {
VPuzzlePiece *piece = graphicsPiece->GetPiece(); VPPiece *piece = graphicsPiece->GetPiece();
if(piece->GetIsSelected()) 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) Q_UNUSED(pieceListBefore)

View File

@ -64,7 +64,7 @@ private slots:
* @param pieceListBefore the piece list before the move * @param pieceListBefore the piece list before the move
* @param pieceListAfter the piece list after 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 * @brief on_SceneSelectionChanged Slot is called when the scene selection has changed

View File

@ -164,7 +164,7 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
// TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece() // TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece()
VPuzzlePiece *piece = CreatePiece(rawPiece); VPPiece *piece = CreatePiece(rawPiece);
m_layout->GetUnplacedPieceList()->AddPiece(piece); 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->SetName(rawPiece.GetName());
piece->SetUuid(rawPiece.GetUUID()); piece->SetUuid(rawPiece.GetUUID());
@ -202,9 +202,9 @@ VPuzzlePiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
// TODO : set all the information we need for the piece! // TODO : set all the information we need for the piece!
// //
connect(piece, &VPuzzlePiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged); connect(piece, &VPPiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged);
connect(piece, &VPuzzlePiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged); connect(piece, &VPPiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged);
connect(piece, &VPuzzlePiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged); connect(piece, &VPPiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged);
return piece; return piece;
@ -355,7 +355,7 @@ void VPMainWindow::SetPropertyTabCurrentPieceData()
ui->containerCurrentPieceData->setVisible(true); ui->containerCurrentPieceData->setVisible(true);
ui->containerCurrentPieceMultipleData->setVisible(false); ui->containerCurrentPieceMultipleData->setVisible(false);
VPuzzlePiece *selectedPiece = m_selectedPieces.first(); VPPiece *selectedPiece = m_selectedPieces.first();
// set the value to the current piece // set the value to the current piece
ui->lineEditCurrentPieceName->setText(selectedPiece->GetName()); ui->lineEditCurrentPieceName->setText(selectedPiece->GetName());
@ -938,7 +938,7 @@ void VPMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value)
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
VPuzzlePiece *piece = m_selectedPieces.first(); VPPiece *piece = m_selectedPieces.first();
piece->SetRotation(value); piece->SetRotation(value);
} }
} }
@ -949,7 +949,7 @@ void VPMainWindow::on_CurrentPiecePositionEdited()
{ {
if(m_selectedPieces.count() == 1) 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), QPointF pos(UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), m_layout->GetUnit(), Unit::Px),
UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), m_layout->GetUnit(), Unit::Px)); UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), m_layout->GetUnit(), Unit::Px));
piece->SetPosition(pos); piece->SetPosition(pos);
@ -984,7 +984,7 @@ void VPMainWindow::on_PiecePositionChanged()
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
VPuzzlePiece *piece = m_selectedPieces.first(); VPPiece *piece = m_selectedPieces.first();
QPointF pos = piece->GetPosition(); QPointF pos = piece->GetPosition();
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX, SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX,
@ -999,7 +999,7 @@ void VPMainWindow::on_PieceRotationChanged()
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
VPuzzlePiece *piece = m_selectedPieces.first(); VPPiece *piece = m_selectedPieces.first();
qreal angle = piece->GetRotation(); qreal angle = piece->GetRotation();
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle); SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle);

View File

@ -36,7 +36,7 @@
#include "vpcarrousel.h" #include "vpcarrousel.h"
#include "vpmaingraphicsview.h" #include "vpmaingraphicsview.h"
#include "vplayout.h" #include "vplayout.h"
#include "vpuzzlepiece.h" #include "vppiece.h"
#include "../vlayout/vlayoutpiece.h" #include "../vlayout/vlayoutpiece.h"
#include "vpcommandline.h" #include "vpcommandline.h"
@ -96,13 +96,13 @@ private:
VPCommandLinePtr m_cmd; VPCommandLinePtr m_cmd;
VPLayout *m_layout{nullptr}; VPLayout *m_layout{nullptr};
QList<VPuzzlePiece *>m_selectedPieces{QList<VPuzzlePiece *>()}; QList<VPPiece *>m_selectedPieces{QList<VPPiece *>()};
/** /**
* @brief CreatePiece creates a piece from the given VLayoutPiece data * @brief CreatePiece creates a piece from the given VLayoutPiece data
* @param rawPiece the raw piece 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 ...) * @brief InitMenuBar Inits the menu bar (File, Edit, Help ...)

View File

@ -41,13 +41,13 @@ VPMimeDataPiece::~VPMimeDataPiece()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzlePiece* VPMimeDataPiece::GetPiecePtr() const VPPiece* VPMimeDataPiece::GetPiecePtr() const
{ {
return m_piece; return m_piece;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMimeDataPiece::SetPiecePtr(VPuzzlePiece* piece) void VPMimeDataPiece::SetPiecePtr(VPPiece* piece)
{ {
m_piece = piece; m_piece = piece;
} }

View File

@ -31,7 +31,7 @@
#include <QMimeData> #include <QMimeData>
#include "vpuzzlepiece.h" #include "vppiece.h"
class VPMimeDataPiece : public QMimeData class VPMimeDataPiece : public QMimeData
{ {
@ -46,18 +46,18 @@ public:
* @brief GetPiecePtr Returns the piece pointer of the mime data * @brief GetPiecePtr Returns the piece pointer of the mime data
* @return piece pointer * @return piece pointer
*/ */
VPuzzlePiece* GetPiecePtr() const; VPPiece* GetPiecePtr() const;
/** /**
* @brief SetPiecePtr sets the piece pointer to the given value * @brief SetPiecePtr sets the piece pointer to the given value
* @param piece the piece pointer * @param piece the piece pointer
*/ */
void SetPiecePtr(VPuzzlePiece* piece); void SetPiecePtr(VPPiece* piece);
private: private:
Q_DISABLE_COPY(VPMimeDataPiece) Q_DISABLE_COPY(VPMimeDataPiece)
VPuzzlePiece *m_piece{nullptr}; VPPiece *m_piece{nullptr};
}; };

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlepiece.cpp ** @file vppiece.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,7 +25,7 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlepiece.h" #include "vppiece.h"
#include <QtMath> #include <QtMath>
@ -39,77 +39,77 @@
Q_LOGGING_CATEGORY(pPiece, "p.piece") 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; return m_name;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetName(const QString &name) void VPPiece::SetName(const QString &name)
{ {
m_name = name; m_name = name;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QUuid VPuzzlePiece::GetUuid() const QUuid VPPiece::GetUuid() const
{ {
return m_uuid; return m_uuid;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetUuid(const QUuid &uuid) void VPPiece::SetUuid(const QUuid &uuid)
{ {
m_uuid = uuid; m_uuid = uuid;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VPuzzlePiece::GetCuttingLine() const QVector<QPointF> VPPiece::GetCuttingLine() const
{ {
return m_cuttingLine; return m_cuttingLine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetCuttingLine(const QVector<QPointF> &cuttingLine) void VPPiece::SetCuttingLine(const QVector<QPointF> &cuttingLine)
{ {
m_cuttingLine = cuttingLine; m_cuttingLine = cuttingLine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VPuzzlePiece::GetSeamLine() const QVector<QPointF> VPPiece::GetSeamLine() const
{ {
return m_seamLine; return m_seamLine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetSeamLine(const QVector<QPointF> &seamLine) void VPPiece::SetSeamLine(const QVector<QPointF> &seamLine)
{ {
m_seamLine = seamLine; m_seamLine = seamLine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetShowSeamLine() const bool VPPiece::GetShowSeamLine() const
{ {
return m_showSeamline; return m_showSeamline;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetShowSeamLine(bool value) void VPPiece::SetShowSeamLine(bool value)
{ {
m_showSeamline = value; m_showSeamline = value;
@ -117,13 +117,13 @@ void VPuzzlePiece::SetShowSeamLine(bool value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetPieceMirrored() const bool VPPiece::GetPieceMirrored() const
{ {
return m_mirrorPiece; return m_mirrorPiece;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetPieceMirrored(bool value) void VPPiece::SetPieceMirrored(bool value)
{ {
m_mirrorPiece = 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()); 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()); return QPointF(m_transform.dx(), m_transform.dy());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetRotation(qreal angle) void VPPiece::SetRotation(qreal angle)
{ {
// qreal currentAngle = GetRotation(); // qreal currentAngle = GetRotation();
// qreal newAngle = angle - currentAngle; // qreal newAngle = angle - currentAngle;
@ -172,7 +172,7 @@ void VPuzzlePiece::SetRotation(qreal angle)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VPuzzlePiece::GetRotation() qreal VPPiece::GetRotation()
{ {
return m_pieceAngle; return m_pieceAngle;
@ -191,7 +191,7 @@ qreal VPuzzlePiece::GetRotation()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetIsSelected(bool value) void VPPiece::SetIsSelected(bool value)
{ {
if(m_isSelected != value) if(m_isSelected != value)
{ {
@ -201,54 +201,54 @@ void VPuzzlePiece::SetIsSelected(bool value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetIsSelected() bool VPPiece::GetIsSelected()
{ {
return m_isSelected; return m_isSelected;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetIsGrainlineEnabled(bool value) void VPPiece::SetIsGrainlineEnabled(bool value)
{ {
m_isGrainlineEnabled = value; m_isGrainlineEnabled = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetIsGrainlineEnabled() bool VPPiece::GetIsGrainlineEnabled()
{ {
return m_isGrainlineEnabled; return m_isGrainlineEnabled;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetGrainlineAngle(qreal value) void VPPiece::SetGrainlineAngle(qreal value)
{ {
m_grainlineAngle = value; m_grainlineAngle = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VPuzzlePiece::GetGrainlineAngle() qreal VPPiece::GetGrainlineAngle()
{ {
return m_grainlineAngle; return m_grainlineAngle;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetGrainline(QVector<QPointF> grainline) void VPPiece::SetGrainline(QVector<QPointF> grainline)
{ {
m_grainline = grainline; m_grainline = grainline;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VPuzzlePiece::GetGrainline() QVector<QPointF> VPPiece::GetGrainline()
{ {
return m_grainline; return m_grainline;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPuzzlePiece::GetPieceList() VPPieceList* VPPiece::GetPieceList()
{ {
return m_pieceList; return m_pieceList;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetPieceList(VPPieceList* pieceList) void VPPiece::SetPieceList(VPPieceList* pieceList)
{ {
if(pieceList != m_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<QPointF> points = GetSeamLine(); QVector<QPointF> points = GetSeamLine();
if(points.isEmpty()) if(points.isEmpty())

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlepiece.h ** @file vpiece.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,8 +25,8 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLEPIECE_H #ifndef VPPIECE_H
#define VPUZZLEPIECE_H #define VPPIECE_H
#include <QUuid> #include <QUuid>
#include <QVector> #include <QVector>
@ -35,12 +35,12 @@
class VPPieceList; class VPPieceList;
class VPuzzlePiece : public QObject class VPPiece : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzlePiece(); VPPiece();
~VPuzzlePiece(); ~VPPiece();
/** /**
* @brief GetName Returns the name of the piece * @brief GetName Returns the name of the piece
@ -226,7 +226,7 @@ signals:
void PropertiesChanged(); void PropertiesChanged();
private: private:
Q_DISABLE_COPY(VPuzzlePiece) Q_DISABLE_COPY(VPPiece)
QUuid m_uuid{QUuid()}; QUuid m_uuid{QUuid()};
QString m_name{QString()}; QString m_name{QString()};
QVector<QPointF> m_cuttingLine{QVector<QPointF>()}; QVector<QPointF> m_cuttingLine{QVector<QPointF>()};
@ -247,4 +247,4 @@ private:
VPPieceList *m_pieceList{nullptr}; VPPieceList *m_pieceList{nullptr};
}; };
#endif // VPUZZLEPIECE_H #endif // VPPIECE_H

View File

@ -53,7 +53,7 @@ VPLayout* VPPieceList::GetLayout()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QList<VPuzzlePiece *> VPPieceList::GetPieces() QList<VPPiece *> VPPieceList::GetPieces()
{ {
return m_pieces; 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())); 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); m_pieces.removeAll(piece);
piece->SetPieceList(nullptr); piece->SetPieceList(nullptr);

View File

@ -29,7 +29,7 @@
#define VPPIECELIST_H #define VPPIECELIST_H
#include <QList> #include <QList>
#include "vpuzzlepiece.h" #include "vppiece.h"
class VPLayout; class VPLayout;
@ -40,9 +40,9 @@ public:
VPPieceList(VPLayout *layout); VPPieceList(VPLayout *layout);
~VPPieceList(); ~VPPieceList();
QList<VPuzzlePiece *> GetPieces(); QList<VPPiece *> GetPieces();
void AddPiece(VPuzzlePiece *piece); void AddPiece(VPPiece *piece);
void RemovePiece(VPuzzlePiece *piece); void RemovePiece(VPPiece *piece);
// here add some more function if we want to add/move a piece at a // here add some more function if we want to add/move a piece at a
// certain position in the list // certain position in the list
@ -68,18 +68,18 @@ signals:
/** /**
* @brief PieceAdded The signal is emited when a piece was added * @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 * @brief PieceRemoved The signal is emited when a piece was removed
*/ */
void PieceRemoved(VPuzzlePiece *piece); void PieceRemoved(VPPiece *piece);
private: private:
Q_DISABLE_COPY(VPPieceList) Q_DISABLE_COPY(VPPieceList)
QString m_name{}; QString m_name{};
QList<VPuzzlePiece *> m_pieces{}; QList<VPPiece *> m_pieces{};
VPLayout *m_layout{nullptr}; VPLayout *m_layout{nullptr};

View File

@ -229,7 +229,7 @@ void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList)
{ {
if (name() == ML::TagPiece) if (name() == ML::TagPiece)
{ {
VPuzzlePiece *piece = new VPuzzlePiece(); VPPiece *piece = new VPPiece();
ReadPiece(piece); ReadPiece(piece);
pieceList->AddPiece(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); Q_UNUSED(piece);
SCASSERT(isStartElement() && name() == ML::TagPiece); SCASSERT(isStartElement() && name() == ML::TagPiece);

View File

@ -33,7 +33,7 @@
#include "../ifc/xml/vabstractconverter.h" #include "../ifc/xml/vabstractconverter.h"
#include "vplayout.h" #include "vplayout.h"
#include "vppiecelist.h" #include "vppiecelist.h"
#include "vpuzzlepiece.h" #include "vppiece.h"
class VPLayoutFileReader : public QXmlStreamReader class VPLayoutFileReader : public QXmlStreamReader
{ {
@ -52,7 +52,7 @@ private:
void ReadTiles(VPLayout *layout); void ReadTiles(VPLayout *layout);
void ReadPieceLists(VPLayout *layout); void ReadPieceLists(VPLayout *layout);
void ReadPieceList(VPPieceList *pieceList); void ReadPieceList(VPPieceList *pieceList);
void ReadPiece(VPuzzlePiece *piece); void ReadPiece(VPPiece *piece);
QMarginsF ReadMargins(); QMarginsF ReadMargins();
QSizeF ReadSize(); QSizeF ReadSize();

View File

@ -29,7 +29,7 @@
#include "vplayoutfilewriter.h" #include "vplayoutfilewriter.h"
#include "vplayout.h" #include "vplayout.h"
#include "vppiecelist.h" #include "vppiecelist.h"
#include "vpuzzlepiece.h" #include "vppiece.h"
#include "vplayoutliterals.h" #include "vplayoutliterals.h"
#include "../ifc/xml/vlayoutconverter.h" #include "../ifc/xml/vlayoutconverter.h"
@ -148,7 +148,7 @@ void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList, const QString &t
//SetAttribute("selected", pieceList->GetIsSelected()); //SetAttribute("selected", pieceList->GetIsSelected());
QList<VPuzzlePiece*> pieces = pieceList->GetPieces(); QList<VPPiece*> pieces = pieceList->GetPieces();
for (auto piece : pieces) for (auto piece : pieces)
{ {
WritePiece(piece); 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); Q_UNUSED(piece);

View File

@ -36,7 +36,7 @@
class VPLayout; class VPLayout;
class VPPieceList; class VPPieceList;
class VPuzzlePiece; class VPPiece;
class QFile; class QFile;
class QMarginsF; class QMarginsF;
@ -56,7 +56,7 @@ private:
void WritePieceLists(VPLayout *layout); void WritePieceLists(VPLayout *layout);
void WritePieceList(VPPieceList *pieceList); void WritePieceList(VPPieceList *pieceList);
void WritePieceList(VPPieceList *pieceList, const QString &tagName); void WritePieceList(VPPieceList *pieceList, const QString &tagName);
void WritePiece(VPuzzlePiece *piece); void WritePiece(VPPiece *piece);
void WriteMargins(const QMarginsF &margins); void WriteMargins(const QMarginsF &margins);
void WriteSize(QSizeF size); void WriteSize(QSizeF size);