From b8872a0319474cd2999b695a66ef4bec243647a1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 11 May 2022 17:14:40 +0300 Subject: [PATCH] Code style. --- .../vtools/dialogs/tools/dialogendline.cpp | 18 +++---- src/libs/vtools/dialogs/tools/dialogmove.cpp | 20 ++++--- .../vtools/dialogs/tools/dialogrotation.cpp | 53 +++++++++---------- .../visualization/line/vistoolendline.cpp | 2 +- 4 files changed, 42 insertions(+), 51 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogendline.cpp b/src/libs/vtools/dialogs/tools/dialogendline.cpp index edc66fe58..8d95b66b8 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogendline.cpp @@ -208,7 +208,7 @@ void DialogEndLine::FXLength() */ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false)// After first choose we ignore all objects + if (not prepare)// After first choose we ignore all objects { if (type == SceneObject::Point) { @@ -218,8 +218,7 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) { vis->VisualMode(id); } - VAbstractMainWindow *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); prepare = true; @@ -267,7 +266,7 @@ void DialogEndLine::SetFormula(const QString &value) } ui->plainTextEditFormula->setPlainText(formulaLength); - VisToolEndLine *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->setLength(formulaLength); @@ -291,7 +290,7 @@ void DialogEndLine::SetAngle(const QString &value) } ui->plainTextEditAngle->setPlainText(formulaAngle); - VisToolEndLine *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->SetAngle(formulaAngle); @@ -307,13 +306,13 @@ void DialogEndLine::SetBasePointId(const quint32 &value) { setCurrentPointId(ui->comboBoxBasePoint, value); - VisToolEndLine *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogEndLine::GetLineColor() const +auto DialogEndLine::GetLineColor() const -> QString { return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack); } @@ -344,8 +343,7 @@ void DialogEndLine::ShowDialog(bool click) } /*We will ignore click if pointer is in point circle*/ - VMainGraphicsScene *scene = - qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); + auto *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(static_cast(*point), scene->getScenePos()); @@ -358,7 +356,7 @@ void DialogEndLine::ShowDialog(bool click) } this->setModal(true); - VisToolEndLine *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) this->SetAngle(line->Angle());//Show in dialog angle what user choose diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp index 03319be48..2f1cfb063 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.cpp +++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp @@ -327,18 +327,16 @@ void DialogMove::ShowDialog(bool click) stage1 = false; prepare = true; - VMainGraphicsScene *scene = - qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); + auto *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->clearSelection(); - VisToolMove *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) operation->SetObjects(SourceToObjects(sourceObjects)); operation->VisualMode(); - VAbstractMainWindow *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(operation, &VisToolMove::ToolTip, window, &VAbstractMainWindow::ShowToolTip); @@ -358,7 +356,7 @@ void DialogMove::ShowDialog(bool click) } else if (not stage2 && not stage1 && prepare && click) { - VisToolMove *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) if (operation->LengthValue() > 0) @@ -376,7 +374,7 @@ void DialogMove::ShowDialog(bool click) } else if (not stage1 && stage2 && prepare && click) { - VisToolMove *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) @@ -415,7 +413,7 @@ void DialogMove::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxRotationOriginPoint, QString())) { - VisToolMove *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) operation->SetRotationOriginPointId(id); @@ -432,8 +430,8 @@ void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool) Q_UNUSED(tool) if (stage1) { - auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), - [object](const SourceItem &sItem) { return sItem.id == object; }); + auto *obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [object](const SourceItem &sItem) { return sItem.id == object; }); if (selected) { if (obj == sourceObjects.cend()) @@ -445,7 +443,7 @@ void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool) } else { - if (obj != sourceObjects.end()) + if (obj != sourceObjects.cend()) { sourceObjects.erase(obj); } diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index 647b466e5..fa9106e75 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -161,7 +161,7 @@ void DialogRotation::SetAngle(const QString &value) } ui->plainTextEditFormula->setPlainText(formulaAngle); - VisToolRotation *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) operation->SetAngle(formulaAngle); @@ -236,12 +236,11 @@ void DialogRotation::ShowDialog(bool click) stage1 = false; - VMainGraphicsScene *scene = - qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); + auto *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->clearSelection(); - VisToolRotation *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) operation->SetObjects(SourceToObjects(sourceObjects)); operation->VisualMode(); @@ -273,8 +272,7 @@ void DialogRotation::ShowDialog(bool click) } /*We will ignore click if pointer is in point circle*/ - VMainGraphicsScene *scene = - qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); + auto *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) try { @@ -292,7 +290,7 @@ void DialogRotation::ShowDialog(bool click) return; } - VisToolRotation *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) SetAngle(operation->Angle());//Show in dialog angle that a user choose @@ -315,7 +313,7 @@ void DialogRotation::SetSourceObjects(const QVector &value) sourceObjects = value; FillSourceList(); - VisToolRotation *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) operation->SetObjects(SourceToObjects(sourceObjects)); } @@ -327,13 +325,13 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { - VisToolRotation *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) - auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), - [id](const SourceItem &sItem) { return sItem.id == id; }); + auto *obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [id](const SourceItem &sItem) { return sItem.id == id; }); - if (obj != sourceObjects.end()) + if (obj != sourceObjects.cend()) { if (sourceObjects.size() > 1) { @@ -351,8 +349,7 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxOriginPoint, QString())) { - VAbstractMainWindow *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(operation, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); @@ -371,8 +368,8 @@ void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool) Q_UNUSED(tool) if (stage1) { - auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), - [object](const SourceItem &sItem) { return sItem.id == object; }); + auto *obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [object](const SourceItem &sItem) { return sItem.id == object; }); if (selected) { if (obj == sourceObjects.cend()) @@ -384,7 +381,7 @@ void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool) } else { - if (obj != sourceObjects.end()) + if (obj != sourceObjects.cend()) { sourceObjects.erase(obj); } @@ -401,7 +398,7 @@ void DialogRotation::DeployAngleTextEdit() //--------------------------------------------------------------------------------------------------------------------- void DialogRotation::FXAngle() { - DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); + auto *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit angle")); dialog->SetFormula(GetAngle()); dialog->setPostfix(degreeSymbol); @@ -415,7 +412,7 @@ void DialogRotation::FXAngle() //--------------------------------------------------------------------------------------------------------------------- void DialogRotation::SuffixChanged() { - QLineEdit* edit = qobject_cast(sender()); + auto* edit = qobject_cast(sender()); if (edit) { const QString suffix = edit->text(); @@ -433,7 +430,7 @@ void DialogRotation::SuffixChanged() { QRegularExpression rx(NameRegExp()); const QStringList uniqueNames = data->AllUniqueNames(); - for (auto &uniqueName : uniqueNames) + for (const auto &uniqueName : uniqueNames) { const QString name = uniqueName + suffix; if (not rx.match(name).hasMatch() || not data->IsUnique(name)) @@ -457,7 +454,7 @@ void DialogRotation::SuffixChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogRotation::GroupNameChanged() { - QLineEdit* edit = qobject_cast(sender()); + auto* edit = qobject_cast(sender()); if (edit) { const QString name = edit->text(); @@ -500,7 +497,7 @@ void DialogRotation::SaveData() } } - VisToolRotation *operation = qobject_cast(vis); + auto *operation = qobject_cast(vis); SCASSERT(operation != nullptr) operation->SetObjects(SourceToObjects(sourceObjects)); @@ -533,11 +530,11 @@ void DialogRotation::PointChanged() { quint32 id = getCurrentObjectId(ui->comboBoxOriginPoint); - auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), - [id](const SourceItem &sItem) { return sItem.id == id; }); + auto *obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [id](const SourceItem &sItem) { return sItem.id == id; }); QColor color; - if (obj != sourceObjects.end()) + if (obj != sourceObjects.cend()) { flagError = false; color = errorColor; @@ -601,10 +598,8 @@ void DialogRotation::ValidateSourceAliases() CheckState(); return; } - else - { - SetAliasValid(sourceItem.id, true); - } + + SetAliasValid(sourceItem.id, true); } } diff --git a/src/libs/vtools/visualization/line/vistoolendline.cpp b/src/libs/vtools/visualization/line/vistoolendline.cpp index 476e028ec..e002c2379 100644 --- a/src/libs/vtools/visualization/line/vistoolendline.cpp +++ b/src/libs/vtools/visualization/line/vistoolendline.cpp @@ -99,7 +99,7 @@ void VisToolEndLine::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- QString VisToolEndLine::Angle() const { - return QString("%1").arg(this->line().angle()); + return QString::number(this->line().angle()); } //---------------------------------------------------------------------------------------------------------------------