Fix issue with VMainGraphicsView.

This commit is contained in:
Roman Telezhynskyi 2020-05-11 17:39:54 +03:00
parent 19fd03b66e
commit a89259d47d
5 changed files with 16 additions and 105 deletions

View File

@ -14,7 +14,6 @@ SOURCES += \
$$PWD/vpuzzlegraphicspiece.cpp \
$$PWD/vpuzzlelayout.cpp \
$$PWD/vpuzzlelayer.cpp \
$$PWD/vpuzzlemaingraphicsscene.cpp \
$$PWD/vpuzzlemaingraphicsview.cpp \
$$PWD/vpuzzlemimedatapiece.cpp \
$$PWD/vpuzzlepiece.cpp \
@ -40,7 +39,6 @@ HEADERS += \
$$PWD/vpuzzlegraphicspiece.h \
$$PWD/vpuzzlelayout.h \
$$PWD/vpuzzlelayer.h \
$$PWD/vpuzzlemaingraphicsscene.h \
$$PWD/vpuzzlemaingraphicsview.h \
$$PWD/vpuzzlemimedatapiece.h \
$$PWD/vpuzzlepiece.h \

View File

@ -1,35 +0,0 @@
/************************************************************************
**
** @file vpuzzlemaingraphicsscene.cpp
** @author Ronan Le Tiec
** @date 3 5, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpuzzlemaingraphicsscene.h"
//---------------------------------------------------------------------------------------------------------------------
VPuzzleMainGraphicsScene::VPuzzleMainGraphicsScene(QObject *parent): QGraphicsScene(parent)
{
}

View File

@ -1,44 +0,0 @@
/************************************************************************
**
** @file vpuzzlemaingraphicsscene.cpp
** @author Ronan Le Tiec
** @date 3 5, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPUZZLEMAINGRAPHICSSCENE_H
#define VPUZZLEMAINGRAPHICSSCENE_H
#include <QGraphicsScene>
// TODO: When ready, extend from QGraphicsScene instead
class VPuzzleMainGraphicsScene : public QGraphicsScene
{
Q_OBJECT
public:
VPuzzleMainGraphicsScene(QObject *parent = nullptr);
};
#endif // VPUZZLEMAINGRAPHICSSCENE_H

View File

@ -34,6 +34,7 @@
#include "vpuzzlemimedatapiece.h"
#include "vpuzzlelayer.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include <QLoggingCategory>
@ -42,30 +43,22 @@ Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView")
//---------------------------------------------------------------------------------------------------------------------
VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent) :
QGraphicsView(parent),
m_layout(layout),
m_graphicsPieces(QList<VPuzzleGraphicsPiece*>())
VMainGraphicsView(parent),
m_layout(layout)
{
m_scene = new VPuzzleMainGraphicsScene(this);
m_scene = new VMainGraphicsScene(this);
setScene(m_scene);
m_graphicsLayout = new VPuzzleGraphicsLayout(layout);
m_graphicsLayout->setPos(0,0);
m_graphicsLayout->setPos(0, 0);
m_scene->addItem(m_graphicsLayout);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
setAcceptDrops(true);
// add the connections
connect(m_layout, &VPuzzleLayout::PieceMovedToLayer, this, &VPuzzleMainGraphicsView::on_PieceMovedToLayer);
connect(m_scene, &VPuzzleMainGraphicsScene::selectionChanged, this, &VPuzzleMainGraphicsView::on_SceneSelectionChanged);
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleMainGraphicsView::~VPuzzleMainGraphicsView()
{
connect(m_scene, &VMainGraphicsScene::selectionChanged, this,
&VPuzzleMainGraphicsView::on_SceneSelectionChanged);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -29,21 +29,19 @@
#ifndef VPUZZLEMAINGRAPHICSVIEW_H
#define VPUZZLEMAINGRAPHICSVIEW_H
#include <QGraphicsView>
#include "vpuzzlegraphicslayout.h"
#include "vpuzzlemaingraphicsscene.h"
#include "vpuzzlegraphicspiece.h"
#include "../vwidgets/vmaingraphicsview.h"
class VMainGraphicsScene;
// TODO: when ready, extend the VMainGrapchisView instead
class VPuzzleMainGraphicsView : public QGraphicsView
class VPuzzleMainGraphicsView : public VMainGraphicsView
{
Q_OBJECT
public:
VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent);
~VPuzzleMainGraphicsView();
~VPuzzleMainGraphicsView() = default;
/**
* @brief RefreshLayout Refreshes the rectangles for the layout border and the margin
@ -60,7 +58,8 @@ protected:
private slots:
/**
* @brief on_PieceMovedToLayer The slot is called when the given piece was moved from the given layer to the other given layer
* @brief on_PieceMovedToLayer The slot is called when the given piece was moved from the given layer to the other
* given layer
* @param piece the piece that was moved
* @param layerBefore the layer before the move
* @param layerAfter the layer after the move
@ -75,12 +74,12 @@ private slots:
private:
Q_DISABLE_COPY(VPuzzleMainGraphicsView)
VPuzzleMainGraphicsScene *m_scene{nullptr};
VMainGraphicsScene *m_scene{nullptr};
VPuzzleGraphicsLayout *m_graphicsLayout{nullptr};
VPuzzleLayout *m_layout{nullptr};
QList<VPuzzleGraphicsPiece*> m_graphicsPieces;
QList<VPuzzleGraphicsPiece*> m_graphicsPieces{};
};