Returned undocommand "Toggle piece in layout".

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-09 15:53:22 +02:00
parent 988ce8f7f2
commit 39d2ea41ac
18 changed files with 177 additions and 68 deletions

View File

@ -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/toggledetailinlayout.h" #include "../vtools/undocommands/togglepieceinlayout.h"
#include <QMenu> #include <QMenu>
#include <QUndoStack> #include <QUndoStack>
@ -45,7 +45,7 @@ VWidgetDetails::VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget
{ {
ui->setupUi(this); ui->setupUi(this);
FillTable(m_data->DataDetails()); FillTable(m_data->DataPieces());
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
@ -62,7 +62,7 @@ VWidgetDetails::~VWidgetDetails()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VWidgetDetails::UpdateList() void VWidgetDetails::UpdateList()
{ {
FillTable(m_data->DataDetails()); FillTable(m_data->DataPieces());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -93,16 +93,16 @@ void VWidgetDetails::InLayoutStateChanged(int row, int column)
return; return;
} }
const QHash<quint32, VDetail> *allDetails = m_data->DataDetails(); const QHash<quint32, VPiece> *allDetails = m_data->DataPieces();
const bool inLayout = not allDetails->value(id).IsInLayout(); const bool inLayout = not allDetails->value(id).IsInLayout();
ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, inLayout, m_data, m_doc); TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, inLayout, m_data, m_doc);
connect(togglePrint, &ToggleDetailInLayout::UpdateList, this, &VWidgetDetails::UpdateList); connect(togglePrint, &TogglePieceInLayout::UpdateList, this, &VWidgetDetails::UpdateList);
qApp->getUndoStack()->push(togglePrint); qApp->getUndoStack()->push(togglePrint);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VWidgetDetails::FillTable(const QHash<quint32, VDetail> *details) void VWidgetDetails::FillTable(const QHash<quint32, VPiece> *details)
{ {
const int selectedRow = ui->tableWidget->currentRow(); const int selectedRow = ui->tableWidget->currentRow();
ui->tableWidget->clear(); ui->tableWidget->clear();
@ -114,7 +114,7 @@ void VWidgetDetails::FillTable(const QHash<quint32, VDetail> *details)
while (i != details->constEnd()) while (i != details->constEnd())
{ {
++currentRow; ++currentRow;
const VDetail det = i.value(); const VPiece det = i.value();
QTableWidgetItem *item = new QTableWidgetItem(); QTableWidgetItem *item = new QTableWidgetItem();
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
@ -134,7 +134,7 @@ void VWidgetDetails::FillTable(const QHash<quint32, VDetail> *details)
ui->tableWidget->setItem(currentRow, 0, item); ui->tableWidget->setItem(currentRow, 0, item);
QString name = det.getName(); QString name = det.GetName();
if (name.isEmpty()) if (name.isEmpty())
{ {
name = tr("Unnamed"); name = tr("Unnamed");
@ -158,7 +158,7 @@ void VWidgetDetails::FillTable(const QHash<quint32, VDetail> *details)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VWidgetDetails::ToggleSectionDetails(bool select) void VWidgetDetails::ToggleSectionDetails(bool select)
{ {
const QHash<quint32, VDetail> *allDetails = m_data->DataDetails(); const QHash<quint32, VPiece> *allDetails = m_data->DataPieces();
if (allDetails->count() == 0) if (allDetails->count() == 0)
{ {
return; return;
@ -172,8 +172,8 @@ void VWidgetDetails::ToggleSectionDetails(bool select)
{ {
if (not select == allDetails->value(id).IsInLayout()) if (not select == allDetails->value(id).IsInLayout())
{ {
ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, select, m_data, m_doc); TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc);
connect(togglePrint, &ToggleDetailInLayout::UpdateList, this, &VWidgetDetails::UpdateList); connect(togglePrint, &TogglePieceInLayout::UpdateList, this, &VWidgetDetails::UpdateList);
qApp->getUndoStack()->push(togglePrint); qApp->getUndoStack()->push(togglePrint);
} }
} }
@ -193,7 +193,7 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
QAction *actionInvertSelection = menu->addAction(tr("Invert selection")); QAction *actionInvertSelection = menu->addAction(tr("Invert selection"));
const QHash<quint32, VDetail> *allDetails = m_data->DataDetails(); const QHash<quint32, VPiece> *allDetails = m_data->DataPieces();
if (allDetails->count() == 0) if (allDetails->count() == 0)
{ {
return; return;
@ -201,7 +201,7 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
int selectedDetails = 0; int selectedDetails = 0;
QHash<quint32, VDetail>::const_iterator iter = allDetails->constBegin(); auto iter = allDetails->constBegin();
while (iter != allDetails->constEnd()) while (iter != allDetails->constEnd())
{ {
if(iter.value().IsInLayout()) if(iter.value().IsInLayout())
@ -220,7 +220,6 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
actionSelectAll->setDisabled(true); actionSelectAll->setDisabled(true);
} }
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos)); QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
bool select; bool select;
@ -250,8 +249,8 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
{ {
select = not allDetails->value(id).IsInLayout(); select = not allDetails->value(id).IsInLayout();
ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, select, m_data, m_doc); TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc);
connect(togglePrint, &ToggleDetailInLayout::UpdateList, this, &VWidgetDetails::UpdateList); connect(togglePrint, &TogglePieceInLayout::UpdateList, this, &VWidgetDetails::UpdateList);
qApp->getUndoStack()->push(togglePrint); qApp->getUndoStack()->push(togglePrint);
} }
} }

View File

@ -33,7 +33,7 @@
class VAbstractPattern; class VAbstractPattern;
class VContainer; class VContainer;
class VDetail; class VPiece;
namespace Ui namespace Ui
{ {
@ -65,7 +65,7 @@ private:
VAbstractPattern *m_doc; VAbstractPattern *m_doc;
VContainer *m_data; VContainer *m_data;
void FillTable(const QHash<quint32, VDetail> *details); void FillTable(const QHash<quint32, VPiece> *details);
void ToggleSectionDetails(bool select); void ToggleSectionDetails(bool select);
}; };

View File

@ -615,7 +615,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
{ {
VPiece detail; VPiece detail;
const quint32 id = GetParametrId(domElement); const quint32 id = GetParametrId(domElement);
// detail.setName(GetParametrString(domElement, AttrName, "")); detail.SetName(GetParametrString(domElement, AttrName, ""));
detail.SetMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, "0.0"))); detail.SetMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, "0.0")));
detail.SetMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, "0.0"))); detail.SetMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, "0.0")));
// detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1")); // detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1"));
@ -623,7 +623,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
// detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1")); // detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1"));
// detail.setForbidFlipping(GetParametrUInt(domElement, VToolDetail::AttrForbidFlipping, // detail.setForbidFlipping(GetParametrUInt(domElement, VToolDetail::AttrForbidFlipping,
// QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping()))); // QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
// detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));
const QStringList tags = QStringList() << VToolSeamAllowance::TagNodes const QStringList tags = QStringList() << VToolSeamAllowance::TagNodes
<< TagData << TagData

