Refactoring VPieceCarrouselPiecePreview

This commit is contained in:
Ronan Le Tiec 2020-05-23 14:39:31 +02:00
parent 510d1bd931
commit fb78189d29
5 changed files with 22 additions and 22 deletions

View File

@ -8,8 +8,8 @@ SOURCES += \
$$PWD/vpcarrousel.cpp \ $$PWD/vpcarrousel.cpp \
$$PWD/vpcarrouselpiece.cpp \ $$PWD/vpcarrouselpiece.cpp \
$$PWD/vpcarrouselpiecelist.cpp \ $$PWD/vpcarrouselpiecelist.cpp \
$$PWD/vpcarrouselpiecepreview.cpp \
$$PWD/vpcommands.cpp \ $$PWD/vpcommands.cpp \
$$PWD/vpiececarrouselpiecepreview.cpp \
$$PWD/vpmainwindow.cpp \ $$PWD/vpmainwindow.cpp \
$$PWD/vpuzzlecommandline.cpp \ $$PWD/vpuzzlecommandline.cpp \
$$PWD/vpuzzlegraphicslayout.cpp \ $$PWD/vpuzzlegraphicslayout.cpp \
@ -32,8 +32,8 @@ HEADERS += \
$$PWD/vpcarrousel.h \ $$PWD/vpcarrousel.h \
$$PWD/vpcarrouselpiece.h \ $$PWD/vpcarrouselpiece.h \
$$PWD/vpcarrouselpiecelist.h \ $$PWD/vpcarrouselpiecelist.h \
$$PWD/vpcarrouselpiecepreview.h \
$$PWD/vpcommands.h \ $$PWD/vpcommands.h \
$$PWD/vpiececarrouselpiecepreview.h \
$$PWD/vpmainwindow.h \ $$PWD/vpmainwindow.h \
$$PWD/vpstable.h \ $$PWD/vpstable.h \
$$PWD/vpuzzlecommandline.h \ $$PWD/vpuzzlecommandline.h \

View File

@ -49,7 +49,7 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPCarrouselPiece::VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer) : VPCarrouselPiece::VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer) :
m_piece(piece), m_piece(piece),
m_carrouselLayer(carrouselLayer), m_carrouselPieceList(carrouselLayer),
m_dragStart(QPoint()) m_dragStart(QPoint())
{ {
Init(); Init();
@ -75,7 +75,7 @@ void VPCarrouselPiece::Init()
setStyleSheet("background-color:white; border: 2px solid transparent;"); setStyleSheet("background-color:white; border: 2px solid transparent;");
// define the preview of the piece // define the preview of the piece
m_piecePreview = new VPieceCarrouselPiecePreview(this); m_piecePreview = new VPCarrouselPiecePreview(this);
// m_graphicsView = new VMainGraphicsView(this); // m_graphicsView = new VMainGraphicsView(this);
// --> undefined reference to 'VMainGraphicsView::VMainGraphicView(QWidget*)' // --> undefined reference to 'VMainGraphicsView::VMainGraphicView(QWidget*)'
@ -175,7 +175,7 @@ void VPCarrouselPiece::mousePressEvent(QMouseEvent *event)
{ {
if(!(event->modifiers() & Qt::ControlModifier)) if(!(event->modifiers() & Qt::ControlModifier))
{ {
m_carrouselLayer->GetCarrousel()->ClearSelection(); m_carrouselPieceList->GetCarrousel()->ClearSelection();
m_piece->SetIsSelected(true); m_piece->SetIsSelected(true);
} }
else else
@ -207,7 +207,7 @@ void VPCarrouselPiece::mouseMoveEvent(QMouseEvent *event)
} }
// make sure the multiple selection is removed // make sure the multiple selection is removed
m_carrouselLayer->GetCarrousel()->ClearSelection(); m_carrouselPieceList->GetCarrousel()->ClearSelection();
m_piece->SetIsSelected(true); m_piece->SetIsSelected(true);
// starts the dragging // starts the dragging

View File

@ -34,7 +34,7 @@
#include <QMouseEvent> #include <QMouseEvent>
#include "vpuzzlepiece.h" #include "vpuzzlepiece.h"
#include "vpiececarrouselpiecepreview.h" #include "vpcarrouselpiecepreview.h"
class VPCarrouselPieceList; class VPCarrouselPieceList;
@ -82,10 +82,10 @@ private:
VPuzzlePiece *m_piece; VPuzzlePiece *m_piece;
VPCarrouselPieceList *m_carrouselLayer; VPCarrouselPieceList *m_carrouselPieceList;
QLabel *m_label{nullptr}; QLabel *m_label{nullptr};
VPieceCarrouselPiecePreview *m_piecePreview{nullptr}; VPCarrouselPiecePreview *m_piecePreview{nullptr};
QPoint m_dragStart; QPoint m_dragStart;

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpiececarrouselpiecepreview.cpp ** @file vpcarrouselpiecepreview.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 3 5, 2020 ** @date 3 5, 2020
** **
@ -26,29 +26,29 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpiececarrouselpiecepreview.h" #include "vpcarrouselpiecepreview.h"
#include <QMouseEvent> #include <QMouseEvent>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselPiecePreview::VPieceCarrouselPiecePreview(QWidget *parent): VPCarrouselPiecePreview::VPCarrouselPiecePreview(QWidget *parent):
QGraphicsView(parent) QGraphicsView(parent)
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselPiecePreview::~VPieceCarrouselPiecePreview() VPCarrouselPiecePreview::~VPCarrouselPiecePreview()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiecePreview::mousePressEvent(QMouseEvent *event) void VPCarrouselPiecePreview::mousePressEvent(QMouseEvent *event)
{ {
event->ignore(); event->ignore();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiecePreview::mouseMoveEvent(QMouseEvent *event) void VPCarrouselPiecePreview::mouseMoveEvent(QMouseEvent *event)
{ {
event->ignore(); event->ignore();
} }

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpiececarrouselpiecepreview.h ** @file vpcarrouselpiecepreview.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 3 5, 2020 ** @date 3 5, 2020
** **
@ -26,20 +26,20 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLEPIECECARROUSELPIECEPREVIEW_H #ifndef VPCARROUSELPIECEPREVIEW_H
#define VPUZZLEPIECECARROUSELPIECEPREVIEW_H #define VPCARROUSELPIECEPREVIEW_H
#include <QGraphicsView> #include <QGraphicsView>
class VPieceCarrouselPiecePreview: public QGraphicsView class VPCarrouselPiecePreview: public QGraphicsView
{ {
public: public:
VPieceCarrouselPiecePreview(QWidget *parent = nullptr); VPCarrouselPiecePreview(QWidget *parent = nullptr);
~VPieceCarrouselPiecePreview(); ~VPCarrouselPiecePreview();
protected: protected:
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;
}; };
#endif // VPUZZLEPIECECARROUSELPIECEPREVIEW_H #endif // VPCARROUSELPIECEPREVIEW_H