From e4d6df06b7e968a3c49d803914ef374e61b93d6b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 13 Jul 2016 14:41:44 +0300 Subject: [PATCH] Refactoring. Instead of using proxy slots emit signals directly from lambda expressions. --HG-- branch : develop --- src/app/valentina/dialogs/dialoghistory.cpp | 2 +- .../dialogs/dialoglayoutprogress.cpp | 8 +------ .../valentina/dialogs/dialoglayoutprogress.h | 1 - src/libs/ifc/xml/vabstractpattern.cpp | 23 ------------------- src/libs/ifc/xml/vabstractpattern.h | 3 --- .../dialogs/tools/dialogcubicbezierpath.cpp | 2 +- .../tools/dialogcurveintersectaxis.cpp | 3 ++- .../vtools/dialogs/tools/dialogendline.cpp | 2 +- .../dialogs/tools/dialoglineintersectaxis.cpp | 3 ++- .../vtools/dialogs/tools/dialogrotation.cpp | 2 +- .../vtools/dialogs/tools/dialogsplinepath.cpp | 2 +- src/libs/vtools/dialogs/tools/dialogtool.cpp | 6 ----- src/libs/vtools/dialogs/tools/dialogtool.h | 1 - .../toolsinglepoint/vtoolbasepoint.cpp | 6 ++--- src/libs/vtools/tools/drawTools/vdrawtool.cpp | 2 +- src/libs/vtools/tools/vabstracttool.cpp | 2 +- src/libs/vtools/tools/vtooldetail.cpp | 4 ++-- 17 files changed, 17 insertions(+), 55 deletions(-) diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index 239b150ad..46170015f 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -59,7 +59,7 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent) FillTable(); InitialTable(); connect(ui->tableWidget, &QTableWidget::cellClicked, this, &DialogHistory::cellClicked); - connect(this, &DialogHistory::ShowHistoryTool, doc, &VPattern::ShowHistoryTool); + connect(this, &DialogHistory::ShowHistoryTool, [doc](quint32 id, bool enable){emit doc->ShowTool(id, enable);}); connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor); connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory); ShowPoint(); diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.cpp b/src/app/valentina/dialogs/dialoglayoutprogress.cpp index 0f236b912..d7de471bd 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.cpp +++ b/src/app/valentina/dialogs/dialoglayoutprogress.cpp @@ -55,7 +55,7 @@ DialogLayoutProgress::DialogLayoutProgress(int count, QWidget *parent) QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel); SCASSERT(bCancel != nullptr); - connect(bCancel, &QPushButton::clicked, this, &DialogLayoutProgress::StopWorking); + connect(bCancel, &QPushButton::clicked, [this](){emit Abort();}); setModal(true); this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint); @@ -109,12 +109,6 @@ void DialogLayoutProgress::Finished() done(QDialog::Accepted); } -//--------------------------------------------------------------------------------------------------------------------- -void DialogLayoutProgress::StopWorking() -{ - emit Abort(); -} - //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutProgress::showEvent(QShowEvent *event) { diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.h b/src/app/valentina/dialogs/dialoglayoutprogress.h index 38eb0b96e..7f339e44f 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.h +++ b/src/app/valentina/dialogs/dialoglayoutprogress.h @@ -54,7 +54,6 @@ public slots: void Arranged(int count); void Error(const LayoutErrors &state); void Finished(); - void StopWorking(); protected: virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index db7b7d50b..8b43bcb04 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1052,29 +1052,6 @@ void VAbstractPattern::haveLiteChange() emit patternChanged(false); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ShowHistoryTool hightlight tool. - * @param id tool id. - * @param enable enable or diasable hightlight. - */ -void VAbstractPattern::ShowHistoryTool(quint32 id, bool enable) -{ - emit ShowTool(id, enable); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VAbstractPattern::NeedFullParsing() -{ - emit UndoCommand(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VAbstractPattern::ClearScene() -{ - emit ClearMainWindow(); -} - //--------------------------------------------------------------------------------------------------------------------- void VAbstractPattern::ToolExists(const quint32 &id) const { diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 172f7cce3..a6b7e7ab1 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -253,9 +253,6 @@ signals: public slots: virtual void LiteParseTree(const Document &parse)=0; void haveLiteChange(); - void ShowHistoryTool(quint32 id, bool enable); - void NeedFullParsing(); - void ClearScene(); protected: /** @brief nameActivDraw name current pattern peace. */ diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp index ef7e22793..155ea6620 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp @@ -128,7 +128,7 @@ void DialogCubicBezierPath::ChosenObject(quint32 id, const SceneObject &type) if (path.CountPoints() == 1) { visPath->VisualMode(NULL_ID); - connect(visPath, &VisToolCubicBezierPath::ToolTip, this, &DialogTool::ShowVisToolTip); + connect(visPath, &VisToolCubicBezierPath::ToolTip, [this](const QString &toolTip){emit ToolTip(toolTip);}); } else { diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index b645fa884..2ed8d355f 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -217,7 +217,8 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { number++; line->VisualMode(id); - connect(line, &VisToolCurveIntersectAxis::ToolTip, this, &DialogTool::ShowVisToolTip); + connect(line, &VisToolCurveIntersectAxis::ToolTip, + [this](const QString &toolTip){emit ToolTip(toolTip);}); } } break; diff --git a/src/libs/vtools/dialogs/tools/dialogendline.cpp b/src/libs/vtools/dialogs/tools/dialogendline.cpp index dd668813e..a4dbe1a5e 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogendline.cpp @@ -167,7 +167,7 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxBasePoint, "")) { vis->VisualMode(id); - connect(vis.data(), &Visualization::ToolTip, this, &DialogTool::ShowVisToolTip); + connect(vis.data(), &Visualization::ToolTip, [this](const QString &toolTip){emit ToolTip(toolTip);}); prepare = true; } } diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp index 7f6b56f61..01a153a9b 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp @@ -242,7 +242,8 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { number++; line->VisualMode(id); - connect(line, &VisToolLineIntersectAxis::ToolTip, this, &DialogTool::ShowVisToolTip); + connect(line, &VisToolLineIntersectAxis::ToolTip, + [this](const QString &toolTip){emit ToolTip(toolTip);}); } break; case (1): diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index 08c8f33ae..69611de94 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -216,7 +216,7 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type) VisToolRotation *operation = qobject_cast(vis); SCASSERT(operation != nullptr); - connect(operation, &Visualization::ToolTip, this, &DialogTool::ShowVisToolTip); + connect(operation, &Visualization::ToolTip, [this](const QString &toolTip){emit ToolTip(toolTip);}); operation->SetOriginPointId(id); operation->RefreshGeometry(); diff --git a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp index ed4a3eb50..d025c97d3 100644 --- a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp @@ -181,7 +181,7 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type) if (path.CountPoints() == 1) { visPath->VisualMode(NULL_ID); - connect(visPath, &VisToolSplinePath::ToolTip, this, &DialogTool::ShowVisToolTip); + connect(visPath, &VisToolSplinePath::ToolTip, [this](const QString &toolTip){emit ToolTip(toolTip);}); connect(visPath, &VisToolSplinePath::PathChanged, this, &DialogSplinePath::PathUpdated); } else diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 1515c9af8..5e56b1c0f 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -912,12 +912,6 @@ QString DialogTool::getPointName() const return pointName; } -//--------------------------------------------------------------------------------------------------------------------- -void DialogTool::ShowVisToolTip(const QString &toolTip) -{ - emit ToolTip(toolTip); -} - //--------------------------------------------------------------------------------------------------------------------- void DialogTool::ShowDialog(bool click) { diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index 1a5a0ee78..b227794ee 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -91,7 +91,6 @@ signals: */ void ToolTip(const QString &toolTip); public slots: - void ShowVisToolTip(const QString &toolTip); virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void SelectedObject(bool selected, quint32 object, quint32 tool); void NamePointChanged(); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index 7e1c32dab..b4f212b58 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -143,8 +143,8 @@ void VToolBasePoint::AddToFile() patternPiece.appendChild(doc->createElement(VAbstractPattern::TagDetails)); AddPatternPiece *addPP = new AddPatternPiece(patternPiece, doc, namePP); - connect(addPP, &AddPatternPiece::ClearScene, doc, &VAbstractPattern::ClearScene); - connect(addPP, &AddPatternPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); + connect(addPP, &AddPatternPiece::ClearScene, [this](){emit doc->ClearMainWindow();}); + connect(addPP, &AddPatternPiece::NeedFullParsing, [this](){emit doc->UndoCommand();}); qApp->getUndoStack()->push(addPP); } @@ -233,7 +233,7 @@ void VToolBasePoint::DeleteTool(bool ask) qCDebug(vTool, "Begin deleting."); DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw); - connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); + connect(deletePP, &DeletePatternPiece::NeedFullParsing, [this](){emit doc->UndoCommand();}); qApp->getUndoStack()->push(deletePP); // Throw exception, this will help prevent case when we forget to immediately quit function. diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 81bbfb172..c88ffbcfe 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -372,7 +372,7 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine void VDrawTool::AddToCalculation(const QDomElement &domElement) { AddToCalc *addToCal = new AddToCalc(domElement, doc); - connect(addToCal, &AddToCalc::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); + connect(addToCal, &AddToCalc::NeedFullParsing, [this](){emit doc->UndoCommand();}); qApp->getUndoStack()->push(addToCal); } diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index ad74b4cf4..150a900f0 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -88,7 +88,7 @@ void VAbstractTool::DeleteTool(bool ask) qCDebug(vTool, "Begin deleting."); DelTool *delTool = new DelTool(doc, id); - connect(delTool, &DelTool::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); + connect(delTool, &DelTool::NeedFullParsing, [this](){emit doc->UndoCommand();}); qApp->getUndoStack()->push(delTool); // Throw exception, this will help prevent case when we forget to immediately quit function. diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 9eed8d8c3..2d8041193 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -331,7 +331,7 @@ void VToolDetail::AddToFile() } AddDet *addDet = new AddDet(domElement, doc, detail, drawName); - connect(addDet, &AddDet::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); + connect(addDet, &AddDet::NeedFullParsing, [this](){emit doc->UndoCommand();}); qApp->getUndoStack()->push(addDet); } @@ -680,7 +680,7 @@ void VToolDetail::DeleteTool(bool ask) return; } /* If UnionDetails tool delete detail no need emit FullParsing.*/ - connect(delDet, &DeleteDetail::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); + connect(delDet, &DeleteDetail::NeedFullParsing, [this](){emit doc->UndoCommand();}); } qApp->getUndoStack()->push(delDet);