Apply button now works.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-09 16:27:55 +02:00
parent a6a492c8d3
commit 1c0dced61d
2 changed files with 25 additions and 10 deletions

View File

@ -302,19 +302,17 @@ void VToolSeamAllowance::FullUpdateFromGuiOk(int result)
{ {
if (result == QDialog::Accepted) if (result == QDialog::Accepted)
{ {
SCASSERT(not m_dialog.isNull()); SaveDialogChange();
DialogSeamAllowance *dialogTool = qobject_cast<DialogSeamAllowance*>(m_dialog.data());
SCASSERT(dialogTool != nullptr);
const VPiece newDet = dialogTool->GetPiece();
const VPiece oldDet = VAbstractTool::data.GetPiece(id);
SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, id, this->scene());
connect(saveCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(saveCommand);
} }
delete m_dialog; delete m_dialog;
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::FullUpdateFromGuiApply()
{
SaveDialogChange();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::EnableToolMove(bool move) void VToolSeamAllowance::EnableToolMove(bool move)
{ {
@ -536,6 +534,7 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
m_dialog = dialog; m_dialog = dialog;
m_dialog->setModal(true); m_dialog->setModal(true);
connect(m_dialog.data(), &DialogTool::DialogClosed, this, &VToolSeamAllowance::FullUpdateFromGuiOk); connect(m_dialog.data(), &DialogTool::DialogClosed, this, &VToolSeamAllowance::FullUpdateFromGuiOk);
connect(m_dialog.data(), &DialogTool::DialogApplied, this, &VToolSeamAllowance::FullUpdateFromGuiApply);
SetDialog(); SetDialog();
m_dialog->show(); m_dialog->show();
} }
@ -668,6 +667,20 @@ void VToolSeamAllowance::RefreshGeometry()
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::SaveDialogChange()
{
SCASSERT(not m_dialog.isNull());
DialogSeamAllowance *dialogTool = qobject_cast<DialogSeamAllowance*>(m_dialog.data());
SCASSERT(dialogTool != nullptr);
const VPiece newDet = dialogTool->GetPiece();
const VPiece oldDet = VAbstractTool::data.GetPiece(id);
SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, id, this->scene());
connect(saveCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(saveCommand);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::DeleteTool(bool ask) void VToolSeamAllowance::DeleteTool(bool ask)
{ {

View File

@ -83,6 +83,7 @@ public:
public slots: public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
virtual void FullUpdateFromGuiOk(int result); virtual void FullUpdateFromGuiOk(int result);
void FullUpdateFromGuiApply();
void EnableToolMove(bool move); void EnableToolMove(bool move);
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
@ -119,7 +120,8 @@ private:
VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation,
VMainGraphicsScene *scene, const QString &m_drawName, QGraphicsItem * parent = nullptr); VMainGraphicsScene *scene, const QString &m_drawName, QGraphicsItem * parent = nullptr);
void RefreshGeometry (); void RefreshGeometry();
void SaveDialogChange();
template <typename Tool> template <typename Tool>
Tool* InitTool(VMainGraphicsScene *scene, const VPieceNode &node); Tool* InitTool(VMainGraphicsScene *scene, const VPieceNode &node);