Refactoring. Create method SaveDialogChange.

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-11 19:45:39 +03:00
parent 1dfe9eda03
commit 81c1c39be9
2 changed files with 13 additions and 19 deletions

View File

@ -112,27 +112,22 @@ void VDrawTool::FullUpdateFromGuiOk(int result)
{ {
if (result == QDialog::Accepted) if (result == QDialog::Accepted)
{ {
QDomElement oldDomElement = doc->elementById(QString().setNum(id)); SaveDialogChange();
if (oldDomElement.isElement())
{
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
SaveDialog(newDomElement);
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id);
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree);
qApp->getUndoStack()->push(saveOptions);
} }
else DialogLinkDestroy();
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
delete dialog;
dialog = nullptr;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromGuiApply refresh tool data after change in options but do not delete dialog
*/
void VDrawTool::FullUpdateFromGuiApply() void VDrawTool::FullUpdateFromGuiApply()
{
SaveDialogChange();
}
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::SaveDialogChange()
{ {
QDomElement oldDomElement = doc->elementById(QString().setNum(id)); QDomElement oldDomElement = doc->elementById(QString().setNum(id));
if (oldDomElement.isElement()) if (oldDomElement.isElement())
@ -153,6 +148,7 @@ void VDrawTool::FullUpdateFromGuiApply()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDrawTool::DialogLinkDestroy() void VDrawTool::DialogLinkDestroy()
{ {
delete this->dialog;
this->dialog=nullptr; this->dialog=nullptr;
} }

View File

@ -62,9 +62,6 @@ public slots:
virtual void ChangedActivDraw(const QString &newName); virtual void ChangedActivDraw(const QString &newName);
void ChangedNameDraw(const QString &oldName, const QString &newName); void ChangedNameDraw(const QString &oldName, const QString &newName);
virtual void FullUpdateFromGuiOk(int result); virtual void FullUpdateFromGuiOk(int result);
/**
* @brief FullUpdateFromGuiApply refresh tool data after change in options but do not delete dialog
*/
virtual void FullUpdateFromGuiApply(); virtual void FullUpdateFromGuiApply();
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
protected: protected:
@ -87,6 +84,7 @@ protected:
/** @brief SaveDialog save options into file after change in dialog. */ /** @brief SaveDialog save options into file after change in dialog. */
virtual void SaveDialog(QDomElement &domElement)=0; virtual void SaveDialog(QDomElement &domElement)=0;
void SaveDialogChange();
template <typename Dialog, typename Tool> template <typename Dialog, typename Tool>
/** /**