Refactoring VPieceCarrouselLayer

This commit is contained in:
Ronan Le Tiec 2020-05-23 14:33:02 +02:00
parent 690606b4e5
commit 8ca77baef0
5 changed files with 29 additions and 29 deletions

View File

@ -6,6 +6,7 @@ SOURCES += \
$$PWD/main.cpp \
$$PWD/vpapplication.cpp \
$$PWD/vpcarrousel.cpp \
$$PWD/vpcarrouselpiecelist.cpp \
$$PWD/vpcommands.cpp \
$$PWD/vpiececarrouselpiecepreview.cpp \
$$PWD/vpmainwindow.cpp \
@ -21,7 +22,6 @@ SOURCES += \
$$PWD/xml/vplayoutfilereader.cpp \
$$PWD/xml/vplayoutfilewriter.cpp \
$$PWD/xml/vplayoutliterals.cpp \
$$PWD/vpiececarrousellayer.cpp \
$$PWD/vpiececarrouselpiece.cpp
*msvc*:SOURCES +=
@ -30,6 +30,7 @@ HEADERS += \
$$PWD/dialogs/vpdialogabout.h \
$$PWD/vpapplication.h \
$$PWD/vpcarrousel.h \
$$PWD/vpcarrouselpiecelist.h \
$$PWD/vpcommands.h \
$$PWD/vpiececarrouselpiecepreview.h \
$$PWD/vpmainwindow.h \
@ -46,7 +47,6 @@ HEADERS += \
$$PWD/xml/vplayoutfilereader.h \
$$PWD/xml/vplayoutfilewriter.h \
$$PWD/xml/vplayoutliterals.h \
$$PWD/vpiececarrousellayer.h \
$$PWD/vpiececarrouselpiece.h
FORMS += \

View File

