Undo/Redo remove sheet.
This commit is contained in:
parent
3f73bd9d75
commit
087d0855dd
|
@ -13,6 +13,7 @@ SOURCES += \
|
||||||
$$PWD/undocommands/vpundooriginmove.cpp \
|
$$PWD/undocommands/vpundooriginmove.cpp \
|
||||||
$$PWD/undocommands/vpundopiecemove.cpp \
|
$$PWD/undocommands/vpundopiecemove.cpp \
|
||||||
$$PWD/undocommands/vpundopiecerotate.cpp \
|
$$PWD/undocommands/vpundopiecerotate.cpp \
|
||||||
|
$$PWD/undocommands/vpundoremovesheet.cpp \
|
||||||
$$PWD/vpapplication.cpp \
|
$$PWD/vpapplication.cpp \
|
||||||
$$PWD/carousel/vpcarrousel.cpp \
|
$$PWD/carousel/vpcarrousel.cpp \
|
||||||
$$PWD/carousel/vpcarrouselpiece.cpp \
|
$$PWD/carousel/vpcarrouselpiece.cpp \
|
||||||
|
@ -53,6 +54,7 @@ HEADERS += \
|
||||||
$$PWD/undocommands/vpundooriginmove.h \
|
$$PWD/undocommands/vpundooriginmove.h \
|
||||||
$$PWD/undocommands/vpundopiecemove.h \
|
$$PWD/undocommands/vpundopiecemove.h \
|
||||||
$$PWD/undocommands/vpundopiecerotate.h \
|
$$PWD/undocommands/vpundopiecerotate.h \
|
||||||
|
$$PWD/undocommands/vpundoremovesheet.h \
|
||||||
$$PWD/vpapplication.h \
|
$$PWD/vpapplication.h \
|
||||||
$$PWD/carousel/vpcarrousel.h \
|
$$PWD/carousel/vpcarrousel.h \
|
||||||
$$PWD/carousel/vpcarrouselpiece.h \
|
$$PWD/carousel/vpcarrouselpiece.h \
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "../undocommands/vpundopiecerotate.h"
|
#include "../undocommands/vpundopiecerotate.h"
|
||||||
#include "../undocommands/vpundooriginmove.h"
|
#include "../undocommands/vpundooriginmove.h"
|
||||||
#include "../undocommands/vpundomovepieceonsheet.h"
|
#include "../undocommands/vpundomovepieceonsheet.h"
|
||||||
|
#include "../undocommands/vpundoremovesheet.h"
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
@ -401,22 +402,7 @@ void VPMainGraphicsView::contextMenuEvent(QContextMenuEvent *event)
|
||||||
QAction *selectedAction = menu.exec(event->globalPos());
|
QAction *selectedAction = menu.exec(event->globalPos());
|
||||||
if (selectedAction == removeSheetAction)
|
if (selectedAction == removeSheetAction)
|
||||||
{
|
{
|
||||||
if (sheet != nullptr)
|
layout->UndoStack()->push(new VPUndoRemoveSheet(sheet));
|
||||||
{
|
|
||||||
sheet->SetVisible(false);
|
|
||||||
|
|
||||||
QList<VPPiecePtr> pieces = sheet->GetPieces();
|
|
||||||
for (const auto &piece : pieces)
|
|
||||||
{
|
|
||||||
if (not piece.isNull())
|
|
||||||
{
|
|
||||||
piece->SetSheet(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
layout->SetFocusedSheet(VPSheetPtr());
|
|
||||||
emit on_SheetRemoved();
|
|
||||||
}
|
}
|
||||||
else if (selectedAction == restoreOriginAction)
|
else if (selectedAction == restoreOriginAction)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,9 +70,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void CleanAfterExport();
|
void CleanAfterExport();
|
||||||
|
|
||||||
signals:
|
|
||||||
void on_SheetRemoved();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief on_PieceSheetChanged The slot is called when the given piece was moved from the given piece list to
|
* @brief on_PieceSheetChanged The slot is called when the given piece was moved from the given piece list to
|
||||||
|
|
120
src/app/puzzle/undocommands/vpundoremovesheet.cpp
Normal file
120
src/app/puzzle/undocommands/vpundoremovesheet.cpp
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vpundoremovesheet.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 19 8, 2021
|
||||||
|
**
|
||||||
|
** @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) 2021 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 "vpundoremovesheet.h"
|
||||||
|
#include "../vmisc/def.h"
|
||||||
|
#include "../layout/vpsheet.h"
|
||||||
|
#include "../layout/vppiece.h"
|
||||||
|
#include "../layout/vplayout.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPUndoRemoveSheet::VPUndoRemoveSheet(const VPSheetPtr &sheet, QUndoCommand *parent)
|
||||||
|
: VPUndoCommand(false, parent),
|
||||||
|
m_sheet(sheet)
|
||||||
|
{
|
||||||
|
SCASSERT(not sheet.isNull())
|
||||||
|
|
||||||
|
QList<VPPiecePtr> pieces = sheet->GetPieces();
|
||||||
|
for (auto piece : pieces)
|
||||||
|
{
|
||||||
|
m_pieces.append(piece);
|
||||||
|
}
|
||||||
|
|
||||||
|
setText(tr("add sheet"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPUndoRemoveSheet::undo()
|
||||||
|
{
|
||||||
|
VPSheetPtr sheet = m_sheet.toStrongRef();
|
||||||
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (not sheet.isNull())
|
||||||
|
{
|
||||||
|
sheet->SetVisible(true);
|
||||||
|
|
||||||
|
for (const auto &piece : m_pieces)
|
||||||
|
{
|
||||||
|
VPPiecePtr p = piece.toStrongRef();
|
||||||
|
if (not p.isNull())
|
||||||
|
{
|
||||||
|
p->SetSheet(sheet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VPLayoutPtr layout = sheet->GetLayout();
|
||||||
|
if (layout.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit layout->SheetListChanged();
|
||||||
|
layout->SetFocusedSheet(sheet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPUndoRemoveSheet::redo()
|
||||||
|
{
|
||||||
|
VPSheetPtr sheet = m_sheet.toStrongRef();
|
||||||
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (not sheet.isNull())
|
||||||
|
{
|
||||||
|
sheet->SetVisible(false);
|
||||||
|
|
||||||
|
for (const auto &piece : m_pieces)
|
||||||
|
{
|
||||||
|
VPPiecePtr p = piece.toStrongRef();
|
||||||
|
if (not p.isNull())
|
||||||
|
{
|
||||||
|
p->SetSheet(VPSheetPtr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VPLayoutPtr layout = sheet->GetLayout();
|
||||||
|
if (layout.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit layout->SheetListChanged();
|
||||||
|
layout->SetFocusedSheet(VPSheetPtr());
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int VPUndoRemoveSheet::id() const
|
||||||
|
{
|
||||||
|
return static_cast<int>(ML::UndoCommand::RemoveSheet);
|
||||||
|
}
|
52
src/app/puzzle/undocommands/vpundoremovesheet.h
Normal file
52
src/app/puzzle/undocommands/vpundoremovesheet.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vpundoremovesheet.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 19 8, 2021
|
||||||
|
**
|
||||||
|
** @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) 2021 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 VPUNDOREMOVESHEET_H
|
||||||
|
#define VPUNDOREMOVESHEET_H
|
||||||
|
|
||||||
|
#include "vpundocommand.h"
|
||||||
|
|
||||||
|
#include "../layout/layoutdef.h"
|
||||||
|
|
||||||
|
class VPUndoRemoveSheet : public VPUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit VPUndoRemoveSheet(const VPSheetPtr &sheet, QUndoCommand *parent = nullptr);
|
||||||
|
virtual ~VPUndoRemoveSheet()=default;
|
||||||
|
|
||||||
|
virtual void undo() override;
|
||||||
|
virtual void redo() override;
|
||||||
|
virtual auto id() const -> int override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VPUndoRemoveSheet)
|
||||||
|
|
||||||
|
QList<VPPieceWeakPtr> m_pieces{};
|
||||||
|
VPSheetWeakPtr m_sheet;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VPUNDOREMOVESHEET_H
|
|
@ -784,7 +784,6 @@ void VPMainWindow::InitMainGraphics()
|
||||||
|
|
||||||
connect(m_graphicsView, &VPMainGraphicsView::ScaleChanged, this, &VPMainWindow::on_ScaleChanged);
|
connect(m_graphicsView, &VPMainGraphicsView::ScaleChanged, this, &VPMainWindow::on_ScaleChanged);
|
||||||
connect(m_graphicsView->GetScene(), &VMainGraphicsScene::mouseMove, this, &VPMainWindow::on_MouseMoved);
|
connect(m_graphicsView->GetScene(), &VMainGraphicsScene::mouseMove, this, &VPMainWindow::on_MouseMoved);
|
||||||
connect(m_graphicsView, &VPMainGraphicsView::on_SheetRemoved, m_carrousel, &VPCarrousel::Refresh);
|
|
||||||
connect(m_layout.get(), &VPLayout::PieceSheetChanged, m_carrousel, &VPCarrousel::Refresh);
|
connect(m_layout.get(), &VPLayout::PieceSheetChanged, m_carrousel, &VPCarrousel::Refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user