Refactoring.

--HG--
branch : develop
This commit is contained in:
dismine 2014-06-26 13:41:59 +03:00
parent 88b8a00a2e
commit 280b7c9584
4 changed files with 17 additions and 22 deletions

View File

@ -188,13 +188,7 @@ void VToolSinglePoint::DeleteTool(bool ask)
{ {
if (ask) if (ask)
{ {
QMessageBox msgBox; if (ConfirmDeletion() == QMessageBox::Cancel)
msgBox.setText(tr("Confirm the deletion."));
msgBox.setInformativeText(tr("Do you really want delete?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Question);
if (msgBox.exec() == QMessageBox::Cancel)
{ {
return; return;
} }

View File

@ -246,13 +246,7 @@ void VAbstractTool::DeleteTool(bool ask)
{ {
if (ask) if (ask)
{ {
QMessageBox msgBox; if (ConfirmDeletion() == QMessageBox::Cancel)
msgBox.setText(tr("Confirm the deletion."));
msgBox.setInformativeText(tr("Do you really want delete?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Question);
if (msgBox.exec() == QMessageBox::Cancel)
{ {
return; return;
} }
@ -296,6 +290,18 @@ Qt::PenStyle VAbstractTool::LineStyle()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
int VAbstractTool::ConfirmDeletion()
{
QMessageBox msgBox;
msgBox.setText(tr("Confirm the deletion."));
msgBox.setInformativeText(tr("Do you really want delete?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Question);
return msgBox.exec();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0. * @brief LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0.

View File

@ -148,6 +148,7 @@ protected:
virtual void RemoveReferens(){} virtual void RemoveReferens(){}
virtual void DeleteTool(bool ask = true); virtual void DeleteTool(bool ask = true);
Qt::PenStyle LineStyle(); Qt::PenStyle LineStyle();
static int ConfirmDeletion();
private: private:
Q_DISABLE_COPY(VAbstractTool) Q_DISABLE_COPY(VAbstractTool)
}; };

View File

@ -496,17 +496,11 @@ void VToolDetail::DeleteTool(bool ask)
DeleteDetail *delDet = new DeleteDetail(doc, id); DeleteDetail *delDet = new DeleteDetail(doc, id);
if (ask) if (ask)
{ {
QMessageBox msgBox; if (ConfirmDeletion() == QMessageBox::Cancel)
msgBox.setText(tr("Confirm the deletion."));
msgBox.setInformativeText(tr("Do you really want delete?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Question);
if (msgBox.exec() == QMessageBox::Cancel)
{ {
return; return;
} }
/*Ugly hack. If UnionDetails delete detail no need emit FullParsing */ /* If UnionDetails tool delete detail no need emit FullParsing.*/
connect(delDet, &DeleteDetail::NeedFullParsing, doc, &VPattern::NeedFullParsing); connect(delDet, &DeleteDetail::NeedFullParsing, doc, &VPattern::NeedFullParsing);
} }
qApp->getUndoStack()->push(delDet); qApp->getUndoStack()->push(delDet);