@ -1,6 +1,6 @@
/************************************************************************
**
** @file vpiececarrousellayer.cpp
** @file vpcarrouselpiecelist.cpp
** @author Ronan Le Tiec
** @date 25 4, 2020
**
@ -26,7 +26,7 @@
**
*************************************************************************/
#include "vpiececarrousellayer.h"
#include "vpcarrouselpiecelist.h"
#include "vpcarrousel.h"
#include "../vmisc/backport/qoverload.h"
@ -37,7 +37,7 @@
Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer")
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *carrousel) :
VPCarrouselPieceList::VPCarrouselPieceList(VPuzzleLayer *layer, VPCarrousel *carrousel) :
m_layer(layer),
m_carrousel(carrousel),
m_carrouselPieces(QList<VPieceCarrouselPiece*>())
@ -46,13 +46,13 @@ VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *car
}
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselLayer::~VPieceCarrouselLayer()
VPCarrouselPieceList::~VPCarrouselPieceList()
{
Clear();
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::Init()
void VPCarrouselPieceList::Init()
{
// initiales the structure
QVBoxLayout *layoutPiecesLayout = new QVBoxLayout();
@ -63,12 +63,12 @@ void VPieceCarrouselLayer::Init()
Refresh();
// add the connections
connect(m_layer, &VPuzzleLayer::PieceAdded, this, &VPieceCarrouselLayer::on_PieceAdded);
connect(m_layer, &VPuzzleLayer::PieceRemoved, this, &VPieceCarrouselLayer::on_PieceRemoved);
connect(m_layer, &VPuzzleLayer::PieceAdded, this, &VPCarrouselPieceList::on_PieceAdded);
connect(m_layer, &VPuzzleLayer::PieceRemoved, this, &VPCarrouselPieceList::on_PieceRemoved);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::Refresh()
void VPCarrouselPieceList::Refresh()
{
Clear();
@ -94,7 +94,7 @@ void VPieceCarrouselLayer::Refresh()
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::Clear()
void VPCarrouselPieceList::Clear()
{
// Removes and deletes the carrousel pieces from the layer
while (!m_carrouselPieces.isEmpty())
@ -111,25 +111,25 @@ void VPieceCarrouselLayer::Clear()
}
//---------------------------------------------------------------------------------------------------------------------
QList<VPieceCarrouselPiece*> VPieceCarrouselLayer::GetCarrouselPieces()
QList<VPieceCarrouselPiece*> VPCarrouselPieceList::GetCarrouselPieces()
{
return m_carrouselPieces;
}
//---------------------------------------------------------------------------------------------------------------------
VPCarrousel* VPieceCarrouselLayer::GetCarrousel()
VPCarrousel* VPCarrouselPieceList::GetCarrousel()
{
return m_carrousel;
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer* VPieceCarrouselLayer::GetLayer()
VPuzzleLayer* VPCarrouselPieceList::GetLayer()
{
return m_layer;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::on_PieceAdded(VPuzzlePiece* piece)
void VPCarrouselPieceList::on_PieceAdded(VPuzzlePiece* piece)
{
Q_UNUSED(piece)
@ -139,7 +139,7 @@ void VPieceCarrouselLayer::on_PieceAdded(VPuzzlePiece* piece)
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::on_PieceRemoved(VPuzzlePiece* piece)
void VPCarrouselPieceList::on_PieceRemoved(VPuzzlePiece* piece)
{
for (auto carrouselPiece : m_carrouselPieces)
{

View File

@ -1,6 +1,6 @@
/************************************************************************
**
** @file vpiececarrousellayer.h
** @file vpcarrouselpiecelist.h
** @author Ronan Le Tiec
** @date 25 4, 2020
**
@ -26,8 +26,8 @@
**
*************************************************************************/
#ifndef VPIECECARROUSELLAYER_H
#define VPIECECARROUSELLAYER_H
#ifndef VPCARROUSELPIECELIST_H
#define VPCARROUSELPIECELIST_H
#include <QWidget>
#include "vpuzzlelayer.h"
@ -35,12 +35,12 @@
class VPCarrousel;
class VPieceCarrouselLayer : public QWidget
class VPCarrouselPieceList : public QWidget
{
Q_OBJECT
public:
VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *carrousel);
~VPieceCarrouselLayer();
VPCarrouselPieceList(VPuzzleLayer *layer, VPCarrousel *carrousel);
~VPCarrouselPieceList();
void Init();
void Refresh();
@ -61,7 +61,7 @@ public:
VPuzzleLayer* GetLayer();
private:
Q_DISABLE_COPY(VPieceCarrouselLayer)
Q_DISABLE_COPY(VPCarrouselPieceList)
VPuzzleLayer *m_layer;
VPCarrousel *m_carrousel;
@ -81,4 +81,4 @@ private slots:
};
#endif // VPIECECARROUSELLAYER_H
#endif // VPCARROUSELPIECELIST_H

View File

@ -38,7 +38,7 @@
#include <QMenu>
#include "vpuzzlemimedatapiece.h"
#include "vpiececarrousellayer.h"
#include "vpcarrouselpiecelist.h"
#include "vpcarrousel.h"
#include <QLoggingCategory>
@ -47,7 +47,7 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece")
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, VPieceCarrouselLayer *carrouselLayer) :
VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer) :
m_piece(piece),
m_carrouselLayer(carrouselLayer),
m_dragStart(QPoint())

View File

@ -37,13 +37,13 @@
#include "vpiececarrouselpiecepreview.h"
class VPieceCarrouselLayer;
class VPCarrouselPieceList;
class VPieceCarrouselPiece : public QFrame
{
Q_OBJECT
public:
explicit VPieceCarrouselPiece(VPuzzlePiece *piece, VPieceCarrouselLayer *carrouselLayer);
explicit VPieceCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer);
~VPieceCarrouselPiece();
void Init();
@ -82,7 +82,7 @@ private:
VPuzzlePiece *m_piece;
VPieceCarrouselLayer *m_carrouselLayer;
VPCarrouselPieceList *m_carrouselLayer;
QLabel *m_label{nullptr};
VPieceCarrouselPiecePreview *m_piecePreview{nullptr};