View File

@ -412,6 +412,8 @@
<xs:attribute name="version" type="pieceVersion"></xs:attribute> <xs:attribute name="version" type="pieceVersion"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute> <xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute> <xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="inLayout" type="xs:boolean"></xs:attribute>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>

View File

@ -1694,12 +1694,10 @@ void VPatternConverter::TagDetailToV0_4_0()
if (not dom.isNull()) if (not dom.isNull())
{ {
dom.removeAttribute(strName);
dom.removeAttribute(strSupplement); dom.removeAttribute(strSupplement);
dom.removeAttribute(strClosed); dom.removeAttribute(strClosed);
dom.removeAttribute(strWidth); dom.removeAttribute(strWidth);
dom.removeAttribute(strForbidFlipping); dom.removeAttribute(strForbidFlipping);
dom.removeAttribute(strInLayout);
dom.setAttribute(strVersion, "1"); dom.setAttribute(strVersion, "1");

View File

@ -27,6 +27,7 @@
*************************************************************************/ *************************************************************************/
#include "vabstractpiece.h" #include "vabstractpiece.h"
#include "vabstractpiece_p.h"
#include <QLineF> #include <QLineF>
#include <QSet> #include <QSet>
@ -37,13 +38,13 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractPiece::VAbstractPiece() VAbstractPiece::VAbstractPiece()
: d(new VAbstractPieceData)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractPiece::VAbstractPiece(const VAbstractPiece &piece) VAbstractPiece::VAbstractPiece(const VAbstractPiece &piece)
{ :d (piece.d)
Q_UNUSED(piece) {}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractPiece &VAbstractPiece::operator=(const VAbstractPiece &piece) VAbstractPiece &VAbstractPiece::operator=(const VAbstractPiece &piece)
@ -52,6 +53,7 @@ VAbstractPiece &VAbstractPiece::operator=(const VAbstractPiece &piece)
{ {
return *this; return *this;
} }
d = piece.d;
return *this; return *this;
} }
@ -59,6 +61,18 @@ VAbstractPiece &VAbstractPiece::operator=(const VAbstractPiece &piece)
VAbstractPiece::~VAbstractPiece() VAbstractPiece::~VAbstractPiece()
{} {}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPiece::GetName() const
{
return d->m_name;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPiece::SetName(const QString &value)
{
d->m_name = value;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractPiece::SumTrapezoids(const QVector<QPointF> &points) qreal VAbstractPiece::SumTrapezoids(const QVector<QPointF> &points)
{ {

View File

@ -30,9 +30,11 @@
#define VABSTRACTPIECE_H #define VABSTRACTPIECE_H
#include <QtGlobal> #include <QtGlobal>
#include <QSharedDataPointer>
template <class T> class QVector; template <class T> class QVector;
class QPointF; class QPointF;
class VAbstractPieceData;
class VAbstractPiece class VAbstractPiece
{ {
@ -42,12 +44,18 @@ public:
VAbstractPiece &operator=(const VAbstractPiece &piece); VAbstractPiece &operator=(const VAbstractPiece &piece);
virtual ~VAbstractPiece(); virtual ~VAbstractPiece();
QString GetName() const;
void SetName(const QString &value);
static qreal SumTrapezoids(const QVector<QPointF> &points); static qreal SumTrapezoids(const QVector<QPointF> &points);
static QVector<QPointF> CheckLoops(const QVector<QPointF> &points); static QVector<QPointF> CheckLoops(const QVector<QPointF> &points);
static QVector<QPointF> CorrectEquidistantPoints(const QVector<QPointF> &points, bool removeFirstAndLast = true); static QVector<QPointF> CorrectEquidistantPoints(const QVector<QPointF> &points, bool removeFirstAndLast = true);
protected: protected:
static QVector<QPointF> RemoveDublicates(const QVector<QPointF> &points, bool removeFirstAndLast = true); static QVector<QPointF> RemoveDublicates(const QVector<QPointF> &points, bool removeFirstAndLast = true);
private:
QSharedDataPointer<VAbstractPieceData> d;
}; };
#endif // VABSTRACTPIECE_H #endif // VABSTRACTPIECE_H

View File

@ -0,0 +1,66 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 9 11, 2016
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2016 Valentina project
** <https://bitbucket.org/dismine/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 VABSTRACTPIECE_P_H
#define VABSTRACTPIECE_P_H
#include <QSharedData>
#include <QString>
#include "../vmisc/diagnostic.h"
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
class VAbstractPieceData : public QSharedData
{
public:
VAbstractPieceData()
: m_name()
{}
VAbstractPieceData(const VAbstractPieceData &piece)
: QSharedData(piece),
m_name(piece.m_name)
{}
~VAbstractPieceData();
QString m_name;
private:
VAbstractPieceData &operator=(const VAbstractPieceData &) Q_DECL_EQ_DELETE;
};
VAbstractPieceData::~VAbstractPieceData()
{}
QT_WARNING_POP
#endif // VABSTRACTPIECE_P_H

View File

@ -19,7 +19,8 @@ HEADERS += \
$$PWD/vtextmanager.h \ $$PWD/vtextmanager.h \
$$PWD/vposter.h \ $$PWD/vposter.h \
$$PWD/vgraphicsfillitem.h \ $$PWD/vgraphicsfillitem.h \
$$PWD/vabstractpiece.h $$PWD/vabstractpiece.h \
$$PWD/vabstractpiece_p.h
SOURCES += \ SOURCES += \
$$PWD/vlayoutgenerator.cpp \ $$PWD/vlayoutgenerator.cpp \

View File

@ -244,6 +244,18 @@ void VPiece::SetMy(qreal value)
d->m_my = value; d->m_my = value;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VPiece::IsInLayout() const
{
return d->m_inLayout;
}
//---------------------------------------------------------------------------------------------------------------------
void VPiece::SetInLayout(bool inLayout)
{
d->m_inLayout = inLayout;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Missing find missing nodes in detail. When we deleted object in detail and return this detail need * @brief Missing find missing nodes in detail. When we deleted object in detail and return this detail need

View File

@ -71,6 +71,9 @@ public:
qreal GetMy() const; qreal GetMy() const;
void SetMy(qreal value); void SetMy(qreal value);
bool IsInLayout() const;
void SetInLayout(bool inLayout);
QVector<VPieceNode> Missing(const VPiece &det) const; QVector<VPieceNode> Missing(const VPiece &det) const;
int indexOfNode(const quint32 &id) const; int indexOfNode(const quint32 &id) const;

View File

@ -44,14 +44,16 @@ public:
VPieceData() VPieceData()
: m_nodes(), : m_nodes(),
m_mx(0), m_mx(0),
m_my(0) m_my(0),
m_inLayout(true)
{} {}
VPieceData(const VPieceData &detail) VPieceData(const VPieceData &detail)
: QSharedData(detail), : QSharedData(detail),
m_nodes(detail.m_nodes), m_nodes(detail.m_nodes),
m_mx(detail.m_mx), m_mx(detail.m_mx),
m_my(detail.m_my) m_my(detail.m_my),
m_inLayout(detail.m_inLayout)
{} {}
~VPieceData(); ~VPieceData();
@ -62,6 +64,8 @@ public:
qreal m_mx; qreal m_mx;
qreal m_my; qreal m_my;
bool m_inLayout;
private: private:
VPieceData &operator=(const VPieceData &) Q_DECL_EQ_DELETE; VPieceData &operator=(const VPieceData &) Q_DECL_EQ_DELETE;
}; };

View File

@ -76,7 +76,7 @@
#include "../undocommands/deletedetail.h" #include "../undocommands/deletedetail.h"
#include "../undocommands/movepiece.h" #include "../undocommands/movepiece.h"
#include "../undocommands/savedetailoptions.h" #include "../undocommands/savedetailoptions.h"
#include "../undocommands/toggledetailinlayout.h" #include "../undocommands/togglepieceinlayout.h"
#include "../vgeometry/varc.h" #include "../vgeometry/varc.h"
#include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h" #include "../vgeometry/vcubicbezierpath.h"
@ -805,9 +805,9 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
} }
else if (selectedAction == inLayoutOption) else if (selectedAction == inLayoutOption)
{ {
ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, selectedAction->isChecked(), TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, selectedAction->isChecked(),
&(VAbstractTool::data), doc); &(VAbstractTool::data), doc);
connect(togglePrint, &ToggleDetailInLayout::UpdateList, doc, &VAbstractPattern::CheckInLayoutList); connect(togglePrint, &TogglePieceInLayout::UpdateList, doc, &VAbstractPattern::CheckInLayoutList);
qApp->getUndoStack()->push(togglePrint); qApp->getUndoStack()->push(togglePrint);
} }
else if (selectedAction == actionRemove) else if (selectedAction == actionRemove)

