Refactoring VPuzzlePiece
This commit is contained in:
parent
6079d69c93
commit
83666c090f
|
@ -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 \
|
||||
|
|
|
@ -106,7 +106,7 @@ void VPCarrousel::on_ActivePieceListChanged(int index)
|
|||
|
||||
if (pieceList)
|
||||
{
|
||||
QList<VPuzzlePiece*> pieces = pieceList->GetPieces();
|
||||
QList<VPPiece*> pieces = pieceList->GetPieces();
|
||||
|
||||
for (auto piece : pieces)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QComboBox>
|
||||
#include <QScrollArea>
|
||||
#include "vplayout.h"
|
||||
#include "vpuzzlepiece.h"
|
||||
#include "vppiece.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QGraphicsView>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#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;
|
||||
|
||||
|
|
|
@ -73,11 +73,11 @@ void VPCarrouselPieceList::Refresh()
|
|||
Clear();
|
||||
|
||||
// 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
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <QtMath>
|
||||
#include <QGraphicsScene>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
|
||||
#include <QGraphicsItem>
|
||||
|
||||
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;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*************************************************************************/
|
||||
#include "vplayout.h"
|
||||
#include "vppiecelist.h"
|
||||
#include "vpuzzlepiece.h"
|
||||
#include "vppiece.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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;
|
||||
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();
|
||||
|
||||
|
|
|
@ -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<VPuzzlePiece *> GetSelectedPieces();
|
||||
QList<VPPiece *> 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)
|
||||
|
|
|
@ -113,7 +113,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
|
|||
{
|
||||
const VPMimeDataPiece *mimePiece = qobject_cast<const VPMimeDataPiece *> (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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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};
|
||||
QList<VPuzzlePiece *>m_selectedPieces{QList<VPuzzlePiece *>()};
|
||||
QList<VPPiece *>m_selectedPieces{QList<VPPiece *>()};
|
||||
|
||||
/**
|
||||
* @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 ...)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <QMimeData>
|
||||
|
||||
#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};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
#include "vpuzzlepiece.h"
|
||||
#include "vppiece.h"
|
||||
|
||||
#include <QtMath>
|
||||
|
||||
|
@ -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<QPointF> VPuzzlePiece::GetCuttingLine() const
|
||||
QVector<QPointF> VPPiece::GetCuttingLine() const
|
||||
{
|
||||
return m_cuttingLine;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPuzzlePiece::SetCuttingLine(const QVector<QPointF> &cuttingLine)
|
||||
void VPPiece::SetCuttingLine(const QVector<QPointF> &cuttingLine)
|
||||
{
|
||||
m_cuttingLine = cuttingLine;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VPuzzlePiece::GetSeamLine() const
|
||||
QVector<QPointF> VPPiece::GetSeamLine() const
|
||||
{
|
||||
return m_seamLine;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPuzzlePiece::SetSeamLine(const QVector<QPointF> &seamLine)
|
||||
void VPPiece::SetSeamLine(const QVector<QPointF> &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<QPointF> grainline)
|
||||
void VPPiece::SetGrainline(QVector<QPointF> grainline)
|
||||
{
|
||||
m_grainline = grainline;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VPuzzlePiece::GetGrainline()
|
||||
QVector<QPointF> 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<QPointF> points = GetSeamLine();
|
||||
if(points.isEmpty())
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
#ifndef VPUZZLEPIECE_H
|
||||
#define VPUZZLEPIECE_H
|
||||
#ifndef VPPIECE_H
|
||||
#define VPPIECE_H
|
||||
|
||||
#include <QUuid>
|
||||
#include <QVector>
|
||||
|
@ -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<QPointF> m_cuttingLine{QVector<QPointF>()};
|
||||
|
@ -247,4 +247,4 @@ private:
|
|||
VPPieceList *m_pieceList{nullptr};
|
||||
};
|
||||
|
||||
#endif // VPUZZLEPIECE_H
|
||||
#endif // VPPIECE_H
|
|
@ -53,7 +53,7 @@ VPLayout* VPPieceList::GetLayout()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QList<VPuzzlePiece *> VPPieceList::GetPieces()
|
||||
QList<VPPiece *> 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);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#define VPPIECELIST_H
|
||||
|
||||
#include <QList>
|
||||
#include "vpuzzlepiece.h"
|
||||
#include "vppiece.h"
|
||||
|
||||
class VPLayout;
|
||||
|
||||
|
@ -40,9 +40,9 @@ public:
|
|||
VPPieceList(VPLayout *layout);
|
||||
~VPPieceList();
|
||||
|
||||
QList<VPuzzlePiece *> GetPieces();
|
||||
void AddPiece(VPuzzlePiece *piece);
|
||||
void RemovePiece(VPuzzlePiece *piece);
|
||||
QList<VPPiece *> 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<VPuzzlePiece *> m_pieces{};
|
||||
QList<VPPiece *> m_pieces{};
|
||||
|
||||
VPLayout *m_layout{nullptr};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<VPuzzlePiece*> pieces = pieceList->GetPieces();
|
||||
QList<VPPiece*> 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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user