Refactoring. Instead of using proxy slots emit signals directly from lambda

expressions.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-07-13 14:41:44 +03:00
parent 14d4f14adb
commit e4d6df06b7
17 changed files with 17 additions and 55 deletions

View File

@ -59,7 +59,7 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent)
FillTable(); FillTable();
InitialTable(); InitialTable();
connect(ui->tableWidget, &QTableWidget::cellClicked, this, &DialogHistory::cellClicked); 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::ChangedCursor, this, &DialogHistory::ChangedCursor);
connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory); connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory);
ShowPoint(); ShowPoint();

View File

@ -55,7 +55,7 @@ DialogLayoutProgress::DialogLayoutProgress(int count, QWidget *parent)
QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel);
SCASSERT(bCancel != nullptr); SCASSERT(bCancel != nullptr);
connect(bCancel, &QPushButton::clicked, this, &DialogLayoutProgress::StopWorking); connect(bCancel, &QPushButton::clicked, [this](){emit Abort();});
setModal(true); setModal(true);
this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint); this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
@ -109,12 +109,6 @@ void DialogLayoutProgress::Finished()
done(QDialog::Accepted); done(QDialog::Accepted);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutProgress::StopWorking()
{
emit Abort();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutProgress::showEvent(QShowEvent *event) void DialogLayoutProgress::showEvent(QShowEvent *event)
{ {

View File

@ -54,7 +54,6 @@ public slots:
void Arranged(int count); void Arranged(int count);
void Error(const LayoutErrors &state); void Error(const LayoutErrors &state);
void Finished(); void Finished();
void StopWorking();
protected: protected:
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;

View File

@ -1052,29 +1052,6 @@ void VAbstractPattern::haveLiteChange()
emit patternChanged(false); 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 void VAbstractPattern::ToolExists(const quint32 &id) const
{ {

View File

@ -253,9 +253,6 @@ signals:
public slots: public slots:
virtual void LiteParseTree(const Document &parse)=0; virtual void LiteParseTree(const Document &parse)=0;
void haveLiteChange(); void haveLiteChange();
void ShowHistoryTool(quint32 id, bool enable);
void NeedFullParsing();
void ClearScene();
protected: protected:
/** @brief nameActivDraw name current pattern peace. */ /** @brief nameActivDraw name current pattern peace. */

View File

@ -128,7 +128,7 @@ void DialogCubicBezierPath::ChosenObject(quint32 id, const SceneObject &type)
if (path.CountPoints() == 1) if (path.CountPoints() == 1)
{ {
visPath->VisualMode(NULL_ID); visPath->VisualMode(NULL_ID);
connect(visPath, &VisToolCubicBezierPath::ToolTip, this, &DialogTool::ShowVisToolTip); connect(visPath, &VisToolCubicBezierPath::ToolTip, [this](const QString &toolTip){emit ToolTip(toolTip);});
} }
else else
{ {

View File

@ -217,7 +217,8 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{ {
number++; number++;
line->VisualMode(id); line->VisualMode(id);
connect(line, &VisToolCurveIntersectAxis::ToolTip, this, &DialogTool::ShowVisToolTip); connect(line, &VisToolCurveIntersectAxis::ToolTip,
[this](const QString &toolTip){emit ToolTip(toolTip);});
} }
} }
break; break;

View File

@ -167,7 +167,7 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type)
if (SetObject(id, ui->comboBoxBasePoint, "")) if (SetObject(id, ui->comboBoxBasePoint, ""))
{ {
vis->VisualMode(id); 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; prepare = true;
} }
} }

View File

@ -242,7 +242,8 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{ {
number++; number++;
line->VisualMode(id); line->VisualMode(id);
connect(line, &VisToolLineIntersectAxis::ToolTip, this, &DialogTool::ShowVisToolTip); connect(line, &VisToolLineIntersectAxis::ToolTip,
[this](const QString &toolTip){emit ToolTip(toolTip);});
} }
break; break;
case (1): case (1):

View File

@ -216,7 +216,7 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis); VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr); 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->SetOriginPointId(id);
operation->RefreshGeometry(); operation->RefreshGeometry();

View File

@ -181,7 +181,7 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type)
if (path.CountPoints() == 1) if (path.CountPoints() == 1)
{ {
visPath->VisualMode(NULL_ID); 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); connect(visPath, &VisToolSplinePath::PathChanged, this, &DialogSplinePath::PathUpdated);
} }
else else

View File

@ -912,12 +912,6 @@ QString DialogTool::getPointName() const
return pointName; return pointName;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::ShowVisToolTip(const QString &toolTip)
{
emit ToolTip(toolTip);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::ShowDialog(bool click) void DialogTool::ShowDialog(bool click)
{ {

View File

@ -91,7 +91,6 @@ signals:
*/ */
void ToolTip(const QString &toolTip); void ToolTip(const QString &toolTip);
public slots: public slots:
void ShowVisToolTip(const QString &toolTip);
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
virtual void SelectedObject(bool selected, quint32 object, quint32 tool); virtual void SelectedObject(bool selected, quint32 object, quint32 tool);
void NamePointChanged(); void NamePointChanged();

View File

@ -143,8 +143,8 @@ void VToolBasePoint::AddToFile()
patternPiece.appendChild(doc->createElement(VAbstractPattern::TagDetails)); patternPiece.appendChild(doc->createElement(VAbstractPattern::TagDetails));
AddPatternPiece *addPP = new AddPatternPiece(patternPiece, doc, namePP); AddPatternPiece *addPP = new AddPatternPiece(patternPiece, doc, namePP);
connect(addPP, &AddPatternPiece::ClearScene, doc, &VAbstractPattern::ClearScene); connect(addPP, &AddPatternPiece::ClearScene, [this](){emit doc->ClearMainWindow();});
connect(addPP, &AddPatternPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); connect(addPP, &AddPatternPiece::NeedFullParsing, [this](){emit doc->UndoCommand();});
qApp->getUndoStack()->push(addPP); qApp->getUndoStack()->push(addPP);
} }
@ -233,7 +233,7 @@ void VToolBasePoint::DeleteTool(bool ask)
qCDebug(vTool, "Begin deleting."); qCDebug(vTool, "Begin deleting.");
DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw); 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); qApp->getUndoStack()->push(deletePP);
// Throw exception, this will help prevent case when we forget to immediately quit function. // Throw exception, this will help prevent case when we forget to immediately quit function.

View File

@ -372,7 +372,7 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine
void VDrawTool::AddToCalculation(const QDomElement &domElement) void VDrawTool::AddToCalculation(const QDomElement &domElement)
{ {
AddToCalc *addToCal = new AddToCalc(domElement, doc); 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); qApp->getUndoStack()->push(addToCal);
} }

View File

@ -88,7 +88,7 @@ void VAbstractTool::DeleteTool(bool ask)
qCDebug(vTool, "Begin deleting."); qCDebug(vTool, "Begin deleting.");
DelTool *delTool = new DelTool(doc, id); 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); qApp->getUndoStack()->push(delTool);
// Throw exception, this will help prevent case when we forget to immediately quit function. // Throw exception, this will help prevent case when we forget to immediately quit function.

View File

@ -331,7 +331,7 @@ void VToolDetail::AddToFile()
} }
AddDet *addDet = new AddDet(domElement, doc, detail, drawName); 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); qApp->getUndoStack()->push(addDet);
} }
@ -680,7 +680,7 @@ void VToolDetail::DeleteTool(bool ask)
return; return;
} }
/* If UnionDetails tool delete detail no need emit FullParsing.*/ /* 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); qApp->getUndoStack()->push(delDet);