Show Forbid flipping and Force flipping options in piece context menu.
--HG-- branch : develop
This commit is contained in:
parent
63fd000443
commit
8b7494fb08
|
@ -31,7 +31,7 @@
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vtools/undocommands/togglepieceinlayout.h"
|
#include "../vtools/undocommands/togglepiecestate.h"
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
|
|
@ -876,9 +876,9 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse
|
||||||
initData.detail.SetSeamAllowanceBuiltIn(GetParametrBool(domElement,
|
initData.detail.SetSeamAllowanceBuiltIn(GetParametrBool(domElement,
|
||||||
VToolSeamAllowance::AttrSeamAllowanceBuiltIn,
|
VToolSeamAllowance::AttrSeamAllowanceBuiltIn,
|
||||||
falseStr));
|
falseStr));
|
||||||
initData.detail.SetForbidFlipping(GetParametrBool(domElement, VToolSeamAllowance::AttrForbidFlipping,
|
initData.detail.SetForbidFlipping(GetParametrBool(domElement, AttrForbidFlipping,
|
||||||
QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
|
QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
|
||||||
initData.detail.SetForceFlipping(GetParametrBool(domElement, VToolSeamAllowance::AttrForceFlipping,
|
initData.detail.SetForceFlipping(GetParametrBool(domElement, AttrForceFlipping,
|
||||||
QString().setNum(qApp->ValentinaSettings()->GetForceWorkpieceFlipping())));
|
QString().setNum(qApp->ValentinaSettings()->GetForceWorkpieceFlipping())));
|
||||||
initData.detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));
|
initData.detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));
|
||||||
initData.detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr));
|
initData.detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr));
|
||||||
|
|
|
@ -119,6 +119,8 @@ const QString AttrArc = QStringLiteral("arc");
|
||||||
const QString AttrSuffix = QStringLiteral("suffix");
|
const QString AttrSuffix = QStringLiteral("suffix");
|
||||||
const QString AttrIdObject = QStringLiteral("idObject");
|
const QString AttrIdObject = QStringLiteral("idObject");
|
||||||
const QString AttrInLayout = QStringLiteral("inLayout");
|
const QString AttrInLayout = QStringLiteral("inLayout");
|
||||||
|
const QString AttrForbidFlipping = QStringLiteral("forbidFlipping");
|
||||||
|
const QString AttrForceFlipping = QStringLiteral("forceFlipping");
|
||||||
const QString AttrRotationAngle = QStringLiteral("rotationAngle");
|
const QString AttrRotationAngle = QStringLiteral("rotationAngle");
|
||||||
const QString AttrClosed = QStringLiteral("closed");
|
const QString AttrClosed = QStringLiteral("closed");
|
||||||
const QString AttrShowLabel = QStringLiteral("showLabel");
|
const QString AttrShowLabel = QStringLiteral("showLabel");
|
||||||
|
|
|
@ -141,6 +141,8 @@ extern const QString AttrArc;
|
||||||
extern const QString AttrSuffix;
|
extern const QString AttrSuffix;
|
||||||
extern const QString AttrIdObject;
|
extern const QString AttrIdObject;
|
||||||
extern const QString AttrInLayout;
|
extern const QString AttrInLayout;
|
||||||
|
extern const QString AttrForbidFlipping;
|
||||||
|
extern const QString AttrForceFlipping;
|
||||||
extern const QString AttrClosed;
|
extern const QString AttrClosed;
|
||||||
extern const QString AttrShowLabel;
|
extern const QString AttrShowLabel;
|
||||||
extern const QString AttrShowLabel1;
|
extern const QString AttrShowLabel1;
|
||||||
|
|
|
@ -288,11 +288,20 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
|
|
||||||
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
||||||
|
|
||||||
|
const VPiece detail = VAbstractTool::data.GetPiece(piece->getId());
|
||||||
|
|
||||||
QAction *inLayoutOption = menu.addAction(tr("In layout"));
|
QAction *inLayoutOption = menu.addAction(tr("In layout"));
|
||||||
inLayoutOption->setCheckable(true);
|
inLayoutOption->setCheckable(true);
|
||||||
const VPiece detail = VAbstractTool::data.GetPiece(piece->getId());
|
|
||||||
inLayoutOption->setChecked(detail.IsInLayout());
|
inLayoutOption->setChecked(detail.IsInLayout());
|
||||||
|
|
||||||
|
QAction *forbidFlippingOption = menu.addAction(tr("Forbid flipping"));
|
||||||
|
forbidFlippingOption->setCheckable(true);
|
||||||
|
forbidFlippingOption->setChecked(detail.IsForbidFlipping());
|
||||||
|
|
||||||
|
QAction *forceFlippingOption = menu.addAction(tr("Force flipping"));
|
||||||
|
forceFlippingOption->setCheckable(true);
|
||||||
|
forceFlippingOption->setChecked(detail.IsForceFlipping());
|
||||||
|
|
||||||
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
||||||
piece->referens() > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true);
|
piece->referens() > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true);
|
||||||
|
|
||||||
|
@ -305,6 +314,14 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
emit ToggleInLayout(selectedAction->isChecked());
|
emit ToggleInLayout(selectedAction->isChecked());
|
||||||
}
|
}
|
||||||
|
else if (selectedAction == forbidFlippingOption)
|
||||||
|
{
|
||||||
|
emit ToggleForbidFlipping(selectedAction->isChecked());
|
||||||
|
}
|
||||||
|
else if (selectedAction == forceFlippingOption)
|
||||||
|
{
|
||||||
|
emit ToggleForceFlipping(selectedAction->isChecked());
|
||||||
|
}
|
||||||
else if (selectedAction == actionRemove)
|
else if (selectedAction == actionRemove)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -62,6 +62,8 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void ShowOptions();
|
void ShowOptions();
|
||||||
void ToggleInLayout(bool checked);
|
void ToggleInLayout(bool checked);
|
||||||
|
void ToggleForbidFlipping(bool checked);
|
||||||
|
void ToggleForceFlipping(bool checked);
|
||||||
void Delete();
|
void Delete();
|
||||||
void ToggleExcludeState(quint32 id);
|
void ToggleExcludeState(quint32 id);
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
#include "../undocommands/deletepiece.h"
|
#include "../undocommands/deletepiece.h"
|
||||||
#include "../undocommands/movepiece.h"
|
#include "../undocommands/movepiece.h"
|
||||||
#include "../undocommands/savepieceoptions.h"
|
#include "../undocommands/savepieceoptions.h"
|
||||||
#include "../undocommands/togglepieceinlayout.h"
|
#include "../undocommands/togglepiecestate.h"
|
||||||
#include "../vwidgets/vmaingraphicsview.h"
|
#include "../vwidgets/vmaingraphicsview.h"
|
||||||
#include "../vwidgets/vnobrushscalepathitem.h"
|
#include "../vwidgets/vnobrushscalepathitem.h"
|
||||||
#include "../qmuparser/qmutokenparser.h"
|
#include "../qmuparser/qmutokenparser.h"
|
||||||
|
@ -70,8 +70,6 @@ const QString VToolSeamAllowance::TagIPaths = QStringLiteral("iPaths");
|
||||||
const QString VToolSeamAllowance::TagPins = QStringLiteral("pins");
|
const QString VToolSeamAllowance::TagPins = QStringLiteral("pins");
|
||||||
const QString VToolSeamAllowance::TagPlaceLabels = QStringLiteral("placeLabels");
|
const QString VToolSeamAllowance::TagPlaceLabels = QStringLiteral("placeLabels");
|
||||||
|
|
||||||
const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping");
|
|
||||||
const QString VToolSeamAllowance::AttrForceFlipping = QStringLiteral("forceFlipping");
|
|
||||||
const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance");
|
const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance");
|
||||||
const QString VToolSeamAllowance::AttrHideMainPath = QStringLiteral("hideMainPath");
|
const QString VToolSeamAllowance::AttrHideMainPath = QStringLiteral("hideMainPath");
|
||||||
const QString VToolSeamAllowance::AttrSeamAllowanceBuiltIn = QStringLiteral("seamAllowanceBuiltIn");
|
const QString VToolSeamAllowance::AttrSeamAllowanceBuiltIn = QStringLiteral("seamAllowanceBuiltIn");
|
||||||
|
@ -1177,11 +1175,20 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
||||||
|
|
||||||
|
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
|
||||||
|
|
||||||
QAction *inLayoutOption = menu.addAction(tr("In layout"));
|
QAction *inLayoutOption = menu.addAction(tr("In layout"));
|
||||||
inLayoutOption->setCheckable(true);
|
inLayoutOption->setCheckable(true);
|
||||||
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
|
|
||||||
inLayoutOption->setChecked(detail.IsInLayout());
|
inLayoutOption->setChecked(detail.IsInLayout());
|
||||||
|
|
||||||
|
QAction *forbidFlippingOption = menu.addAction(tr("Forbid flipping"));
|
||||||
|
forbidFlippingOption->setCheckable(true);
|
||||||
|
forbidFlippingOption->setChecked(detail.IsForbidFlipping());
|
||||||
|
|
||||||
|
QAction *forceFlippingOption = menu.addAction(tr("Force flipping"));
|
||||||
|
forceFlippingOption->setCheckable(true);
|
||||||
|
forceFlippingOption->setChecked(detail.IsForceFlipping());
|
||||||
|
|
||||||
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
||||||
_referens > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true);
|
_referens > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true);
|
||||||
|
|
||||||
|
@ -1194,6 +1201,14 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
ToggleInLayout(selectedAction->isChecked());
|
ToggleInLayout(selectedAction->isChecked());
|
||||||
}
|
}
|
||||||
|
else if (selectedAction == forbidFlippingOption)
|
||||||
|
{
|
||||||
|
ToggleForbidFlipping(selectedAction->isChecked());
|
||||||
|
}
|
||||||
|
else if (selectedAction == forceFlippingOption)
|
||||||
|
{
|
||||||
|
ToggleForceFlipping(selectedAction->isChecked());
|
||||||
|
}
|
||||||
else if (selectedAction == actionRemove)
|
else if (selectedAction == actionRemove)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1462,6 +1477,18 @@ void VToolSeamAllowance::ToggleInLayout(bool checked)
|
||||||
qApp->getUndoStack()->push(togglePrint);
|
qApp->getUndoStack()->push(togglePrint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSeamAllowance::ToggleForbidFlipping(bool checked)
|
||||||
|
{
|
||||||
|
qApp->getUndoStack()->push(new TogglePieceForbidFlipping(m_id, checked, &(VAbstractTool::data), doc));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSeamAllowance::ToggleForceFlipping(bool checked)
|
||||||
|
{
|
||||||
|
qApp->getUndoStack()->push(new TogglePieceForceFlipping(m_id, checked, &(VAbstractTool::data), doc));
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSeamAllowance::DeleteFromMenu()
|
void VToolSeamAllowance::DeleteFromMenu()
|
||||||
{
|
{
|
||||||
|
@ -1706,6 +1733,10 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc
|
||||||
connect(tool, &VNodePoint::ShowOptions, parent, &VToolSeamAllowance::ShowOptions, Qt::UniqueConnection);
|
connect(tool, &VNodePoint::ShowOptions, parent, &VToolSeamAllowance::ShowOptions, Qt::UniqueConnection);
|
||||||
connect(tool, &VNodePoint::ToggleInLayout, parent, &VToolSeamAllowance::ToggleInLayout,
|
connect(tool, &VNodePoint::ToggleInLayout, parent, &VToolSeamAllowance::ToggleInLayout,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
connect(tool, &VNodePoint::ToggleForbidFlipping, parent, &VToolSeamAllowance::ToggleForbidFlipping,
|
||||||
|
Qt::UniqueConnection);
|
||||||
|
connect(tool, &VNodePoint::ToggleForceFlipping, parent, &VToolSeamAllowance::ToggleForceFlipping,
|
||||||
|
Qt::UniqueConnection);
|
||||||
connect(tool, &VNodePoint::Delete, parent, &VToolSeamAllowance::DeleteFromMenu, Qt::UniqueConnection);
|
connect(tool, &VNodePoint::Delete, parent, &VToolSeamAllowance::DeleteFromMenu, Qt::UniqueConnection);
|
||||||
connect(tool, &VNodePoint::ToggleExcludeState, parent, &VToolSeamAllowance::ToggleExcludeState,
|
connect(tool, &VNodePoint::ToggleExcludeState, parent, &VToolSeamAllowance::ToggleExcludeState,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
|
|
@ -76,8 +76,7 @@ public:
|
||||||
static const QString TagPins;
|
static const QString TagPins;
|
||||||
static const QString TagPlaceLabels;
|
static const QString TagPlaceLabels;
|
||||||
|
|
||||||
static const QString AttrForbidFlipping;
|
|
||||||
static const QString AttrForceFlipping;
|
|
||||||
static const QString AttrSeamAllowance;
|
static const QString AttrSeamAllowance;
|
||||||
static const QString AttrHideMainPath;
|
static const QString AttrHideMainPath;
|
||||||
static const QString AttrSeamAllowanceBuiltIn;
|
static const QString AttrSeamAllowanceBuiltIn;
|
||||||
|
@ -163,6 +162,8 @@ protected:
|
||||||
private slots:
|
private slots:
|
||||||
void ShowOptions();
|
void ShowOptions();
|
||||||
void ToggleInLayout(bool checked);
|
void ToggleInLayout(bool checked);
|
||||||
|
void ToggleForbidFlipping(bool checked);
|
||||||
|
void ToggleForceFlipping(bool checked);
|
||||||
void DeleteFromMenu();
|
void DeleteFromMenu();
|
||||||
void ToggleExcludeState(quint32 id);
|
void ToggleExcludeState(quint32 id);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "togglepieceinlayout.h"
|
#include "togglepiecestate.h"
|
||||||
|
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
@ -42,26 +42,19 @@
|
||||||
#include "vundocommand.h"
|
#include "vundocommand.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
TogglePieceInLayout::TogglePieceInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
TogglePieceState::TogglePieceState(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: VUndoCommand(QDomElement(), doc, parent),
|
: VUndoCommand(QDomElement(), doc, parent),
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_data(data),
|
m_data(data),
|
||||||
m_oldState(m_data->DataPieces()->value(m_id).IsInLayout()),
|
m_oldState(not state),
|
||||||
m_newState(state)
|
m_newState(state)
|
||||||
{
|
{}
|
||||||
setText(tr("detail in layout list"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
TogglePieceInLayout::~TogglePieceInLayout()
|
void TogglePieceState::undo()
|
||||||
{
|
{
|
||||||
}
|
qCDebug(vUndo, "TogglePieceState::undo().");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void TogglePieceInLayout::undo()
|
|
||||||
{
|
|
||||||
qCDebug(vUndo, "ToggleDetailInLayout::undo().");
|
|
||||||
|
|
||||||
if (m_newState != m_oldState)
|
if (m_newState != m_oldState)
|
||||||
{
|
{
|
||||||
|
@ -70,9 +63,9 @@ void TogglePieceInLayout::undo()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TogglePieceInLayout::redo()
|
void TogglePieceState::redo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "ToggleDetailInLayout::redo().");
|
qCDebug(vUndo, "TogglePieceState::redo().");
|
||||||
|
|
||||||
if (m_newState != m_oldState)
|
if (m_newState != m_oldState)
|
||||||
{
|
{
|
||||||
|
@ -81,21 +74,12 @@ void TogglePieceInLayout::redo()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int TogglePieceInLayout::id() const
|
TogglePieceInLayout::TogglePieceInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
|
QUndoCommand *parent)
|
||||||
|
: TogglePieceState(id, state, data, doc, parent)
|
||||||
{
|
{
|
||||||
return static_cast<int>(UndoCommand::TogglePieceInLayout);
|
setText(tr("detail in layout list"));
|
||||||
}
|
m_oldState = m_data->DataPieces()->value(m_id).IsInLayout();
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
quint32 TogglePieceInLayout::getDetId() const
|
|
||||||
{
|
|
||||||
return m_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
bool TogglePieceInLayout::getNewState() const
|
|
||||||
{
|
|
||||||
return m_newState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -123,3 +107,57 @@ void TogglePieceInLayout::Do(bool state)
|
||||||
qDebug("Can't get detail by id = %u.", m_id);
|
qDebug("Can't get detail by id = %u.", m_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
TogglePieceForbidFlipping::TogglePieceForbidFlipping(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
|
QUndoCommand *parent)
|
||||||
|
: TogglePieceState(id, state, data, doc, parent)
|
||||||
|
{
|
||||||
|
setText(tr("forbid flipping"));
|
||||||
|
m_oldState = m_data->DataPieces()->value(m_id).IsForbidFlipping();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TogglePieceForbidFlipping::Do(bool state)
|
||||||
|
{
|
||||||
|
QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail);
|
||||||
|
if (detail.isElement())
|
||||||
|
{
|
||||||
|
doc->SetAttribute(detail, AttrForbidFlipping, state);
|
||||||
|
|
||||||
|
VPiece det = m_data->DataPieces()->value(m_id);
|
||||||
|
det.SetForbidFlipping(state);
|
||||||
|
m_data->UpdatePiece(m_id, det);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Can't get detail by id = %u.", m_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
TogglePieceForceFlipping::TogglePieceForceFlipping(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
|
QUndoCommand *parent)
|
||||||
|
: TogglePieceState(id, state, data, doc, parent)
|
||||||
|
{
|
||||||
|
setText(tr("force flipping"));
|
||||||
|
m_oldState = m_data->DataPieces()->value(m_id).IsForceFlipping();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TogglePieceForceFlipping::Do(bool state)
|
||||||
|
{
|
||||||
|
QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail);
|
||||||
|
if (detail.isElement())
|
||||||
|
{
|
||||||
|
doc->SetAttribute(detail, AttrForceFlipping, state);
|
||||||
|
|
||||||
|
VPiece det = m_data->DataPieces()->value(m_id);
|
||||||
|
det.SetForceFlipping(state);
|
||||||
|
m_data->UpdatePiece(m_id, det);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Can't get detail by id = %u.", m_id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,29 +37,87 @@
|
||||||
|
|
||||||
#include "vundocommand.h"
|
#include "vundocommand.h"
|
||||||
|
|
||||||
class TogglePieceInLayout : public VUndoCommand
|
class TogglePieceState : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TogglePieceInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
TogglePieceState(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
virtual ~TogglePieceInLayout();
|
virtual ~TogglePieceState() = default;
|
||||||
virtual void undo() Q_DECL_OVERRIDE;
|
virtual void undo() Q_DECL_OVERRIDE;
|
||||||
virtual void redo() Q_DECL_OVERRIDE;
|
virtual void redo() Q_DECL_OVERRIDE;
|
||||||
virtual int id() const Q_DECL_OVERRIDE;
|
|
||||||
quint32 getDetId() const;
|
quint32 getDetId() const;
|
||||||
bool getNewState() const;
|
bool getNewState() const;
|
||||||
|
|
||||||
signals:
|
protected:
|
||||||
void UpdateList();
|
|
||||||
private:
|
|
||||||
Q_DISABLE_COPY(TogglePieceInLayout)
|
|
||||||
quint32 m_id;
|
quint32 m_id;
|
||||||
VContainer *m_data;
|
VContainer *m_data;
|
||||||
bool m_oldState;
|
bool m_oldState;
|
||||||
bool m_newState;
|
bool m_newState;
|
||||||
|
|
||||||
void Do(bool state);
|
virtual void Do(bool state)=0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(TogglePieceState)
|
||||||
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline quint32 TogglePieceState::getDetId() const
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool TogglePieceState::getNewState() const
|
||||||
|
{
|
||||||
|
return m_newState;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TogglePieceInLayout : public TogglePieceState
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TogglePieceInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
|
QUndoCommand *parent = nullptr);
|
||||||
|
virtual ~TogglePieceInLayout() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void Do(bool state) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void UpdateList();
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(TogglePieceInLayout)
|
||||||
|
};
|
||||||
|
|
||||||
|
class TogglePieceForbidFlipping : public TogglePieceState
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TogglePieceForbidFlipping(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
|
QUndoCommand *parent = nullptr);
|
||||||
|
virtual ~TogglePieceForbidFlipping() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void Do(bool state) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(TogglePieceForbidFlipping)
|
||||||
|
};
|
||||||
|
|
||||||
|
class TogglePieceForceFlipping : public TogglePieceState
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TogglePieceForceFlipping(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
|
QUndoCommand *parent = nullptr);
|
||||||
|
virtual ~TogglePieceForceFlipping() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void Do(bool state) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(TogglePieceForceFlipping)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TOGGLEDETAILINLAYOUT_H
|
#endif // TOGGLEDETAILINLAYOUT_H
|
|
@ -22,12 +22,12 @@ HEADERS += \
|
||||||
$$PWD/deletepiece.h \
|
$$PWD/deletepiece.h \
|
||||||
$$PWD/movepiece.h \
|
$$PWD/movepiece.h \
|
||||||
$$PWD/savepieceoptions.h \
|
$$PWD/savepieceoptions.h \
|
||||||
$$PWD/togglepieceinlayout.h \
|
|
||||||
$$PWD/savepiecepathoptions.h \
|
$$PWD/savepiecepathoptions.h \
|
||||||
$$PWD/label/showlabel.h \
|
$$PWD/label/showlabel.h \
|
||||||
$$PWD/label/showdoublelabel.h \
|
$$PWD/label/showdoublelabel.h \
|
||||||
$$PWD/label/operationshowlabel.h \
|
$$PWD/label/operationshowlabel.h \
|
||||||
$$PWD/saveplacelabeloptions.h
|
$$PWD/saveplacelabeloptions.h \
|
||||||
|
$$PWD/togglepiecestate.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/addtocalc.cpp \
|
$$PWD/addtocalc.cpp \
|
||||||
|
@ -50,9 +50,9 @@ SOURCES += \
|
||||||
$$PWD/deletepiece.cpp \
|
$$PWD/deletepiece.cpp \
|
||||||
$$PWD/movepiece.cpp \
|
$$PWD/movepiece.cpp \
|
||||||
$$PWD/savepieceoptions.cpp \
|
$$PWD/savepieceoptions.cpp \
|
||||||
$$PWD/togglepieceinlayout.cpp \
|
|
||||||
$$PWD/savepiecepathoptions.cpp \
|
$$PWD/savepiecepathoptions.cpp \
|
||||||
$$PWD/label/showlabel.cpp \
|
$$PWD/label/showlabel.cpp \
|
||||||
$$PWD/label/showdoublelabel.cpp \
|
$$PWD/label/showdoublelabel.cpp \
|
||||||
$$PWD/label/operationshowlabel.cpp \
|
$$PWD/label/operationshowlabel.cpp \
|
||||||
$$PWD/saveplacelabeloptions.cpp
|
$$PWD/saveplacelabeloptions.cpp \
|
||||||
|
$$PWD/togglepiecestate.cpp
|
||||||
|
|
|
@ -59,8 +59,7 @@ enum class UndoCommand: char { AddPatternPiece,
|
||||||
RenamePP,
|
RenamePP,
|
||||||
MoveLabel,
|
MoveLabel,
|
||||||
MoveDoubleLabel,
|
MoveDoubleLabel,
|
||||||
RotationMoveLabel,
|
RotationMoveLabel
|
||||||
TogglePieceInLayout
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class VPattern;
|
class VPattern;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user