View File

@ -44,7 +44,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/togglepieceinlayout.h"
#include "../vwidgets/vmaingraphicsview.h" #include "../vwidgets/vmaingraphicsview.h"
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
@ -247,9 +247,11 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl
SCASSERT(doc != nullptr); SCASSERT(doc != nullptr);
doc->SetAttribute(domElement, VDomDocument::AttrId, id); doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrName, piece.GetName());
doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion)); doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(piece.GetMx())); doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(piece.GetMx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy())); doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy()));
doc->SetAttribute(domElement, AttrInLayout, piece.IsInLayout());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -518,10 +520,10 @@ 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"));
// QAction *inLayoutOption = menu.addAction(tr("In layout")); QAction *inLayoutOption = menu.addAction(tr("In layout"));
// inLayoutOption->setCheckable(true); inLayoutOption->setCheckable(true);
// const VDetail detail = VAbstractTool::data.GetDetail(id); const VPiece detail = VAbstractTool::data.GetPiece(id);
// inLayoutOption->setChecked(detail.IsInLayout()); inLayoutOption->setChecked(detail.IsInLayout());
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);
@ -537,13 +539,13 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
SetDialog(); SetDialog();
m_dialog->show(); m_dialog->show();
} }
// else if (selectedAction == inLayoutOption) else if (selectedAction == inLayoutOption)
// { {
// ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, selectedAction->isChecked(), TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, selectedAction->isChecked(),
// &(VAbstractTool::data), doc); &(VAbstractTool::data), doc);
// connect(togglePrint, &ToggleDetailInLayout::UpdateList, doc, &VAbstractPattern::CheckInLayoutList); connect(togglePrint, &TogglePieceInLayout::UpdateList, doc, &VAbstractPattern::CheckInLayoutList);
// qApp->getUndoStack()->push(togglePrint); qApp->getUndoStack()->push(togglePrint);
// } }
else if (selectedAction == actionRemove) else if (selectedAction == actionRemove)
{ {
try try

View File

@ -26,7 +26,7 @@
** **
*************************************************************************/ *************************************************************************/
#include "toggledetailinlayout.h" #include "togglepieceinlayout.h"
#include <QDomElement> #include <QDomElement>
#include <QHash> #include <QHash>
@ -38,30 +38,30 @@
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/logging.h" #include "../vmisc/logging.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vdetail.h" #include "../vpatterndb/vpiece.h"
#include "vundocommand.h" #include "vundocommand.h"
class QUndoCommand; class QUndoCommand;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
ToggleDetailInLayout::ToggleDetailInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc, TogglePieceInLayout::TogglePieceInLayout(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->DataDetails()->value(m_id).IsInLayout()), m_oldState(m_data->DataPieces()->value(m_id).IsInLayout()),
m_newState(state) m_newState(state)
{ {
setText(tr("detail in layout list")); setText(tr("detail in layout list"));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
ToggleDetailInLayout::~ToggleDetailInLayout() TogglePieceInLayout::~TogglePieceInLayout()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void ToggleDetailInLayout::undo() void TogglePieceInLayout::undo()
{ {
qCDebug(vUndo, "ToggleDetailInLayout::undo()."); qCDebug(vUndo, "ToggleDetailInLayout::undo().");
@ -72,7 +72,7 @@ void ToggleDetailInLayout::undo()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void ToggleDetailInLayout::redo() void TogglePieceInLayout::redo()
{ {
qCDebug(vUndo, "ToggleDetailInLayout::redo()."); qCDebug(vUndo, "ToggleDetailInLayout::redo().");
@ -83,25 +83,25 @@ void ToggleDetailInLayout::redo()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int ToggleDetailInLayout::id() const int TogglePieceInLayout::id() const
{ {
return static_cast<int>(UndoCommand::ToggleDetailInLayout); return static_cast<int>(UndoCommand::TogglePieceInLayout);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 ToggleDetailInLayout::getDetId() const quint32 TogglePieceInLayout::getDetId() const
{ {
return m_id; return m_id;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool ToggleDetailInLayout::getNewState() const bool TogglePieceInLayout::getNewState() const
{ {
return m_newState; return m_newState;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void ToggleDetailInLayout::Do(bool state) void TogglePieceInLayout::Do(bool state)
{ {
QDomElement detail = doc->elementById(m_id); QDomElement detail = doc->elementById(m_id);
if (detail.isElement()) if (detail.isElement())
@ -115,9 +115,9 @@ void ToggleDetailInLayout::Do(bool state)
detail.removeAttribute(AttrInLayout); detail.removeAttribute(AttrInLayout);
} }
VDetail det = m_data->DataDetails()->value(m_id); VPiece det = m_data->DataPieces()->value(m_id);
det.SetInLayout(state); det.SetInLayout(state);
m_data->UpdateDetail(m_id, det); m_data->UpdatePiece(m_id, det);
emit UpdateList(); emit UpdateList();
} }
else else

View File

@ -41,13 +41,13 @@ class QUndoCommand;
class VAbstractPattern; class VAbstractPattern;
class VContainer; class VContainer;
class ToggleDetailInLayout : public VUndoCommand class TogglePieceInLayout : public VUndoCommand
{ {
Q_OBJECT Q_OBJECT
public: public:
ToggleDetailInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc, TogglePieceInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
virtual ~ToggleDetailInLayout(); virtual ~TogglePieceInLayout();
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; virtual int id() const Q_DECL_OVERRIDE;
@ -57,7 +57,7 @@ public:
signals: signals:
void UpdateList(); void UpdateList();
private: private:
Q_DISABLE_COPY(ToggleDetailInLayout) Q_DISABLE_COPY(TogglePieceInLayout)
quint32 m_id; quint32 m_id;
VContainer *m_data; VContainer *m_data;
bool m_oldState; bool m_oldState;

View File

@ -21,12 +21,12 @@ HEADERS += \
$$PWD/addgroup.h \ $$PWD/addgroup.h \
$$PWD/delgroup.h \ $$PWD/delgroup.h \
$$PWD/label/moveabstractlabel.h \ $$PWD/label/moveabstractlabel.h \
$$PWD/toggledetailinlayout.h \
$$PWD/label/operationmovelabel.h \ $$PWD/label/operationmovelabel.h \
$$PWD/addpiece.h \ $$PWD/addpiece.h \
$$PWD/deletepiece.h \ $$PWD/deletepiece.h \
$$PWD/movepiece.h \ $$PWD/movepiece.h \
$$PWD/savepieceoptions.h $$PWD/savepieceoptions.h \
$$PWD/togglepieceinlayout.h
SOURCES += \ SOURCES += \
$$PWD/addtocalc.cpp \ $$PWD/addtocalc.cpp \
@ -48,9 +48,9 @@ SOURCES += \
$$PWD/addgroup.cpp \ $$PWD/addgroup.cpp \
$$PWD/delgroup.cpp \ $$PWD/delgroup.cpp \
$$PWD/label/moveabstractlabel.cpp \ $$PWD/label/moveabstractlabel.cpp \
$$PWD/toggledetailinlayout.cpp \
$$PWD/label/operationmovelabel.cpp \ $$PWD/label/operationmovelabel.cpp \
$$PWD/addpiece.cpp \ $$PWD/addpiece.cpp \
$$PWD/deletepiece.cpp \ $$PWD/deletepiece.cpp \
$$PWD/movepiece.cpp \ $$PWD/movepiece.cpp \
$$PWD/savepieceoptions.cpp $$PWD/savepieceoptions.cpp \
$$PWD/togglepieceinlayout.cpp

View File

@ -62,7 +62,7 @@ enum class UndoCommand: char { AddPatternPiece,
MoveLabel, MoveLabel,
MoveDoubleLabel, MoveDoubleLabel,
RotationMoveLabel, RotationMoveLabel,
ToggleDetailInLayout TogglePieceInLayout
}; };
class VNodeDetail; class VNodeDetail;