Refactoring VPuzzleMainGraphicsView

This commit is contained in:
Ronan Le Tiec 2020-05-23 15:36:46 +02:00
parent 5e785bfa79
commit 2accd83d6b
5 changed files with 26 additions and 26 deletions

View File

@ -14,9 +14,9 @@ SOURCES += \
$$PWD/vpgraphicspiece.cpp \ $$PWD/vpgraphicspiece.cpp \
$$PWD/vpgraphicssheet.cpp \ $$PWD/vpgraphicssheet.cpp \
$$PWD/vplayout.cpp \ $$PWD/vplayout.cpp \
$$PWD/vpmaingraphicsview.cpp \
$$PWD/vpmainwindow.cpp \ $$PWD/vpmainwindow.cpp \
$$PWD/vppiecelist.cpp \ $$PWD/vppiecelist.cpp \
$$PWD/vpuzzlemaingraphicsview.cpp \
$$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlemimedatapiece.cpp \
$$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlepiece.cpp \
$$PWD/vpuzzlesettings.cpp \ $$PWD/vpuzzlesettings.cpp \
@ -38,10 +38,10 @@ HEADERS += \
$$PWD/vpgraphicspiece.h \ $$PWD/vpgraphicspiece.h \
$$PWD/vpgraphicssheet.h \ $$PWD/vpgraphicssheet.h \
$$PWD/vplayout.h \ $$PWD/vplayout.h \
$$PWD/vpmaingraphicsview.h \
$$PWD/vpmainwindow.h \ $$PWD/vpmainwindow.h \
$$PWD/vppiecelist.h \ $$PWD/vppiecelist.h \
$$PWD/vpstable.h \ $$PWD/vpstable.h \
$$PWD/vpuzzlemaingraphicsview.h \
$$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlemimedatapiece.h \
$$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlepiece.h \
$$PWD/vpuzzlesettings.h \ $$PWD/vpuzzlesettings.h \

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlemaingraphicsview.cpp ** @file vpmaingraphicsview.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 3 5, 2020 ** @date 3 5, 2020
** **
@ -26,7 +26,7 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlemaingraphicsview.h" #include "vpmaingraphicsview.h"
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QMimeData> #include <QMimeData>
@ -42,7 +42,7 @@ Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPLayout *layout, QWidget *parent) : VPMainGraphicsView::VPMainGraphicsView(VPLayout *layout, QWidget *parent) :
VMainGraphicsView(parent), VMainGraphicsView(parent),
m_layout(layout) m_layout(layout)
{ {
@ -56,13 +56,13 @@ VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPLayout *layout, QWidget *pare
setAcceptDrops(true); setAcceptDrops(true);
// add the connections // add the connections
connect(m_layout, &VPLayout::PieceMovedToPieceList, this, &VPuzzleMainGraphicsView::on_PieceMovedToPieceList); connect(m_layout, &VPLayout::PieceMovedToPieceList, this, &VPMainGraphicsView::on_PieceMovedToPieceList);
connect(m_scene, &VMainGraphicsScene::selectionChanged, this, connect(m_scene, &VMainGraphicsScene::selectionChanged, this,
&VPuzzleMainGraphicsView::on_SceneSelectionChanged); &VPMainGraphicsView::on_SceneSelectionChanged);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::RefreshLayout() void VPMainGraphicsView::RefreshLayout()
{ {
// FIXME: Is that the way to go? // FIXME: Is that the way to go?
@ -72,7 +72,7 @@ void VPuzzleMainGraphicsView::RefreshLayout()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dragEnterEvent(QDragEnterEvent *event) void VPMainGraphicsView::dragEnterEvent(QDragEnterEvent *event)
{ {
const QMimeData *mime = event->mimeData(); const QMimeData *mime = event->mimeData();
@ -84,7 +84,7 @@ void VPuzzleMainGraphicsView::dragEnterEvent(QDragEnterEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dragMoveEvent(QDragMoveEvent *event) void VPMainGraphicsView::dragMoveEvent(QDragMoveEvent *event)
{ {
const QMimeData *mime = event->mimeData(); const QMimeData *mime = event->mimeData();
@ -95,7 +95,7 @@ void VPuzzleMainGraphicsView::dragMoveEvent(QDragMoveEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) void VPMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event)
{ {
event->accept(); event->accept();
} }
@ -103,7 +103,7 @@ void VPuzzleMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dropEvent(QDropEvent *event) void VPMainGraphicsView::dropEvent(QDropEvent *event)
{ {
const QMimeData *mime = event->mimeData(); const QMimeData *mime = event->mimeData();
@ -133,7 +133,7 @@ void VPuzzleMainGraphicsView::dropEvent(QDropEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::keyPressEvent(QKeyEvent *event) void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
{ {
if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete)
{ {
@ -153,7 +153,7 @@ void VPuzzleMainGraphicsView::keyPressEvent(QKeyEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter) void VPMainGraphicsView::on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter)
{ {
Q_UNUSED(pieceListBefore) Q_UNUSED(pieceListBefore)
@ -188,7 +188,7 @@ void VPuzzleMainGraphicsView::on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPi
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::on_SceneSelectionChanged() void VPMainGraphicsView::on_SceneSelectionChanged()
{ {
// most of the selection behaviour taks place automatically // most of the selection behaviour taks place automatically
// but we need to make sure that the unplaced pieces are unselected when the scene selection has changed // but we need to make sure that the unplaced pieces are unselected when the scene selection has changed

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlemaingraphicsview.h ** @file vpmaingraphicsview.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 3 5, 2020 ** @date 3 5, 2020
** **
@ -26,8 +26,8 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLEMAINGRAPHICSVIEW_H #ifndef VPMAINGRAPHICSVIEW_H
#define VPUZZLEMAINGRAPHICSVIEW_H #define VPMAINGRAPHICSVIEW_H
#include "vpgraphicssheet.h" #include "vpgraphicssheet.h"
#include "vpgraphicspiece.h" #include "vpgraphicspiece.h"
@ -36,12 +36,12 @@
class VMainGraphicsScene; class VMainGraphicsScene;
class VPuzzleMainGraphicsView : public VMainGraphicsView class VPMainGraphicsView : public VMainGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzleMainGraphicsView(VPLayout *layout, QWidget *parent); VPMainGraphicsView(VPLayout *layout, QWidget *parent);
~VPuzzleMainGraphicsView() = default; ~VPMainGraphicsView() = default;
/** /**
* @brief RefreshLayout Refreshes the rectangles for the layout border and the margin * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin
@ -72,7 +72,7 @@ private slots:
void on_SceneSelectionChanged(); void on_SceneSelectionChanged();
private: private:
Q_DISABLE_COPY(VPuzzleMainGraphicsView) Q_DISABLE_COPY(VPMainGraphicsView)
VMainGraphicsScene *m_scene{nullptr}; VMainGraphicsScene *m_scene{nullptr};
@ -83,4 +83,4 @@ private:
}; };
#endif // VPUZZLEMAINGRAPHICVIEW_H #endif // VPMAINGRAPHICSVIEW_H

View File

@ -436,7 +436,7 @@ void VPMainWindow::SetPropertyTabTilesData()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitMainGraphics() void VPMainWindow::InitMainGraphics()
{ {
m_graphicsView = new VPuzzleMainGraphicsView(m_layout, this); m_graphicsView = new VPMainGraphicsView(m_layout, this);
ui->centralWidget->layout()->addWidget(m_graphicsView); ui->centralWidget->layout()->addWidget(m_graphicsView);
m_graphicsView->RefreshLayout(); m_graphicsView->RefreshLayout();

View File

@ -34,7 +34,7 @@
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "vpcarrousel.h" #include "vpcarrousel.h"
#include "vpuzzlemaingraphicsview.h" #include "vpmaingraphicsview.h"
#include "vplayout.h" #include "vplayout.h"
#include "vpuzzlepiece.h" #include "vpuzzlepiece.h"
#include "../vlayout/vlayoutpiece.h" #include "../vlayout/vlayoutpiece.h"
@ -91,7 +91,7 @@ private:
Ui::VPMainWindow *ui; Ui::VPMainWindow *ui;
VPCarrousel *m_carrousel{nullptr}; VPCarrousel *m_carrousel{nullptr};
VPuzzleMainGraphicsView *m_graphicsView{nullptr}; VPMainGraphicsView *m_graphicsView{nullptr};
VPCommandLinePtr m_cmd; VPCommandLinePtr m_cmd;