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/vpgraphicssheet.cpp \
$$PWD/vplayout.cpp \
$$PWD/vpmaingraphicsview.cpp \
$$PWD/vpmainwindow.cpp \
$$PWD/vppiecelist.cpp \
$$PWD/vpuzzlemaingraphicsview.cpp \
$$PWD/vpuzzlemimedatapiece.cpp \
$$PWD/vpuzzlepiece.cpp \
$$PWD/vpuzzlesettings.cpp \
@ -38,10 +38,10 @@ HEADERS += \
$$PWD/vpgraphicspiece.h \
$$PWD/vpgraphicssheet.h \
$$PWD/vplayout.h \
$$PWD/vpmaingraphicsview.h \
$$PWD/vpmainwindow.h \
$$PWD/vppiecelist.h \
$$PWD/vpstable.h \
$$PWD/vpuzzlemaingraphicsview.h \
$$PWD/vpuzzlemimedatapiece.h \
$$PWD/vpuzzlepiece.h \
$$PWD/vpuzzlesettings.h \

View file

@ -1,6 +1,6 @@
/************************************************************************
**
** @file vpuzzlemaingraphicsview.cpp
** @file vpmaingraphicsview.cpp
** @author Ronan Le Tiec
** @date 3 5, 2020
**
@ -26,7 +26,7 @@
**
*************************************************************************/
#include "vpuzzlemaingraphicsview.h"
#include "vpmaingraphicsview.h"
#include <QDragEnterEvent>
#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),
m_layout(layout)
{
@ -56,13 +56,13 @@ VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPLayout *layout, QWidget *pare
setAcceptDrops(true);
// 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,
&VPuzzleMainGraphicsView::on_SceneSelectionChanged);
&VPMainGraphicsView::on_SceneSelectionChanged);
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::RefreshLayout()
void VPMainGraphicsView::RefreshLayout()
{
// 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();
@ -84,7 +84,7 @@ void VPuzzleMainGraphicsView::dragEnterEvent(QDragEnterEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dragMoveEvent(QDragMoveEvent *event)
void VPMainGraphicsView::dragMoveEvent(QDragMoveEvent *event)
{
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();
}
@ -103,7 +103,7 @@ void VPuzzleMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dropEvent(QDropEvent *event)
void VPMainGraphicsView::dropEvent(QDropEvent *event)
{
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)
{
@ -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)
@ -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
// 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
** @date 3 5, 2020
**
@ -26,8 +26,8 @@
**
*************************************************************************/
#ifndef VPUZZLEMAINGRAPHICSVIEW_H
#define VPUZZLEMAINGRAPHICSVIEW_H
#ifndef VPMAINGRAPHICSVIEW_H
#define VPMAINGRAPHICSVIEW_H
#include "vpgraphicssheet.h"
#include "vpgraphicspiece.h"
@ -36,12 +36,12 @@
class VMainGraphicsScene;
class VPuzzleMainGraphicsView : public VMainGraphicsView
class VPMainGraphicsView : public VMainGraphicsView
{
Q_OBJECT
public:
VPuzzleMainGraphicsView(VPLayout *layout, QWidget *parent);
~VPuzzleMainGraphicsView() = default;
VPMainGraphicsView(VPLayout *layout, QWidget *parent);
~VPMainGraphicsView() = default;
/**
* @brief RefreshLayout Refreshes the rectangles for the layout border and the margin
@ -72,7 +72,7 @@ private slots:
void on_SceneSelectionChanged();
private:
Q_DISABLE_COPY(VPuzzleMainGraphicsView)
Q_DISABLE_COPY(VPMainGraphicsView)
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()
{
m_graphicsView = new VPuzzleMainGraphicsView(m_layout, this);
m_graphicsView = new VPMainGraphicsView(m_layout, this);
ui->centralWidget->layout()->addWidget(m_graphicsView);
m_graphicsView->RefreshLayout();

View file

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