diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index 2937511d1..b6bff4738 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -408,15 +408,8 @@ auto VPPiece::PathsSuperposition(const QVector &path1, const QVector bool CastTo(piece->GetMappedExternalContourPoints(), piecePath); QRectF const pieceBoundingRect = VLayoutPiece::BoundingRect(piecePath); - if (stickyZone.intersects(pieceBoundingRect) || pieceBoundingRect.contains(stickyZone) || - stickyZone.contains(pieceBoundingRect)) + if ((stickyZone.intersects(pieceBoundingRect) || pieceBoundingRect.contains(stickyZone) || + stickyZone.contains(pieceBoundingRect)) && + not VPPiece::PathsSuperposition(path, piecePath)) { - if (not VPPiece::PathsSuperposition(path, piecePath)) + + QVector const pieceStickyPath = PrepareStickyPath(piecePath); + if (QLineF const distance = ClosestDistance(stickyPath, pieceStickyPath); + match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length()) { - QVector const pieceStickyPath = PrepareStickyPath(piecePath); - if (QLineF const distance = ClosestDistance(stickyPath, pieceStickyPath); - match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length()) - { - match.m_closestDistance = distance; - match.m_pieceGap = pieceGap; - } + match.m_closestDistance = distance; + match.m_pieceGap = pieceGap; } } } diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index 3542b0b6d..7c92bfca7 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -255,16 +255,13 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (VPPiecePtr const piece = m_piece.toStrongRef(); not piece.isNull()) { - if (VPLayoutPtr const layout = piece->Layout(); not layout.isNull()) + if (VPLayoutPtr const layout = piece->Layout(); + not layout.isNull() && (layout->LayoutSettings().IsStickyEdges() && m_hasStickyPosition)) { - if (layout->LayoutSettings().IsStickyEdges() && m_hasStickyPosition) - { - auto *command = - new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge); - layout->UndoStack()->push(command); + auto *command = new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge); + layout->UndoStack()->push(command); - SetStickyPoints(QVector()); - } + SetStickyPoints(QVector()); } } @@ -1184,20 +1181,17 @@ void VPGraphicsPiece::PieceZValueChanged(const VPPiecePtr &piece) //--------------------------------------------------------------------------------------------------------------------- auto VPGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &value) -> QVariant { - if (scene() != nullptr) + if (scene() != nullptr && change == ItemSelectedHasChanged) { - if (change == ItemSelectedHasChanged) + VPPiecePtr const piece = m_piece.toStrongRef(); + if (not piece.isNull()) { - VPPiecePtr const piece = m_piece.toStrongRef(); - if (not piece.isNull()) - { - piece->SetSelected(value.toBool()); + piece->SetSelected(value.toBool()); - VPLayoutPtr const layout = piece->Layout(); - if (not layout.isNull()) - { - emit layout->PieceSelectionChanged(piece); - } + VPLayoutPtr const layout = piece->Layout(); + if (not layout.isNull()) + { + emit layout->PieceSelectionChanged(piece); } } } diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index 6f5b76526..df98c1179 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -305,22 +305,19 @@ void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event) break; } - if (event->key() == Qt::Key_BracketLeft || event->key() == Qt::Key_BracketRight) + if ((event->key() == Qt::Key_BracketLeft || event->key() == Qt::Key_BracketRight) && not event->isAutoRepeat()) { - if (not event->isAutoRepeat()) + VPLayoutPtr const layout = m_layout.toStrongRef(); + if (layout.isNull()) { - VPLayoutPtr const layout = m_layout.toStrongRef(); - if (layout.isNull()) - { - return; - } + return; + } - if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull()) - { - sheet->SceneData()->RotationControls()->SetIgnorePieceTransformation(false); - sheet->SceneData()->RotationControls()->on_UpdateControls(); - sheet->SceneData()->RotationControls()->on_HideHandles(false); - } + if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull()) + { + sheet->SceneData()->RotationControls()->SetIgnorePieceTransformation(false); + sheet->SceneData()->RotationControls()->on_UpdateControls(); + sheet->SceneData()->RotationControls()->on_HideHandles(false); } } VMainGraphicsView::keyReleaseEvent(event); @@ -690,32 +687,29 @@ void VPMainGraphicsView::MovePiece(QKeyEvent *event) } if (const QList &graphicsPieces = sheet->SceneData()->GraphicsPieces(); - m_hasStickyPosition && not graphicsPieces.isEmpty()) + m_hasStickyPosition && not graphicsPieces.isEmpty() && layout->LayoutSettings().IsStickyEdges()) { - if (layout->LayoutSettings().IsStickyEdges()) + auto PreparePieces = [layout]() { - auto PreparePieces = [layout]() + QList pieces; + if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull()) { - QList pieces; - if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull()) - { - pieces = sheet->GetSelectedPieces(); - } + pieces = sheet->GetSelectedPieces(); + } - return pieces; - }; + return pieces; + }; - if (QList const pieces = PreparePieces(); pieces.size() == 1) + if (QList const pieces = PreparePieces(); pieces.size() == 1) + { + const VPPiecePtr &p = pieces.constFirst(); + + auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge); + layout->UndoStack()->push(command); + + if (VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p); gPiece != nullptr) { - const VPPiecePtr &p = pieces.constFirst(); - - auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge); - layout->UndoStack()->push(command); - - if (VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p); gPiece != nullptr) - { - gPiece->SetStickyPoints(QVector()); - } + gPiece->SetStickyPoints(QVector()); } } } diff --git a/src/app/puzzle/undocommands/vpundopiecemove.cpp b/src/app/puzzle/undocommands/vpundopiecemove.cpp index 187beba4c..b08a7416f 100644 --- a/src/app/puzzle/undocommands/vpundopiecemove.cpp +++ b/src/app/puzzle/undocommands/vpundopiecemove.cpp @@ -163,13 +163,10 @@ void VPUndoPiecesMove::undo() for (const auto &piece : qAsConst(m_pieces)) { VPPiecePtr const p = piece.toStrongRef(); - if (not p.isNull()) + if (not p.isNull() && m_oldTransforms.contains(p->GetUniqueID())) { - if (m_oldTransforms.contains(p->GetUniqueID())) - { - p->SetMatrix(m_oldTransforms.value(p->GetUniqueID())); - emit layout->PieceTransformationChanged(p); - } + p->SetMatrix(m_oldTransforms.value(p->GetUniqueID())); + emit layout->PieceTransformationChanged(p); } } } diff --git a/src/app/puzzle/undocommands/vpundopiecerotate.cpp b/src/app/puzzle/undocommands/vpundopiecerotate.cpp index 215e78fd8..c28cf87b5 100644 --- a/src/app/puzzle/undocommands/vpundopiecerotate.cpp +++ b/src/app/puzzle/undocommands/vpundopiecerotate.cpp @@ -202,17 +202,14 @@ void VPUndoPiecesRotate::undo() for (const auto &piece : qAsConst(m_pieces)) { VPPiecePtr const p = piece.toStrongRef(); - if (not p.isNull()) + if (not p.isNull() && m_oldTransforms.contains(p->GetUniqueID())) { - if (m_oldTransforms.contains(p->GetUniqueID())) + p->SetMatrix(m_oldTransforms.value(p->GetUniqueID())); + if (m_followGrainline || p->IsFollowGrainline()) { - p->SetMatrix(m_oldTransforms.value(p->GetUniqueID())); - if (m_followGrainline || p->IsFollowGrainline()) - { - p->RotateToGrainline(m_origin); - } - emit layout->PieceTransformationChanged(p); + p->RotateToGrainline(m_origin); } + emit layout->PieceTransformationChanged(p); } } } diff --git a/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp b/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp index e58077350..2b7234cdc 100644 --- a/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp +++ b/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp @@ -109,13 +109,10 @@ void VPUndoPieceZValueMove::undo() for (const auto &p : pieces) { - if (not p.isNull()) + if (not p.isNull() && m_oldValues.contains(p->GetUniqueID())) { - if (m_oldValues.contains(p->GetUniqueID())) - { - p->SetZValue(m_oldValues.value(p->GetUniqueID())); - emit layout->PieceZValueChanged(p); - } + p->SetZValue(m_oldValues.value(p->GetUniqueID())); + emit layout->PieceZValueChanged(p); } } } @@ -326,13 +323,10 @@ void VPUndoPiecesZValueMove::undo() for (const auto &p : pieces) { - if (not p.isNull()) + if (not p.isNull() && m_oldValues.contains(p->GetUniqueID())) { - if (m_oldValues.contains(p->GetUniqueID())) - { - p->SetZValue(m_oldValues.value(p->GetUniqueID())); - emit layout->PieceZValueChanged(p); - } + p->SetZValue(m_oldValues.value(p->GetUniqueID())); + emit layout->PieceZValueChanged(p); } } } diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index 618f8d1cf..9d4aad45b 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -239,25 +239,20 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con break; } - if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) + if ((type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) && + VPApplication::VApp()->IsAppInGUIMode() && topWinAllowsPop) { - if (VPApplication::VApp()->IsAppInGUIMode()) - { - if (topWinAllowsPop) - { - messageBox.setText(msg); - messageBox.setStandardButtons(QMessageBox::Ok); - messageBox.setWindowModality(Qt::ApplicationModal); - messageBox.setModal(true); + messageBox.setText(msg); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.setWindowModality(Qt::ApplicationModal); + messageBox.setModal(true); #ifndef QT_NO_CURSOR - QGuiApplication::setOverrideCursor(Qt::ArrowCursor); + QGuiApplication::setOverrideCursor(Qt::ArrowCursor); #endif - messageBox.exec(); + messageBox.exec(); #ifndef QT_NO_CURSOR - QGuiApplication::restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); #endif - } - } } if (QtFatalMsg == type) diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index c2f465d0d..7dcf5aef1 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -216,12 +216,10 @@ void SetPrinterSheetPageSettings(const QSharedPointer &printer, const printer->setPageOrientation(sheetOrientation); printer->setFullPage(sheet->IgnoreMargins()); - if (not sheet->IgnoreMargins()) + if (not sheet->IgnoreMargins() && + not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter)) { - if (not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter)) - { - qWarning() << QObject::tr("Cannot set printer margins"); - } + qWarning() << QObject::tr("Cannot set printer margins"); } } @@ -266,12 +264,10 @@ void SetPrinterTiledPageSettings(const QSharedPointer &printer, const printer->setPageOrientation(orientation); printer->setFullPage(layout->LayoutSettings().IgnoreTilesMargins()); - if (not layout->LayoutSettings().IgnoreTilesMargins()) + if (not layout->LayoutSettings().IgnoreTilesMargins() && + not printer->setPageMargins(layout->LayoutSettings().GetTilesMargins(Unit::Mm), QPageLayout::Millimeter)) { - if (not printer->setPageMargins(layout->LayoutSettings().GetTilesMargins(Unit::Mm), QPageLayout::Millimeter)) - { - qWarning() << QObject::tr("Cannot set printer margins"); - } + qWarning() << QObject::tr("Cannot set printer margins"); } } @@ -488,12 +484,9 @@ auto VPMainWindow::LoadFile(const QString &path) -> bool VlpCreateLock(lock, path); - if (not lock->IsLocked()) + if (not lock->IsLocked() && not IgnoreLocking(lock->GetLockError(), path, m_cmd->IsGuiEnabled())) { - if (not IgnoreLocking(lock->GetLockError(), path, m_cmd->IsGuiEnabled())) - { - return false; - } + return false; } try @@ -803,14 +796,11 @@ void VPMainWindow::ShowFullPieceToggled(bool checked) if (selectedPieces.size() == 1) { const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); - if (not selectedPiece.isNull()) + if (not selectedPiece.isNull() && selectedPiece->IsShowFullPiece() != checked) { - if (selectedPiece->IsShowFullPiece() != checked) - { - selectedPiece->SetShowFullPiece(checked); - LayoutWasSaved(false); - emit m_layout->PieceTransformationChanged(selectedPiece); - } + selectedPiece->SetShowFullPiece(checked); + LayoutWasSaved(false); + emit m_layout->PieceTransformationChanged(selectedPiece); } } } @@ -822,14 +812,11 @@ void VPMainWindow::ShowMirrorLineToggled(bool checked) if (selectedPieces.size() == 1) { const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); - if (not selectedPiece.isNull()) + if (not selectedPiece.isNull() && selectedPiece->IsShowMirrorLine() != checked) { - if (selectedPiece->IsShowMirrorLine() != checked) - { - selectedPiece->SetShowMirrorLine(checked); - LayoutWasSaved(false); - emit m_layout->PieceTransformationChanged(selectedPiece); - } + selectedPiece->SetShowMirrorLine(checked); + LayoutWasSaved(false); + emit m_layout->PieceTransformationChanged(selectedPiece); } } } @@ -841,14 +828,11 @@ void VPMainWindow::CurrentPieceVerticallyFlippedToggled(bool checked) if (selectedPieces.size() == 1) { const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); - if (not selectedPiece.isNull()) + if (not selectedPiece.isNull() && selectedPiece->IsVerticallyFlipped() != checked) { - if (selectedPiece->IsVerticallyFlipped() != checked) - { - selectedPiece->FlipVertically(); - LayoutWasSaved(false); - emit m_layout->PieceTransformationChanged(selectedPiece); - } + selectedPiece->FlipVertically(); + LayoutWasSaved(false); + emit m_layout->PieceTransformationChanged(selectedPiece); } } } @@ -860,14 +844,11 @@ void VPMainWindow::CurrentPieceHorizontallyFlippedToggled(bool checked) if (selectedPieces.size() == 1) { const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); - if (not selectedPiece.isNull()) + if (not selectedPiece.isNull() && selectedPiece->IsHorizontallyFlipped() != checked) { - if (selectedPiece->IsHorizontallyFlipped() != checked) - { - selectedPiece->FlipHorizontally(); - LayoutWasSaved(false); - emit m_layout->PieceTransformationChanged(selectedPiece); - } + selectedPiece->FlipHorizontally(); + LayoutWasSaved(false); + emit m_layout->PieceTransformationChanged(selectedPiece); } } } @@ -3004,28 +2985,26 @@ auto VPMainWindow::AskLayoutIsInvalid(const QList &sheets) -> bool //--------------------------------------------------------------------------------------------------------------------- auto VPMainWindow::CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBoundChecked) -> bool { - if (m_layout->LayoutSettings().GetWarningPiecesOutOfBound()) + if (m_layout->LayoutSettings().GetWarningPiecesOutOfBound() && not outOfBoundChecked && not piece.isNull() && + piece->OutOfBound()) { - if (not outOfBoundChecked && not piece.isNull() && piece->OutOfBound()) + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setWindowTitle(tr("The layout is invalid.")); + msgBox.setText(tr("The layout is invalid. Piece out of bound. Do you want to continue export?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + const int width = 500; + auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto *layout = qobject_cast(msgBox.layout()); + SCASSERT(layout != nullptr) + layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); + if (msgBox.exec() == QMessageBox::No) { - QMessageBox msgBox(this); - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(tr("The layout is invalid.")); - msgBox.setText(tr("The layout is invalid. Piece out of bound. Do you want to continue export?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - const int width = 500; - auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - auto *layout = qobject_cast(msgBox.layout()); - SCASSERT(layout != nullptr) - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - if (msgBox.exec() == QMessageBox::No) - { - return false; - } - - outOfBoundChecked = true; // no need to ask more + return false; } + + outOfBoundChecked = true; // no need to ask more } return true; } @@ -3033,29 +3012,27 @@ auto VPMainWindow::CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBou //--------------------------------------------------------------------------------------------------------------------- auto VPMainWindow::CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pieceSuperpositionChecked) -> bool { - if (m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()) + if (m_layout->LayoutSettings().GetWarningSuperpositionOfPieces() && not pieceSuperpositionChecked && + not piece.isNull() && piece->HasSuperpositionWithPieces()) { - if (not pieceSuperpositionChecked && not piece.isNull() && piece->HasSuperpositionWithPieces()) + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setWindowTitle(tr("The layout is invalid.")); + msgBox.setText(tr("The layout is invalid. Pieces superposition. Do you want to continue " + "export?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + const int width = 500; + auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto *layout = qobject_cast(msgBox.layout()); + SCASSERT(layout != nullptr) + layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); + if (msgBox.exec() == QMessageBox::No) { - QMessageBox msgBox(this); - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(tr("The layout is invalid.")); - msgBox.setText(tr("The layout is invalid. Pieces superposition. Do you want to continue " - "export?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - const int width = 500; - auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - auto *layout = qobject_cast(msgBox.layout()); - SCASSERT(layout != nullptr) - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - if (msgBox.exec() == QMessageBox::No) - { - return false; - } - - pieceSuperpositionChecked = true; // no need to ask more + return false; } + + pieceSuperpositionChecked = true; // no need to ask more } return true; @@ -3064,29 +3041,27 @@ auto VPMainWindow::CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pie //--------------------------------------------------------------------------------------------------------------------- auto VPMainWindow::CheckPieceGapePosition(const VPPiecePtr &piece, bool &pieceGapePositionChecked) -> bool { - if (m_layout->LayoutSettings().GetWarningPieceGapePosition()) + if (m_layout->LayoutSettings().GetWarningPieceGapePosition() && not pieceGapePositionChecked && + not piece.isNull() && piece->HasInvalidPieceGapPosition()) { - if (not pieceGapePositionChecked && not piece.isNull() && piece->HasInvalidPieceGapPosition()) + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setWindowTitle(tr("The layout is invalid.")); + msgBox.setText(tr("The layout is invalid. One or several pieces are closer than minimally allowed. Do you " + "want to continue export?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + const int width = 500; + auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto *layout = qobject_cast(msgBox.layout()); + SCASSERT(layout != nullptr) + layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); + if (msgBox.exec() == QMessageBox::No) { - QMessageBox msgBox(this); - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(tr("The layout is invalid.")); - msgBox.setText(tr("The layout is invalid. One or several pieces are closer than minimally allowed. Do you " - "want to continue export?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - const int width = 500; - auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - auto *layout = qobject_cast(msgBox.layout()); - SCASSERT(layout != nullptr) - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - if (msgBox.exec() == QMessageBox::No) - { - return false; - } - - pieceGapePositionChecked = true; // no need to ask more + return false; } + + pieceGapePositionChecked = true; // no need to ask more } return true; @@ -3166,8 +3141,8 @@ auto VPMainWindow::PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, co if (not sheet->IgnoreMargins()) { - QMarginsF const margins = sheet->GetSheetMargins(); - if (not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter)) + if (QMarginsF const margins = sheet->GetSheetMargins(); + not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter)) { qWarning() << QObject::tr("Cannot set printer margins"); } diff --git a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp index 832815e0a..d0964315a 100644 --- a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp +++ b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp @@ -367,31 +367,22 @@ auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool if (m_type == MeasurementsType::Multisize) { - if (not m_dimensions.empty()) + if (not m_dimensions.empty() && not ColumnValid(MultisizeMeasurementsColumns::ShiftA)) { - if (not ColumnValid(MultisizeMeasurementsColumns::ShiftA)) - { - ChangeColor(ui->labelShiftA, errorColor); - columnShiftAFlag = false; - } + ChangeColor(ui->labelShiftA, errorColor); + columnShiftAFlag = false; } - if (m_dimensions.size() > 1) + if (m_dimensions.size() > 1 && not ColumnValid(MultisizeMeasurementsColumns::ShiftB)) { - if (not ColumnValid(MultisizeMeasurementsColumns::ShiftB)) - { - ChangeColor(ui->labelShiftB, errorColor); - columnShiftBFlag = false; - } + ChangeColor(ui->labelShiftB, errorColor); + columnShiftBFlag = false; } - if (m_dimensions.size() > 2) + if (m_dimensions.size() > 2 && not ColumnValid(MultisizeMeasurementsColumns::ShiftC)) { - if (not ColumnValid(MultisizeMeasurementsColumns::ShiftC)) - { - ChangeColor(ui->labelShiftC, errorColor); - columnShiftCFlag = false; - } + ChangeColor(ui->labelShiftC, errorColor); + columnShiftCFlag = false; } } diff --git a/src/app/tape/dialogs/dialogsetupmultisize.cpp b/src/app/tape/dialogs/dialogsetupmultisize.cpp index 2115c1471..4bad60b5f 100644 --- a/src/app/tape/dialogs/dialogsetupmultisize.cpp +++ b/src/app/tape/dialogs/dialogsetupmultisize.cpp @@ -405,13 +405,10 @@ void DialogSetupMultisize::CheckDimension(QGroupBox *group, QGroupBox *nameGroup return; } - if (nameGroup->isChecked() && lineEdit->text().isEmpty()) + if (nameGroup->isChecked() && lineEdit->text().isEmpty() && ui->labelError->text().isEmpty()) { - if (ui->labelError->text().isEmpty()) - { - ui->labelError->setText(tr("Please, provide custom name for dimension %1").arg(dimension->Axis())); - return; - } + ui->labelError->setText(tr("Please, provide custom name for dimension %1").arg(dimension->Axis())); + return; } } } diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index fc12b1938..1dfa2fa13 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -275,25 +275,20 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con break; } - if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) + if ((type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) && + not MApplication::VApp()->IsTestMode() && topWinAllowsPop) { - if (not MApplication::VApp()->IsTestMode()) - { - if (topWinAllowsPop) - { - messageBox.setText(VAbstractApplication::ClearMessage(logMsg)); - messageBox.setStandardButtons(QMessageBox::Ok); - messageBox.setWindowModality(Qt::ApplicationModal); - messageBox.setModal(true); + messageBox.setText(VAbstractApplication::ClearMessage(logMsg)); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.setWindowModality(Qt::ApplicationModal); + messageBox.setModal(true); #ifndef QT_NO_CURSOR - QGuiApplication::setOverrideCursor(Qt::ArrowCursor); + QGuiApplication::setOverrideCursor(Qt::ArrowCursor); #endif - messageBox.exec(); + messageBox.exec(); #ifndef QT_NO_CURSOR - QGuiApplication::restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); #endif - } - } } if (QtFatalMsg == type) @@ -898,13 +893,10 @@ void MApplication::RepopulateMeasurementsDatabase(const QString &path) //--------------------------------------------------------------------------------------------------------------------- void MApplication::KnownMeasurementsPathChanged(const QString &oldPath, const QString &newPath) { - if (oldPath != newPath) + if (oldPath != newPath && m_knownMeasurementsDatabase != nullptr) { - if (m_knownMeasurementsDatabase != nullptr) - { - RestartKnownMeasurementsDatabaseWatcher(); - RepopulateMeasurementsDatabase(newPath); - } + RestartKnownMeasurementsDatabaseWatcher(); + RepopulateMeasurementsDatabase(newPath); } } diff --git a/src/app/tape/tkmmainwindow.cpp b/src/app/tape/tkmmainwindow.cpp index 1091cb7f2..b9bb11260 100644 --- a/src/app/tape/tkmmainwindow.cpp +++ b/src/app/tape/tkmmainwindow.cpp @@ -196,12 +196,10 @@ auto TKMMainWindow::LoadFile(const QString &path) -> bool VlpCreateLock(m_lock, path); - if (not m_lock->IsLocked()) + if (not m_lock->IsLocked() && + not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) { - if (not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) - { - return false; - } + return false; } try diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index ca802d0db..3bfa5f603 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -433,12 +433,10 @@ auto TMainWindow::LoadFile(const QString &path) -> bool VlpCreateLock(m_lock, path); - if (not m_lock->IsLocked()) + if (not m_lock->IsLocked() && + not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) { - if (not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) - { - return false; - } + return false; } try @@ -4097,12 +4095,10 @@ auto TMainWindow::LoadFromExistingFile(const QString &path) -> bool VlpCreateLock(m_lock, path); - if (not m_lock->IsLocked()) + if (not m_lock->IsLocked() && + not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) { - if (not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) - { - return false; - } + return false; } try diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index cc2485b5f..2710810a6 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -287,53 +287,50 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con if (isGuiThread) { - if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) + if ((type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) && VApplication::IsGUIMode()) { - if (VApplication::IsGUIMode()) + // fixme: trying to make sure there are no save/load dialogs are opened, because error message during + // them will lead to crash + const bool topWinAllowsPop = (QApplication::activeModalWidget() == nullptr) || + !QApplication::activeModalWidget()->inherits("QFileDialog"); + + if (topWinAllowsPop && (not isPatternMessage || (type == QtCriticalMsg || type == QtFatalMsg))) { - // fixme: trying to make sure there are no save/load dialogs are opened, because error message during - // them will lead to crash - const bool topWinAllowsPop = (QApplication::activeModalWidget() == nullptr) || - !QApplication::activeModalWidget()->inherits("QFileDialog"); - - if (topWinAllowsPop && (not isPatternMessage || (type == QtCriticalMsg || type == QtFatalMsg))) + QMessageBox messageBox; + switch (type) { - QMessageBox messageBox; - switch (type) - { - case QtWarningMsg: - messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Warning")); - messageBox.setIcon(QMessageBox::Warning); - break; - case QtCriticalMsg: - messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Critical error")); - messageBox.setIcon(QMessageBox::Critical); - break; - case QtFatalMsg: - messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Fatal error")); - messageBox.setIcon(QMessageBox::Critical); - break; - case QtInfoMsg: - messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Information")); - messageBox.setIcon(QMessageBox::Information); - break; - case QtDebugMsg: - default: - break; - } - - messageBox.setText(VAbstractValApplication::ClearMessage(logMsg)); - messageBox.setStandardButtons(QMessageBox::Ok); - messageBox.setWindowModality(Qt::ApplicationModal); - messageBox.setModal(true); -#ifndef QT_NO_CURSOR - QGuiApplication::setOverrideCursor(Qt::ArrowCursor); -#endif - messageBox.exec(); -#ifndef QT_NO_CURSOR - QGuiApplication::restoreOverrideCursor(); -#endif + case QtWarningMsg: + messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Warning")); + messageBox.setIcon(QMessageBox::Warning); + break; + case QtCriticalMsg: + messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Critical error")); + messageBox.setIcon(QMessageBox::Critical); + break; + case QtFatalMsg: + messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Fatal error")); + messageBox.setIcon(QMessageBox::Critical); + break; + case QtInfoMsg: + messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Information")); + messageBox.setIcon(QMessageBox::Information); + break; + case QtDebugMsg: + default: + break; } + + messageBox.setText(VAbstractValApplication::ClearMessage(logMsg)); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.setWindowModality(Qt::ApplicationModal); + messageBox.setModal(true); +#ifndef QT_NO_CURSOR + QGuiApplication::setOverrideCursor(Qt::ArrowCursor); +#endif + messageBox.exec(); +#ifndef QT_NO_CURSOR + QGuiApplication::restoreOverrideCursor(); +#endif } } @@ -783,13 +780,10 @@ void VApplication::RepopulateMeasurementsDatabase(const QString &path) //--------------------------------------------------------------------------------------------------------------------- void VApplication::KnownMeasurementsPathChanged(const QString &oldPath, const QString &newPath) { - if (oldPath != newPath) + if (oldPath != newPath && m_knownMeasurementsDatabase != nullptr) { - if (m_knownMeasurementsDatabase != nullptr) - { - RestartKnownMeasurementsDatabaseWatcher(); - RepopulateMeasurementsDatabase(newPath); - } + RestartKnownMeasurementsDatabaseWatcher(); + RepopulateMeasurementsDatabase(newPath); } } diff --git a/src/app/valentina/core/vcmdexport.cpp b/src/app/valentina/core/vcmdexport.cpp index dee1f850e..868554a14 100644 --- a/src/app/valentina/core/vcmdexport.cpp +++ b/src/app/valentina/core/vcmdexport.cpp @@ -139,13 +139,10 @@ auto VCommandLine::DefaultGenerator() const -> VLayoutGeneratorPtr } } - if (IsOptionSet(LONG_OPTION_SHIFTUNITS)) + if (IsOptionSet(LONG_OPTION_SHIFTUNITS) && !diag.SelectLayoutUnit(OptionValue(LONG_OPTION_SHIFTUNITS))) { - if (!diag.SelectLayoutUnit(OptionValue(LONG_OPTION_SHIFTUNITS))) - { - qCritical() << translate("VCommandLine", "Unsupported layout units.") << "\n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); - } + qCritical() << translate("VCommandLine", "Unsupported layout units.") << "\n"; + const_cast(this)->parser.showHelp(V_EX_USAGE); } if (IsOptionSet(LONG_OPTION_GAPWIDTH)) diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index a1a6be289..ca6b1ca72 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -554,12 +554,9 @@ auto VToolOptionsPropertyBrowser::ComboBoxPalette() const -> QPalette //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) { - if (item != nullptr) + if (item != nullptr && not item->isEnabled()) { - if (not item->isEnabled()) - { - return; - } + return; } if (m_currentItem == item && item != nullptr) diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index db51161a6..8f4f169d3 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -192,14 +192,11 @@ void VWidgetDetails::ToggleSectionDetails(bool select) for (int i = 0; i < ui->tableWidget->rowCount(); ++i) { const quint32 id = ui->tableWidget->item(i, PieceColumn::InLayout)->data(Qt::UserRole).toUInt(); - if (allDetails->contains(id)) + if (allDetails->contains(id) && not(select == allDetails->value(id).IsInLayout())) { - if (not(select == allDetails->value(id).IsInLayout())) - { - auto *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); - connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); - VAbstractApplication::VApp()->getUndoStack()->push(togglePrint); - } + auto *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); + connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); + VAbstractApplication::VApp()->getUndoStack()->push(togglePrint); } } } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index f7ea0956b..06d88c3b9 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -358,12 +358,9 @@ MainWindow::MainWindow(QWidget *parent) connect(doc, &VPattern::CheckLayout, this, [this]() { - if (pattern->DataPieces()->isEmpty()) + if (pattern->DataPieces()->isEmpty() && not ui->actionDraw->isChecked()) { - if (not ui->actionDraw->isChecked()) - { - ActionDraw(true); - } + ActionDraw(true); } }); connect(doc, &VPattern::SetCurrentPP, this, &MainWindow::GlobalChangePP); @@ -2334,28 +2331,19 @@ void MainWindow::StoreMultisizeMDimensions() QList const dimensions = m_m->Dimensions().values(); - if (not dimensions.isEmpty()) + if (not dimensions.isEmpty() && not m_dimensionALabel.isNull()) { - if (not m_dimensionALabel.isNull()) - { - m_dimensionALabel->setText(dimensions.at(0)->Name() + ':'_L1); - } + m_dimensionALabel->setText(dimensions.at(0)->Name() + ':'_L1); } - if (dimensions.size() > 1) + if (dimensions.size() > 1 && not m_dimensionBLabel.isNull()) { - if (not m_dimensionBLabel.isNull()) - { - m_dimensionBLabel->setText(dimensions.at(1)->Name() + ':'_L1); - } + m_dimensionBLabel->setText(dimensions.at(1)->Name() + ':'_L1); } - if (dimensions.size() > 2) + if (dimensions.size() > 2 && not m_dimensionCLabel.isNull()) { - if (not m_dimensionCLabel.isNull()) - { - m_dimensionCLabel->setText(dimensions.at(2)->Name() + ':'_L1); - } + m_dimensionCLabel->setText(dimensions.at(2)->Name() + ':'_L1); } StoreMultisizeMDimension(dimensions, 0, m_currentDimensionA); @@ -3909,17 +3897,14 @@ void MainWindow::ActionDetails(bool checked) ui->actionDetails->setChecked(true); ui->actionLayout->setChecked(false); - if (not VAbstractValApplication::VApp()->getOpeningPattern()) + if (not VAbstractValApplication::VApp()->getOpeningPattern() && pattern->DataPieces()->isEmpty()) { - if (pattern->DataPieces()->isEmpty()) - { - QMessageBox::information(this, tr("Detail mode"), - tr("You can't use Detail mode yet. " - "Please, create at least one workpiece."), - QMessageBox::Ok, QMessageBox::Ok); - ActionDraw(true); - return; - } + QMessageBox::information(this, tr("Detail mode"), + tr("You can't use Detail mode yet. " + "Please, create at least one workpiece."), + QMessageBox::Ok, QMessageBox::Ok); + ActionDraw(true); + return; } m_detailsWidget->UpdateList(); @@ -6782,12 +6767,9 @@ void MainWindow::ExportLayoutAs(bool checked) auto Uncheck = qScopeGuard([this] { ui->actionLayoutExportAs->setChecked(false); }); - if (m_layoutSettings->IsLayoutStale()) + if (m_layoutSettings->IsLayoutStale() && VPrintLayout::ContinueIfLayoutStale(this) == QMessageBox::No) { - if (VPrintLayout::ContinueIfLayoutStale(this) == QMessageBox::No) - { - return; - } + return; } try diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 3d71b40cc..689c361e3 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -400,12 +400,10 @@ auto MainWindowsNoGUI::GenerateLayout(VLayoutGenerator &lGenerator) -> bool } if (nestingState == LayoutErrors::NoError && not qFuzzyIsNull(lGenerator.GetEfficiencyCoefficient()) && - efficiency >= lGenerator.GetEfficiencyCoefficient()) + efficiency >= lGenerator.GetEfficiencyCoefficient() && + (not lGenerator.IsPreferOneSheetSolution() || lGenerator.PapersCount() == 1)) { - if (not lGenerator.IsPreferOneSheetSolution() || lGenerator.PapersCount() == 1) - { - break; - } + break; } if (IsTimeout()) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index c6c13394f..6ea80499e 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -446,13 +446,10 @@ auto VPattern::SPointActiveDraw() -> quint32 if (not domNode.isNull() && domNode.isElement()) { const QDomElement domElement = domNode.toElement(); - if (not domElement.isNull()) + if (not domElement.isNull() && domElement.tagName() == TagPoint && + domElement.attribute(AttrType, QString()) == VToolBasePoint::ToolType) { - if (domElement.tagName() == TagPoint && - domElement.attribute(AttrType, QString()) == VToolBasePoint::ToolType) - { - return GetParametrId(domElement); - } + return GetParametrId(domElement); } } } @@ -1332,12 +1329,9 @@ void VPattern::ParseDetails(const QDomElement &domElement, const Document &parse if (domNode.isElement()) { QDomElement domElement = domNode.toElement(); - if (domElement.isNull() == false) + if (domElement.isNull() == false && domElement.tagName() == TagDetail) { - if (domElement.tagName() == TagDetail) - { - ParseDetailElement(domElement, parse); - } + ParseDetailElement(domElement, parse); } } domNode = domNode.nextSibling(); @@ -2903,25 +2897,22 @@ void VPattern::ParseOldToolSplinePath(VMainGraphicsScene *scene, QDomElement &do for (qint32 i = 0; i < num; ++i) { const QDomElement element = nodeList.at(i).toElement(); - if (element.isNull() == false) + if (element.isNull() == false && element.tagName() == AttrPathPoint) { - if (element.tagName() == AttrPathPoint) + const qreal kAsm1 = GetParametrDouble(element, AttrKAsm1, QStringLiteral("1.0")); + const qreal angle = GetParametrDouble(element, AttrAngle, QChar('0')); + const qreal kAsm2 = GetParametrDouble(element, AttrKAsm2, QStringLiteral("1.0")); + const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR); + const VPointF p = *data->GeometricObject(pSpline); + + QLineF line(0, 0, 100, 0); + line.setAngle(angle + 180); + + VFSplinePoint const splPoint(p, kAsm1, line.angle(), kAsm2, angle); + points.append(splPoint); + if (parse == Document::FullParse) { - const qreal kAsm1 = GetParametrDouble(element, AttrKAsm1, QStringLiteral("1.0")); - const qreal angle = GetParametrDouble(element, AttrAngle, QChar('0')); - const qreal kAsm2 = GetParametrDouble(element, AttrKAsm2, QStringLiteral("1.0")); - const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR); - const VPointF p = *data->GeometricObject(pSpline); - - QLineF line(0, 0, 100, 0); - line.setAngle(angle + 180); - - VFSplinePoint const splPoint(p, kAsm1, line.angle(), kAsm2, angle); - points.append(splPoint); - if (parse == Document::FullParse) - { - IncrementReferens(p.getIdTool()); - } + IncrementReferens(p.getIdTool()); } } } @@ -3069,17 +3060,14 @@ void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomEle for (qint32 i = 0; i < num; ++i) { const QDomElement element = nodeList.at(i).toElement(); - if (element.isNull() == false) + if (element.isNull() == false && element.tagName() == AttrPathPoint) { - if (element.tagName() == AttrPathPoint) + const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR); + const VPointF p = *data->GeometricObject(pSpline); + points.append(p); + if (parse == Document::FullParse) { - const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR); - const VPointF p = *data->GeometricObject(pSpline); - points.append(p); - if (parse == Document::FullParse) - { - IncrementReferens(p.getIdTool()); - } + IncrementReferens(p.getIdTool()); } } } @@ -4187,31 +4175,28 @@ void VPattern::ParseIncrementsElement(const QDomNode &node, const Document &pars { if (domNode.isElement()) { - const QDomElement domElement = domNode.toElement(); - if (not domElement.isNull()) + if (const QDomElement domElement = domNode.toElement(); + not domElement.isNull() && domElement.tagName() == TagIncrement) { - if (domElement.tagName() == TagIncrement) - { - const QString name = GetParametrString(domElement, AttrName, QString()).simplified(); - const QString desc = GetParametrEmptyString(domElement, AttrDescription); - const IncrementType type = - StringToIncrementType(GetParametrString(domElement, AttrType, strTypeIncrement)); - const QString formula = (type == IncrementType::Separator) - ? QChar('0') - : GetParametrString(domElement, AttrFormula, QChar('0')); - const bool specialUnits = GetParametrBool(domElement, AttrSpecialUnits, falseStr); + const QString name = GetParametrString(domElement, AttrName, QString()).simplified(); + const QString desc = GetParametrEmptyString(domElement, AttrDescription); + const IncrementType type = + StringToIncrementType(GetParametrString(domElement, AttrType, strTypeIncrement)); + const QString formula = (type == IncrementType::Separator) + ? QChar('0') + : GetParametrString(domElement, AttrFormula, QChar('0')); + const bool specialUnits = GetParametrBool(domElement, AttrSpecialUnits, falseStr); - bool ok = false; - const qreal value = EvalFormula(data, formula, &ok); + bool ok = false; + const qreal value = EvalFormula(data, formula, &ok); - auto *increment = new VIncrement(data, name, type); - increment->SetIndex(static_cast(index++)); - increment->SetFormula(value, formula, ok); - increment->SetDescription(desc); - increment->SetSpecialUnits(specialUnits); - increment->SetPreviewCalculation(node.toElement().tagName() == TagPreviewCalculations); - data->AddUniqueVariable(increment); - } + auto *increment = new VIncrement(data, name, type); + increment->SetIndex(static_cast(index++)); + increment->SetFormula(value, formula, ok); + increment->SetDescription(desc); + increment->SetSpecialUnits(specialUnits); + increment->SetPreviewCalculation(node.toElement().tagName() == TagPreviewCalculations); + data->AddUniqueVariable(increment); } } domNode = domNode.nextSibling(); @@ -4514,13 +4499,10 @@ void VPattern::SetLabelPrefix(const QString &prefix) { QDomElement pattern = documentElement(); - if (not pattern.isNull()) + if (not pattern.isNull() && ConvertToSet(VApplication::LabelLanguages()).contains(prefix)) { - if (ConvertToSet(VApplication::LabelLanguages()).contains(prefix)) - { - SetAttribute(pattern, AttrLabelPrefix, prefix); - modified = true; - } + SetAttribute(pattern, AttrLabelPrefix, prefix); + modified = true; } } diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index 85ff35146..87e81cc6e 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -431,45 +431,40 @@ auto FvUpdater::xmlParseFeed() -> bool const QXmlStreamAttributes attribs = m_xml.attributes(); const auto fervorPlatform = QStringLiteral("fervor:platform"); - if (attribs.hasAttribute(fervorPlatform)) + if (attribs.hasAttribute(fervorPlatform) && + CurrentlyRunningOnPlatform(attribs.value(fervorPlatform).toString().trimmed())) { - if (CurrentlyRunningOnPlatform(attribs.value(fervorPlatform).toString().trimmed())) + xmlEnclosurePlatform = attribs.value(fervorPlatform).toString().trimmed(); + + const auto attributeUrl = QStringLiteral("url"); + if (attribs.hasAttribute(attributeUrl)) { - xmlEnclosurePlatform = attribs.value(fervorPlatform).toString().trimmed(); + xmlEnclosureUrl = attribs.value(attributeUrl).toString().trimmed(); + } + else + { + xmlEnclosureUrl.clear(); + } - const auto attributeUrl = QStringLiteral("url"); - if (attribs.hasAttribute(attributeUrl)) + const auto fervorVersion = QStringLiteral("fervor:version"); + if (attribs.hasAttribute(fervorVersion)) + { + const QString candidateVersion = attribs.value(fervorVersion).toString().trimmed(); + if (not candidateVersion.isEmpty()) { - xmlEnclosureUrl = attribs.value(attributeUrl).toString().trimmed(); - } - else - { - xmlEnclosureUrl.clear(); - } - - const auto fervorVersion = QStringLiteral("fervor:version"); - if (attribs.hasAttribute(fervorVersion)) - { - const QString candidateVersion = attribs.value(fervorVersion).toString().trimmed(); - if (not candidateVersion.isEmpty()) - { - xmlEnclosureVersion = candidateVersion; - } + xmlEnclosureVersion = candidateVersion; } } } } } - else if (m_xml.isEndElement()) + else if (m_xml.isEndElement() && m_xml.name() == "item"_L1) { - if (m_xml.name() == "item"_L1) - { - // That's it - we have analyzed a single and we'll stop - // here (because the topmost is the most recent one, and thus - // the newest version. + // That's it - we have analyzed a single and we'll stop + // here (because the topmost is the most recent one, and thus + // the newest version. - return searchDownloadedFeedForUpdates(xmlEnclosureUrl, xmlEnclosureVersion, xmlEnclosurePlatform); - } + return searchDownloadedFeedForUpdates(xmlEnclosureUrl, xmlEnclosureVersion, xmlEnclosurePlatform); } if (m_xml.error() && m_xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) @@ -555,13 +550,10 @@ auto FvUpdater::VersionIsIgnored(const QString &version) -> bool } const unsigned lastSkippedVersion = VAbstractApplication::VApp()->Settings()->GetLatestSkippedVersion(); - if (lastSkippedVersion != 0x0) + if (lastSkippedVersion != 0x0 && decVersion == lastSkippedVersion) { - if (decVersion == lastSkippedVersion) - { - // Implicitly skipped version - skip - return true; - } + // Implicitly skipped version - skip + return true; } if (decVersion > AppVersion()) @@ -635,13 +627,10 @@ auto FvUpdater::CurrentlyRunningOnPlatform(const QString &platform) -> bool //--------------------------------------------------------------------------------------------------------------------- void FvUpdater::showErrorDialog(const QString &message, bool showEvenInSilentMode) { - if (m_silentAsMuchAsItCouldGet) + if (m_silentAsMuchAsItCouldGet && not showEvenInSilentMode) { - if (not showEvenInSilentMode) - { - // Don't show errors in the silent mode - return; - } + // Don't show errors in the silent mode + return; } QMessageBox dlFailedMsgBox; @@ -653,13 +642,10 @@ void FvUpdater::showErrorDialog(const QString &message, bool showEvenInSilentMod //--------------------------------------------------------------------------------------------------------------------- void FvUpdater::showInformationDialog(const QString &message, bool showEvenInSilentMode) { - if (m_silentAsMuchAsItCouldGet) + if (m_silentAsMuchAsItCouldGet && not showEvenInSilentMode) { - if (not showEvenInSilentMode) - { - // Don't show information dialogs in the silent mode - return; - } + // Don't show information dialogs in the silent mode + return; } QMessageBox dlInformationMsgBox; diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 549cabf55..083e1df80 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -443,12 +443,9 @@ auto VAbstractPattern::CheckExistNamePP(const QString &name) const -> bool for (qint32 i = 0; i < elements.count(); i++) { const QDomElement elem = elements.at(i).toElement(); - if (elem.isNull() == false) + if (elem.isNull() == false && GetParametrString(elem, AttrName) == name) { - if (GetParametrString(elem, AttrName) == name) - { - return true; - } + return true; } } return false; @@ -498,27 +495,24 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement) { if (domNode.isElement()) { - const QDomElement domElement = domNode.toElement(); - if (not domElement.isNull()) + if (const QDomElement domElement = domNode.toElement(); + not domElement.isNull() && domElement.tagName() == TagGroup) { - if (domElement.tagName() == TagGroup) + VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR), valentinaNamespace); + + const QPair> groupData = ParseItemElement(domElement); + const QMap group = groupData.second; + auto i = group.constBegin(); + while (i != group.constEnd()) { - VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR), valentinaNamespace); - - const QPair> groupData = ParseItemElement(domElement); - const QMap group = groupData.second; - auto i = group.constBegin(); - while (i != group.constEnd()) + if (not itemTool.contains(i.key())) { - if (not itemTool.contains(i.key())) - { - itemTool.insert(i.key(), i.value()); - } - - const bool previous = itemVisibility.value(i.key(), false); - itemVisibility.insert(i.key(), previous || groupData.first); - ++i; + itemTool.insert(i.key(), i.value()); } + + const bool previous = itemVisibility.value(i.key(), false); + itemVisibility.insert(i.key(), previous || groupData.first); + ++i; } } } @@ -562,13 +556,10 @@ auto VAbstractPattern::GetPPElement(const QString &name) -> QDomElement for (qint32 i = 0; i < elements.count(); i++) { - QDomElement const element = elements.at(i).toElement(); - if (not element.isNull()) + if (QDomElement const element = elements.at(i).toElement(); + not element.isNull() && element.attribute(AttrName) == name) { - if (element.attribute(AttrName) == name) - { - return element; - } + return element; } } } @@ -2623,40 +2614,37 @@ auto VAbstractPattern::GetGroups(const QString &patternPieceName) -> QMap(object, tool)); - } + items.append(QPair(object, tool)); } - - groupData.items = items; - - data.insert(id, groupData); } + + groupData.items = items; + + data.insert(id, groupData); } } domNode = domNode.nextSibling(); @@ -2703,19 +2691,16 @@ auto VAbstractPattern::GetGroupsContainingItem(quint32 toolId, quint32 objectId, { if (domNode.isElement()) { - const QDomElement group = domNode.toElement(); - if (group.isNull() == false) + if (const QDomElement group = domNode.toElement(); + group.isNull() == false && group.tagName() == TagGroup) { - if (group.tagName() == TagGroup) + bool const groupHasItem = GroupHasItem(group, toolId, objectId); + if ((containItem && groupHasItem) || (not containItem && not groupHasItem)) { - bool const groupHasItem = GroupHasItem(group, toolId, objectId); - if ((containItem && groupHasItem) || (not containItem && not groupHasItem)) - { - const quint32 groupId = GetParametrUInt(group, AttrId, QChar('0')); - const QString name = GetParametrString( - group, AttrName, QCoreApplication::translate("VAbstractPattern", "New group")); - data.insert(groupId, name); - } + const quint32 groupId = GetParametrUInt(group, AttrId, QChar('0')); + const QString name = GetParametrString( + group, AttrName, QCoreApplication::translate("VAbstractPattern", "New group")); + data.insert(groupId, name); } } } diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 4513bc113..eb6b95130 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -382,13 +382,9 @@ auto VDomDocument::find(QHash &cache, const QDomElement &n for (qint32 i = 0; i < node.childNodes().length(); ++i) { - const QDomNode n = node.childNodes().at(i); - if (n.isElement()) + if (const QDomNode n = node.childNodes().at(i); n.isElement() && VDomDocument::find(cache, n.toElement(), id)) { - if (VDomDocument::find(cache, n.toElement(), id)) - { - return true; - } + return true; } } return false; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index d2d8e24d5..0f6894299 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -643,31 +643,28 @@ auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet { if (domNode.isElement()) { - QDomElement domElement = domNode.toElement(); - if (not domElement.isNull()) + if (QDomElement domElement = domNode.toElement(); + not domElement.isNull() && domElement.tagName() == *strIncrement) { - if (domElement.tagName() == *strIncrement) + try { - try - { - const QString name = GetParametrString(domElement, *strName); - names.insert(name); - domElement.setAttribute(*strName, '#'_L1 + name); + const QString name = GetParametrString(domElement, *strName); + names.insert(name); + domElement.setAttribute(*strName, '#'_L1 + name); - const QString base = GetParametrString(domElement, *strBase); - domElement.setAttribute(*strFormula, base); - } - catch (VExceptionEmptyParameter &e) - { - VException excep("Can't get increment."); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - domElement.removeAttribute(*strId); - domElement.removeAttribute(*strKGrowth); - domElement.removeAttribute(*strKSize); - domElement.removeAttribute(*strBase); + const QString base = GetParametrString(domElement, *strBase); + domElement.setAttribute(*strFormula, base); } + catch (VExceptionEmptyParameter &e) + { + VException excep("Can't get increment."); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + domElement.removeAttribute(*strId); + domElement.removeAttribute(*strKGrowth); + domElement.removeAttribute(*strKSize); + domElement.removeAttribute(*strBase); } } domNode = domNode.nextSibling(); @@ -1627,13 +1624,10 @@ void VPatternConverter::TagRemoveAttributeTypeObjectInV0_4_0() QDomNode domNode = modeling.firstChild(); while (not domNode.isNull()) { - QDomElement domElement = domNode.toElement(); - if (not domElement.isNull()) + if (QDomElement domElement = domNode.toElement(); + not domElement.isNull() && domElement.hasAttribute(*strTypeObject)) { - if (domElement.hasAttribute(*strTypeObject)) - { - domElement.removeAttribute(*strTypeObject); - } + domElement.removeAttribute(*strTypeObject); } domNode = domNode.nextSibling(); } diff --git a/src/libs/vdxf/libdxfrw/drw_entities.cpp b/src/libs/vdxf/libdxfrw/drw_entities.cpp index 56e5a958a..b18d947e1 100644 --- a/src/libs/vdxf/libdxfrw/drw_entities.cpp +++ b/src/libs/vdxf/libdxfrw/drw_entities.cpp @@ -302,22 +302,19 @@ void DRW_Arc::applyExtrusion() { DRW_Circle::applyExtrusion(); - if (haveExtrusion) + // If the extrusion vector has a z value less than 0, the angles for the arc + // have to be mirrored since DXF files use the right hand rule. + // Note that the following code only handles the special case where there is a 2D + // drawing with the z axis heading into the paper (or rather screen). An arbitrary + // extrusion axis (with x and y values greater than 1/64) may still have issues. + if (haveExtrusion && fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0) { - // If the extrusion vector has a z value less than 0, the angles for the arc - // have to be mirrored since DXF files use the right hand rule. - // Note that the following code only handles the special case where there is a 2D - // drawing with the z axis heading into the paper (or rather screen). An arbitrary - // extrusion axis (with x and y values greater than 1/64) may still have issues. - if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0) - { - staangle = M_PI - staangle; - endangle = M_PI - endangle; + staangle = M_PI - staangle; + endangle = M_PI - endangle; - double const temp = staangle; - staangle = endangle; - endangle = temp; - } + double const temp = staangle; + staangle = endangle; + endangle = temp; } } diff --git a/src/libs/vdxf/libdxfrw/drw_header.cpp b/src/libs/vdxf/libdxfrw/drw_header.cpp index bac771819..f0d9d7a52 100644 --- a/src/libs/vdxf/libdxfrw/drw_header.cpp +++ b/src/libs/vdxf/libdxfrw/drw_header.cpp @@ -677,10 +677,9 @@ void DRW_Header::write(const std::unique_ptr &writer, DRW::Version ve else writer->writeString(1, "STANDARD"); // verify if exist "$DIMLUNIT" or obsolete "$DIMUNIT" (pre v2000) - if (!getInt("$DIMLUNIT", &varInt)) + if (!getInt("$DIMLUNIT", &varInt) && !getInt("$DIMUNIT", &varInt)) { - if (!getInt("$DIMUNIT", &varInt)) - varInt = 2; + varInt = 2; } // verify valid values from 1 to 6 if (varInt < 1 || varInt > 6) diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.cpp b/src/libs/vdxf/libdxfrw/libdxfrw.cpp index bca65e095..b09e04044 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.cpp +++ b/src/libs/vdxf/libdxfrw/libdxfrw.cpp @@ -204,13 +204,10 @@ auto dxfRW::writeEntity(DRW_Entity *ent) -> bool if (version < DRW::AC1012) { int varInt = 0; - if (header.getInt("$HANDLING", &varInt)) + if (header.getInt("$HANDLING", &varInt) && varInt != 0) { - if (varInt != 0) - { - ent->handle = static_cast(++entCount); - writer->writeString(5, toHexStr(static_cast(ent->handle))); - } + ent->handle = static_cast(++entCount); + writer->writeString(5, toHexStr(static_cast(ent->handle))); } } else @@ -410,16 +407,13 @@ auto dxfRW::writeTextstyle(DRW_Textstyle *ent) -> bool // stringstream cause crash in OS/X, bug#3597944 std::string name = ent->name; transform(name.begin(), name.end(), name.begin(), toupper); - if (!dimstyleStd) + if (!dimstyleStd && name == "STANDARD") { + // stringstream cause crash in OS/X, bug#3597944 + std::string name = ent->name; + transform(name.begin(), name.end(), name.begin(), toupper); if (name == "STANDARD") - { - // stringstream cause crash in OS/X, bug#3597944 - std::string name = ent->name; - transform(name.begin(), name.end(), name.begin(), toupper); - if (name == "STANDARD") - dimstyleStd = true; - } + dimstyleStd = true; } if (version > DRW::AC1009) { @@ -679,15 +673,12 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool writer->writeUtf8String(340, toHexStr(txstyHandle)); } } - if (version > DRW::AC1014) + if (version > DRW::AC1014 && blockMap.count(ent->dimldrblk) > 0) { - if (blockMap.count(ent->dimldrblk) > 0) - { - int const blkHandle = (*(blockMap.find(ent->dimldrblk))).second; - writer->writeUtf8String(341, toHexStr(blkHandle)); - writer->writeInt16(371, ent->dimlwd); - writer->writeInt16(372, ent->dimlwe); - } + int const blkHandle = (*(blockMap.find(ent->dimldrblk))).second; + writer->writeUtf8String(341, toHexStr(blkHandle)); + writer->writeInt16(371, ent->dimlwd); + writer->writeInt16(372, ent->dimlwe); } return true; } @@ -2639,12 +2630,9 @@ auto dxfRW::processLType() -> bool return true; // found ENDTAB terminate } } - else if (reading) + else if (reading && !ltype.parseCode(code, reader)) { - if (!ltype.parseCode(code, reader)) - { - return setError(DRW::BAD_CODE_PARSED); - } + return setError(DRW::BAD_CODE_PARSED); } } @@ -2679,12 +2667,9 @@ auto dxfRW::processLayer() -> bool return true; // found ENDTAB terminate } } - else if (reading) + else if (reading && !layer.parseCode(code, reader)) { - if (!layer.parseCode(code, reader)) - { - return setError(DRW::BAD_CODE_PARSED); - } + return setError(DRW::BAD_CODE_PARSED); } } @@ -2719,12 +2704,9 @@ auto dxfRW::processDimStyle() -> bool return true; // found ENDTAB terminate } } - else if (reading) + else if (reading && !dimSty.parseCode(code, reader)) { - if (!dimSty.parseCode(code, reader)) - { - return setError(DRW::BAD_CODE_PARSED); - } + return setError(DRW::BAD_CODE_PARSED); } } @@ -2759,12 +2741,9 @@ auto dxfRW::processTextStyle() -> bool return true; // found ENDTAB terminate } } - else if (reading) + else if (reading && !TxtSty.parseCode(code, reader)) { - if (!TxtSty.parseCode(code, reader)) - { - return setError(DRW::BAD_CODE_PARSED); - } + return setError(DRW::BAD_CODE_PARSED); } } @@ -2799,12 +2778,9 @@ auto dxfRW::processVports() -> bool return true; // found ENDTAB terminate } } - else if (reading) + else if (reading && !vp.parseCode(code, reader)) { - if (!vp.parseCode(code, reader)) - { - return setError(DRW::BAD_CODE_PARSED); - } + return setError(DRW::BAD_CODE_PARSED); } } @@ -2839,12 +2815,9 @@ auto dxfRW::processAppId() -> bool return true; // found ENDTAB terminate } } - else if (reading) + else if (reading && !vp.parseCode(code, reader)) { - if (!vp.parseCode(code, reader)) - { - return setError(DRW::BAD_CODE_PARSED); - } + return setError(DRW::BAD_CODE_PARSED); } } diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 15a88315e..a14c98027 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -1047,14 +1047,12 @@ void VDxfEngine::ExportAAMANotch(const QSharedPointer &detailBloc { ExportNotch(passmark.baseLine.p1(), passmark.baseLine.length(), passmark.baseLine.angle()); - if (!mirrorLine.isNull() && detail.IsShowFullPiece()) + if (!mirrorLine.isNull() && detail.IsShowFullPiece() && + !VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2())) { - if (!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2())) - { - const QTransform matrix = VGObject::FlippingMatrix(mirrorLine); - QLineF const baseLine = matrix.map(passmark.baseLine); - ExportNotch(baseLine.p1(), baseLine.length(), baseLine.angle()); - } + const QTransform matrix = VGObject::FlippingMatrix(mirrorLine); + QLineF const baseLine = matrix.map(passmark.baseLine); + ExportNotch(baseLine.p1(), baseLine.length(), baseLine.angle()); } } } @@ -1694,15 +1692,13 @@ void VDxfEngine::ExportASTMNotches(const QSharedPointer &detailBl ExportPassmark(passmark); const QLineF mirrorLine = detail.GetMappedSeamMirrorLine(); - if (!mirrorLine.isNull() && detail.IsShowFullPiece()) + if (!mirrorLine.isNull() && detail.IsShowFullPiece() && + !VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2())) { - if (!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2())) - { - const QTransform matrix = VGObject::FlippingMatrix(mirrorLine); - const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false); + const QTransform matrix = VGObject::FlippingMatrix(mirrorLine); + const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false); - ExportPassmark(mirroredPassmark); - } + ExportPassmark(mirroredPassmark); } } } @@ -1776,14 +1772,12 @@ auto VDxfEngine::ExportASTMNotch(const VLayoutPassmark &passmark) -> DRW_ASTMNot notch->angle = passmark.baseLine.angle(); PassmarkLineType type = passmark.type; - if (m_compatibilityMode == DXFApparelCompatibility::RPCADV08 || - m_compatibilityMode == DXFApparelCompatibility::RPCADV09 || - m_compatibilityMode == DXFApparelCompatibility::RPCADV10) + if ((m_compatibilityMode == DXFApparelCompatibility::RPCADV08 || + m_compatibilityMode == DXFApparelCompatibility::RPCADV09 || + m_compatibilityMode == DXFApparelCompatibility::RPCADV10) && + (type == PassmarkLineType::ExternalVMark || type == PassmarkLineType::InternalVMark)) { - if (type == PassmarkLineType::ExternalVMark || type == PassmarkLineType::InternalVMark) - { - type = PassmarkLineType::CheckMark; - } + type = PassmarkLineType::CheckMark; } switch (type) diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 670485e95..3681b1338 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -854,13 +854,10 @@ auto VMeasurements::MeasurementForDimension(IMD type) const -> QString for (int i = 0; i < list.size(); ++i) { - const QDomElement domElement = list.at(i).toElement(); - if (!domElement.isNull()) + if (const QDomElement domElement = list.at(i).toElement(); + !domElement.isNull() && domElement.attribute(AttrDimension) == d) { - if (domElement.attribute(AttrDimension) == d) - { - return domElement.attribute(AttrName); - } + return domElement.attribute(AttrName); } } return {}; @@ -1619,13 +1616,10 @@ void VMeasurements::ClearDimension(IMD type) for (int i = 0; i < list.size(); ++i) { - QDomElement domElement = list.at(i).toElement(); - if (!domElement.isNull()) + if (QDomElement domElement = list.at(i).toElement(); + !domElement.isNull() && domElement.attribute(AttrDimension) == d) { - if (domElement.attribute(AttrDimension) == d) - { - domElement.removeAttribute(AttrDimension); - } + domElement.removeAttribute(AttrDimension); } } } diff --git a/src/libs/vgeometry/vabstractcubicbezier.cpp b/src/libs/vgeometry/vabstractcubicbezier.cpp index 07530d902..1b0bce5e3 100644 --- a/src/libs/vgeometry/vabstractcubicbezier.cpp +++ b/src/libs/vgeometry/vabstractcubicbezier.cpp @@ -239,13 +239,10 @@ auto PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, q return points; } - if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0) + if ((m_cusp_limit > 0.0 || m_cusp_limit < 0.0) && da1 > m_cusp_limit) { - if (da1 > m_cusp_limit) - { - points.append(QPointF(x3, y3)); - return points; - } + points.append(QPointF(x3, y3)); + return points; } } break; @@ -278,13 +275,10 @@ auto PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, q return points; } - if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0) + if ((m_cusp_limit > 0.0 || m_cusp_limit < 0.0) && da1 > m_cusp_limit) { - if (da1 > m_cusp_limit) - { - points.append(QPointF(x2, y2)); - return points; - } + points.append(QPointF(x2, y2)); + return points; } } break; diff --git a/src/libs/vhpgl/vhpglengine.cpp b/src/libs/vhpgl/vhpglengine.cpp index e4259387f..ae2c8ebb5 100644 --- a/src/libs/vhpgl/vhpglengine.cpp +++ b/src/libs/vhpgl/vhpglengine.cpp @@ -528,15 +528,13 @@ void VHPGLEngine::PlotPassmarks(QTextStream &out, const VLayoutPiece &detail) PlotPassmark(passmark); const QLineF mirrorLine = detail.GetMappedSeamMirrorLine(); - if (!mirrorLine.isNull() && detail.IsShowFullPiece()) + if (!mirrorLine.isNull() && detail.IsShowFullPiece() && + !VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2())) { - if (!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2())) - { - const QTransform matrix = VGObject::FlippingMatrix(mirrorLine); - const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false); + const QTransform matrix = VGObject::FlippingMatrix(mirrorLine); + const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false); - PlotPassmark(mirroredPassmark); - } + PlotPassmark(mirroredPassmark); } } } diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index d61473130..8620a6915 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -729,12 +729,9 @@ auto Rollback(QVector &points, const QLineF &edge) -> bool points.removeLast(); points = VAbstractPiece::RollbackSeamAllowance(points, edge, &success); - if (not points.isEmpty()) + if (not points.isEmpty() && points.constLast().toPoint() != points.constFirst().toPoint()) { - if (points.constLast().toPoint() != points.constFirst().toPoint()) - { - points.append(points.constFirst()); // Should be always closed - } + points.append(points.constFirst()); // Should be always closed } } return success; @@ -866,12 +863,9 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect } } - if (not ekvPoints.isEmpty()) + if (not ekvPoints.isEmpty() && ekvPoints.constLast().toPoint() != ekvPoints.constFirst().toPoint()) { - if (ekvPoints.constLast().toPoint() != ekvPoints.constFirst().toPoint()) - { - ekvPoints.append(ekvPoints.constFirst()); // Should be always closed - } + ekvPoints.append(ekvPoints.constFirst()); // Should be always closed } } } diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 3a4ebf253..afa4d174d 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -370,14 +370,11 @@ inline auto VAbstractPiece::RemoveDublicates(const QVector &points, bool remo } } - if (removeFirstAndLast) + if (removeFirstAndLast && not p.isEmpty() && p.size() > 1) { - if (not p.isEmpty() && p.size() > 1) - { - // Path can't be closed - // See issue #686 - CompareFirstAndLastPoints(p, accuracy); - } + // Path can't be closed + // See issue #686 + CompareFirstAndLastPoints(p, accuracy); } return p; diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index f3fab9f1f..a01c13889 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -1754,16 +1754,13 @@ auto VLayoutPiece::GetItem(bool textAsPaths, bool togetherWithNotches, bool show mirrorFlag = true; } } - else if (not IsSeamAllowanceBuiltIn()) + else if (not IsSeamAllowanceBuiltIn() && !d->m_seamAllowanceMirrorLine.isNull()) { - if (!d->m_seamAllowanceMirrorLine.isNull()) - { - QPainterPath mirrorPath; - mirrorPath.moveTo(d->m_matrix.map(d->m_seamAllowanceMirrorLine.p1())); - mirrorPath.lineTo(d->m_matrix.map(d->m_seamAllowanceMirrorLine.p2())); - mirrorLinePath.addPath(mirrorPath); - mirrorFlag = true; - } + QPainterPath mirrorPath; + mirrorPath.moveTo(d->m_matrix.map(d->m_seamAllowanceMirrorLine.p1())); + mirrorPath.lineTo(d->m_matrix.map(d->m_seamAllowanceMirrorLine.p2())); + mirrorLinePath.addPath(mirrorPath); + mirrorFlag = true; } if (mirrorFlag) diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index cfcd09433..87c23ce5c 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -455,15 +455,13 @@ auto VPosition::Crossing(const VLayoutPiece &detail) const -> VPosition::Crossin for (const auto &position : m_data.positionsCache) { - if (position.boundingRect.intersects(layoutBoundingRect) || - position.boundingRect.contains(detailBoundingRect) || detailBoundingRect.contains(position.boundingRect)) + if ((position.boundingRect.intersects(layoutBoundingRect) || + position.boundingRect.contains(detailBoundingRect) || + detailBoundingRect.contains(position.boundingRect)) && + (position.layoutAllowancePath.contains(contourPath) || contourPath.contains(position.layoutAllowancePath) || + position.layoutAllowancePath.intersects(layoutAllowancePath))) { - if (position.layoutAllowancePath.contains(contourPath) || - contourPath.contains(position.layoutAllowancePath) || - position.layoutAllowancePath.intersects(layoutAllowancePath)) - { - return CrossingType::Intersection; - } + return CrossingType::Intersection; } } diff --git a/src/libs/vlayout/vprintlayout.cpp b/src/libs/vlayout/vprintlayout.cpp index ca1c4d099..722f2dc5f 100644 --- a/src/libs/vlayout/vprintlayout.cpp +++ b/src/libs/vlayout/vprintlayout.cpp @@ -192,12 +192,9 @@ void VPrintLayout::PdfTiledFile(const QString &name) { m_isTiled = true; - if (m_isLayoutStale) + if (m_isLayoutStale && ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No) { - if (ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No) - { - return; - } + return; } QPrinter printer; SetPrinterSettings(&printer, PrintType::PrintPDF, name); @@ -224,12 +221,9 @@ void VPrintLayout::CleanLayout() //--------------------------------------------------------------------------------------------------------------------- void VPrintLayout::PrintLayout() { - if (m_isLayoutStale) + if (m_isLayoutStale && ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No) { - if (ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No) - { - return; - } + return; } // display print dialog and if accepted print QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName); @@ -269,12 +263,9 @@ void VPrintLayout::PrintLayout() //--------------------------------------------------------------------------------------------------------------------- void VPrintLayout::PrintPreview() { - if (m_isLayoutStale) + if (m_isLayoutStale && ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No) { - if (ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No) - { - return; - } + return; } QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName); @@ -390,13 +381,10 @@ void VPrintLayout::PrintPages(QPrinter *printer) { for (int j = 0; j < numPages; ++j) { - if (i != 0 || j != 0) + if ((i != 0 || j != 0) && not printer->newPage()) { - if (not printer->newPage()) - { - qCritical() << tr("Failed in flushing page to disk, disk full?"); - return; - } + qCritical() << tr("Failed in flushing page to disk, disk full?"); + return; } vsizetype index; if (printer->pageOrder() == QPrinter::FirstPageFirst) diff --git a/src/libs/vmisc/qxtcsvmodel.cpp b/src/libs/vmisc/qxtcsvmodel.cpp index f91ddc2d6..28143db34 100644 --- a/src/libs/vmisc/qxtcsvmodel.cpp +++ b/src/libs/vmisc/qxtcsvmodel.cpp @@ -605,13 +605,10 @@ auto QxtCsvModel::toCSV(QIODevice *dest, QString &error, bool withHeader, QChar rows = rowCount(); cols = columnCount(); QString data; - if (not dest->isOpen()) + if (not dest->isOpen() && not dest->open(QIODevice::WriteOnly | QIODevice::Truncate)) { - if (not dest->open(QIODevice::WriteOnly | QIODevice::Truncate)) - { - error = dest->errorString(); - return false; - } + error = dest->errorString(); + return false; } QTextStream stream(dest); diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index f6b6af816..a9869f0e9 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -591,14 +591,11 @@ void VAbstractApplication::CheckSystemLocale() //--------------------------------------------------------------------------------------------------------------------- void VAbstractApplication::SVGFontsPathChanged(const QString &oldPath, const QString &newPath) { - if (oldPath != newPath) + if (oldPath != newPath && m_svgFontDatabase != nullptr) { - if (m_svgFontDatabase != nullptr) - { - RestartSVGFontDatabaseWatcher(); - m_svgFontDatabase->InvalidatePath(oldPath); - RepopulateFontDatabase(newPath); - } + RestartSVGFontDatabaseWatcher(); + m_svgFontDatabase->InvalidatePath(oldPath); + RepopulateFontDatabase(newPath); } } diff --git a/src/libs/vpatterndb/vnodedetail.cpp b/src/libs/vpatterndb/vnodedetail.cpp index 8b3e9033b..bc569203c 100644 --- a/src/libs/vpatterndb/vnodedetail.cpp +++ b/src/libs/vpatterndb/vnodedetail.cpp @@ -240,27 +240,25 @@ auto VNodeDetail::Convert(const VContainer *data, const QVector &no for (int i = 0; i < nodes.size(); ++i) { const VNodeDetail &node = nodes.at(i); - if (node.getTypeTool() == Tool::NodePoint) + if (node.getTypeTool() == Tool::NodePoint && + (not qFuzzyIsNull(node.getMx()) || not qFuzzyIsNull(node.getMy()))) { - if (not qFuzzyIsNull(node.getMx()) || not qFuzzyIsNull(node.getMy())) - { - const QPointF previosPoint = path.NodePreviousPoint(data, i); - const QPointF nextPoint = path.NodeNextPoint(data, i); + const QPointF previosPoint = path.NodePreviousPoint(data, i); + const QPointF nextPoint = path.NodeNextPoint(data, i); - const QPointF point = data->GeometricObject(node.getId())->toQPointF(); + const QPointF point = data->GeometricObject(node.getId())->toQPointF(); - QLineF lineBefore(point, previosPoint); - lineBefore.setAngle(lineBefore.angle() - 90); - lineBefore.setLength(width); + QLineF lineBefore(point, previosPoint); + lineBefore.setAngle(lineBefore.angle() - 90); + lineBefore.setLength(width); - ConvertBefore(path[i], lineBefore, node.getMx(), node.getMy()); + ConvertBefore(path[i], lineBefore, node.getMx(), node.getMy()); - QLineF lineAfter(point, nextPoint); - lineAfter.setAngle(lineAfter.angle() + 90); - lineAfter.setLength(width); + QLineF lineAfter(point, nextPoint); + lineAfter.setAngle(lineAfter.angle() + 90); + lineAfter.setLength(width); - ConvertAfter(path[i], lineAfter, node.getMx(), node.getMy()); - } + ConvertAfter(path[i], lineAfter, node.getMx(), node.getMy()); } } } diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 494936c1b..ac7c93bde 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -365,18 +365,15 @@ auto VPiece::PassmarksPath(const VContainer *data) const -> QPainterPath QPainterPath path; // seam allowence - if (IsSeamAllowance()) + if (IsSeamAllowance() && not passmarks.isEmpty()) { - if (not passmarks.isEmpty()) + for (qint32 i = 0; i < passmarks.count(); ++i) { - for (qint32 i = 0; i < passmarks.count(); ++i) - { - path.moveTo(passmarks.at(i).p1()); - path.lineTo(passmarks.at(i).p2()); - } - - path.setFillRule(Qt::WindingFill); + path.moveTo(passmarks.at(i).p1()); + path.lineTo(passmarks.at(i).p2()); } + + path.setFillRule(Qt::WindingFill); } return path; diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index a171c125c..f60927211 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -221,18 +221,16 @@ template inline auto VPiece::SeamAllowancePath(const QVector &point QPainterPath ekv; // seam allowence - if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn()) + if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn() && not points.isEmpty()) { - if (not points.isEmpty()) + ekv.moveTo(points.at(0)); + for (qint32 i = 1; i < points.count(); ++i) { - ekv.moveTo(points.at(0)); - for (qint32 i = 1; i < points.count(); ++i) - { - ekv.lineTo(points.at(i)); - } + ekv.lineTo(points.at(i)); + } #if !defined(V_NO_ASSERT) - // uncomment for debug + // uncomment for debug // QFont font; // font.setPixelSize(1); // for (qint32 i = 0; i < points.count(); ++i) @@ -248,8 +246,7 @@ template inline auto VPiece::SeamAllowancePath(const QVector &point // } #endif - ekv.setFillRule(Qt::WindingFill); - } + ekv.setFillRule(Qt::WindingFill); } return ekv; diff --git a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp index 80f1529dd..8b292a71d 100644 --- a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp +++ b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp @@ -156,13 +156,10 @@ auto VPE::VFileEditWidget::eventFilter(QObject *obj, QEvent *ev) -> bool ev->ignore(); return true; } - else if (obj == FileLineEdit) + else if (obj == FileLineEdit && ev->type() == QEvent::FocusOut) { - if (ev->type() == QEvent::FocusOut) - { - setFile(FileLineEdit->text(), true); - // We don't return true here because we still want the line edit to catch the event as well - } + setFile(FileLineEdit->text(), true); + // We don't return true here because we still want the line edit to catch the event as well } // forward the signal to the parent class diff --git a/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.cpp index a636a6c72..fa38336de 100644 --- a/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.cpp +++ b/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.cpp @@ -53,21 +53,18 @@ VPE::VShortcutEditWidget::~VShortcutEditWidget() auto VPE::VShortcutEditWidget::eventFilter(QObject *obj, QEvent *event) -> bool { - if (obj == LineEdit) + if (obj == LineEdit && event->type() == QEvent::KeyPress) { - if (event->type() == QEvent::KeyPress) + auto *keyEvent = static_cast(event); + + int keys = keyEvent->key(); + + if (keys != Qt::Key_Shift && keys != Qt::Key_Control && keys != Qt::Key_Meta && keys != Qt::Key_AltGr && + keys != Qt::Key_Alt) { - auto *keyEvent = static_cast(event); - - int keys = keyEvent->key(); - - if (keys != Qt::Key_Shift && keys != Qt::Key_Control && keys != Qt::Key_Meta && keys != Qt::Key_AltGr && - keys != Qt::Key_Alt) - { - keys += keyEvent->modifiers(); - setShortcut(QKeySequence(keys), true); - return true; - } + keys += keyEvent->modifiers(); + setShortcut(QKeySequence(keys), true); + return true; } } diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index 33e7cb112..e33819f6d 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -126,13 +126,10 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, quint32 t // Disable Qt::WaitCursor #ifndef QT_NO_CURSOR - if (QGuiApplication::overrideCursor() != nullptr) + if (QGuiApplication::overrideCursor() != nullptr && QGuiApplication::overrideCursor()->shape() == Qt::WaitCursor) { - if (QGuiApplication::overrideCursor()->shape() == Qt::WaitCursor) - { - restoreCursor = true; - QGuiApplication::restoreOverrideCursor(); - } + restoreCursor = true; + QGuiApplication::restoreOverrideCursor(); } #endif ui->tableWidget->setColumnCount(2); diff --git a/src/libs/vtools/dialogs/tools/dialogarc.cpp b/src/libs/vtools/dialogs/tools/dialogarc.cpp index 49cd9e457..dd5dad911 100644 --- a/src/libs/vtools/dialogs/tools/dialogarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogarc.cpp @@ -369,30 +369,24 @@ void DialogArc::SetRadius(const QString &value) */ void DialogArc::ChosenObject(quint32 id, const SceneObject &type) { - if (not prepare) // After first choose we ignore all objects + if (not prepare && type == SceneObject::Point && + SetObject(id, ui->comboBoxBasePoint, QString())) // After first choose we ignore all objects { - if (type == SceneObject::Point) + if (vis != nullptr) { - if (SetObject(id, ui->comboBoxBasePoint, QString())) - { - if (vis != nullptr) - { - auto *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - vis->VisualMode(id); - vis->RefreshToolTip(); - } + vis->VisualMode(id); + vis->RefreshToolTip(); + } - prepare = true; + prepare = true; - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } - } + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) + { + FinishCreating(); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp b/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp index f57ee2863..4e4b03c3f 100644 --- a/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp +++ b/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp @@ -353,30 +353,24 @@ void DialogArcWithLength::ShowDialog(bool click) //--------------------------------------------------------------------------------------------------------------------- void DialogArcWithLength::ChosenObject(quint32 id, const SceneObject &type) { - if (not prepare) // After first choose we ignore all objects + if (not prepare && type == SceneObject::Point && + SetObject(id, ui->comboBoxCenter, QString())) // After first choose we ignore all objects { - if (type == SceneObject::Point) + if (vis != nullptr) { - if (SetObject(id, ui->comboBoxCenter, QString())) - { - if (vis != nullptr) - { - auto *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - vis->VisualMode(id); - vis->RefreshToolTip(); - } + vis->VisualMode(id); + vis->RefreshToolTip(); + } - prepare = true; + prepare = true; - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } - } + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) + { + FinishCreating(); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogbisector.cpp b/src/libs/vtools/dialogs/tools/dialogbisector.cpp index a01a54dfe..b6f17b99a 100644 --- a/src/libs/vtools/dialogs/tools/dialogbisector.cpp +++ b/src/libs/vtools/dialogs/tools/dialogbisector.cpp @@ -213,14 +213,12 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id && + SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle"))) { - if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle"))) - { - m_number++; - line->SetPoint2Id(id); - line->RefreshGeometry(); - } + m_number++; + line->SetPoint2Id(id); + line->RefreshGeometry(); } break; case 2: @@ -439,25 +437,22 @@ void DialogBisector::ChosenThirdPoint(quint32 id) set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); set.insert(id); - if (set.size() == 3) + if (set.size() == 3 && SetObject(id, ui->comboBoxThirdPoint, QString())) { - if (SetObject(id, ui->comboBoxThirdPoint, QString())) + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + + auto *line = qobject_cast(vis); + SCASSERT(line != nullptr) + connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + + line->SetPoint3Id(id); + line->RefreshGeometry(); + prepare = true; + + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) { - auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - - auto *line = qobject_cast(vis); - SCASSERT(line != nullptr) - connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - - line->SetPoint3Id(id); - line->RefreshGeometry(); - prepare = true; - - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } + FinishCreating(); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp index 8160347c7..47fec6059 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp @@ -122,57 +122,51 @@ void DialogCubicBezier::SetSpline(const VCubicBezier &spline) //--------------------------------------------------------------------------------------------------------------------- void DialogCubicBezier::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + auto *path = qobject_cast(vis); + SCASSERT(path != nullptr) + + switch (number) { - auto *path = qobject_cast(vis); - SCASSERT(path != nullptr) + case 0: + if (SetObject(id, ui->comboBoxP1, tr("Select the second point of curve"))) + { + ++number; + path->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxP2, tr("Select the third point of curve"))) + { + ++number; - switch (number) - { - case 0: - if (SetObject(id, ui->comboBoxP1, tr("Select the second point of curve"))) - { - ++number; - path->VisualMode(id); - } - break; - case 1: - if (SetObject(id, ui->comboBoxP2, tr("Select the third point of curve"))) - { - ++number; + path->SetPoint2Id(id); + path->RefreshGeometry(); + } + break; + case 2: + if (SetObject(id, ui->comboBoxP3, tr("Select the fourth point of curve"))) + { + ++number; - path->SetPoint2Id(id); - path->RefreshGeometry(); - } - break; - case 2: - if (SetObject(id, ui->comboBoxP3, tr("Select the fourth point of curve"))) - { - ++number; + path->SetPoint3Id(id); + path->RefreshGeometry(); + } + break; + case 3: + if (getCurrentObjectId(ui->comboBoxP1) != id && SetObject(id, ui->comboBoxP4, QString())) + { + ++number; - path->SetPoint3Id(id); - path->RefreshGeometry(); - } - break; - case 3: - if (getCurrentObjectId(ui->comboBoxP1) != id) - { - if (SetObject(id, ui->comboBoxP4, QString())) - { - ++number; - - path->SetPoint4Id(id); - path->RefreshGeometry(); - prepare = true; - DialogAccepted(); - } - } - break; - default: - break; - } + path->SetPoint4Id(id); + path->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp index 9b5591f70..e0aee4a2a 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp @@ -190,19 +190,17 @@ void DialogCubicBezierPath::ShowDialog(bool click) } const auto size = path.CountPoints(); - if (size >= 7) + if (size >= 7 && size - VCubicBezierPath::SubSplPointsCount(path.CountSubSpl()) == 0) { - if (size - VCubicBezierPath::SubSplPointsCount(path.CountSubSpl()) == 0) - { // Accept only if all subpaths are completed - emit ToolTip(QString()); + // Accept only if all subpaths are completed + emit ToolTip(QString()); - if (not data->IsUnique(path.name())) - { - path.SetDuplicate(DNumber(path.name())); - } - - DialogAccepted(); + if (not data->IsUnique(path.name())) + { + path.SetDuplicate(DNumber(path.name())); } + + DialogAccepted(); } } diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index 5f89ab0ed..ef92f9c10 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -261,36 +261,31 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) switch (number) { case (0): - if (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc || - type == SceneObject::SplinePath) + if ((type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc || + type == SceneObject::SplinePath) && + SetObject(id, ui->comboBoxCurve, tr("Select axis point"))) { - if (SetObject(id, ui->comboBoxCurve, tr("Select axis point"))) - { - number++; - line->VisualMode(id); - auto *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(line, &VisToolCurveIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - } + number++; + line->VisualMode(id); + auto *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(line, &VisToolCurveIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip); } break; case (1): - if (type == SceneObject::Point) + if (type == SceneObject::Point && SetObject(id, ui->comboBoxAxisPoint, QString())) { - if (SetObject(id, ui->comboBoxAxisPoint, QString())) + line->setAxisPointId(id); + line->RefreshGeometry(); + prepare = true; + + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) { - line->setAxisPointId(id); - line->RefreshGeometry(); - prepare = true; + emit ToolTip(QString()); - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - emit ToolTip(QString()); - - setModal(true); - show(); - } + setModal(true); + show(); } } break; diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp index 772cfaf11..4663e91a7 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp @@ -172,38 +172,35 @@ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type) return; } - if (type == SceneObject::Arc) + if (type == SceneObject::Arc && SetObject(id, ui->comboBoxArc, QString())) { - if (SetObject(id, ui->comboBoxArc, QString())) + if (vis != nullptr) { - if (vis != nullptr) - { - vis->VisualMode(id); - } - prepare = true; + vis->VisualMode(id); + } + prepare = true; - auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - if (m_buildStartPoint) - { - SetFormula("0"_L1); - FinishCreating(); - return; - } + if (m_buildStartPoint) + { + SetFormula("0"_L1); + FinishCreating(); + return; + } - if (m_buildEndPoint) - { - SetFormula(currentLength); - FinishCreating(); - return; - } + if (m_buildEndPoint) + { + SetFormula(currentLength); + FinishCreating(); + return; + } - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) + { + FinishCreating(); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp index f101cf1c8..814161259 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp @@ -175,24 +175,21 @@ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type) return; } - if (type == SceneObject::Spline) + if (type == SceneObject::Spline && SetObject(id, ui->comboBoxSpline, QString())) { - if (SetObject(id, ui->comboBoxSpline, QString())) + if (vis != nullptr) { - if (vis != nullptr) - { - vis->VisualMode(id); - } - prepare = true; + vis->VisualMode(id); + } + prepare = true; - auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) + { + FinishCreating(); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp index 1e7801f7e..3d0f4fa84 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp @@ -175,24 +175,21 @@ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type) return; } - if (type == SceneObject::SplinePath) + if (type == SceneObject::SplinePath && SetObject(id, ui->comboBoxSplinePath, QString())) { - if (SetObject(id, ui->comboBoxSplinePath, QString())) + if (vis != nullptr) { - if (vis != nullptr) - { - vis->VisualMode(id); - } - prepare = true; + vis->VisualMode(id); + } + prepare = true; - auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) + { + FinishCreating(); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogendline.cpp b/src/libs/vtools/dialogs/tools/dialogendline.cpp index 5a5d9b293..e4a40033e 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogendline.cpp @@ -206,26 +206,21 @@ void DialogEndLine::FXLength() */ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) { - if (not prepare) // After first choose we ignore all objects + if (not prepare && type == SceneObject::Point && + SetObject(id, ui->comboBoxBasePoint, QString())) // After first choose we ignore all objects { - if (type == SceneObject::Point) + if (vis != nullptr) { - if (SetObject(id, ui->comboBoxBasePoint, QString())) - { - if (vis != nullptr) - { - vis->VisualMode(id); - } - auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - prepare = true; + vis->VisualMode(id); + } + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + prepare = true; - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } - } + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) + { + FinishCreating(); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp index 010b08f05..4614ca7a6 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp @@ -260,28 +260,25 @@ void DialogFlippingByAxis::SetSourceObjects(const QVector &value) //--------------------------------------------------------------------------------------------------------------------- void DialogFlippingByAxis::ChosenObject(quint32 id, const SceneObject &type) { - if (not stage1 && not prepare) // After first choose we ignore all objects + if (not stage1 && not prepare && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [id](const SourceItem &sItem) { return sItem.id == id; }); + + if (obj != sourceObjects.end()) { - auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), - [id](const SourceItem &sItem) { return sItem.id == id; }); + emit ToolTip(tr("Select origin point that is not part of the list of objects")); + return; + } - if (obj != sourceObjects.end()) - { - emit ToolTip(tr("Select origin point that is not part of the list of objects")); - return; - } + if (SetObject(id, ui->comboBoxOriginPoint, QString())) + { + auto *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) + operation->SetOriginPointId(id); + operation->RefreshGeometry(); - if (SetObject(id, ui->comboBoxOriginPoint, QString())) - { - auto *operation = qobject_cast(vis); - SCASSERT(operation != nullptr) - operation->SetOriginPointId(id); - operation->RefreshGeometry(); - - prepare = true; - } + prepare = true; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp index 7eb4847f6..cd5bea76f 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp @@ -253,57 +253,49 @@ void DialogFlippingByLine::SetSourceObjects(const QVector &value) //--------------------------------------------------------------------------------------------------------------------- void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type) { - if (not stage1 && not prepare) // After first choose we ignore all objects + if (not stage1 && not prepare && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [id](const SourceItem &sItem) { return sItem.id == id; }); + switch (number) { - auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), - [id](const SourceItem &sItem) { return sItem.id == id; }); - switch (number) - { - case 0: - if (obj != sourceObjects.end()) - { - emit ToolTip(tr("Select first line point that is not part of the list of objects")); - return; - } + case 0: + if (obj != sourceObjects.end()) + { + emit ToolTip(tr("Select first line point that is not part of the list of objects")); + return; + } - if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second line point"))) - { - number++; - auto *operation = qobject_cast(vis); - SCASSERT(operation != nullptr) - operation->SetFirstLinePointId(id); - operation->RefreshGeometry(); - } - break; - case 1: - if (obj != sourceObjects.end()) - { - emit ToolTip(tr("Select second line point that is not part of the list of objects")); - return; - } + if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second line point"))) + { + number++; + auto *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) + operation->SetFirstLinePointId(id); + operation->RefreshGeometry(); + } + break; + case 1: + if (obj != sourceObjects.end()) + { + emit ToolTip(tr("Select second line point that is not part of the list of objects")); + return; + } - if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id) - { - if (SetObject(id, ui->comboBoxSecondLinePoint, QString())) - { - if (flagError) - { - number = 0; - prepare = true; + if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id && + SetObject(id, ui->comboBoxSecondLinePoint, QString()) && flagError) + { + number = 0; + prepare = true; - auto *operation = qobject_cast(vis); - SCASSERT(operation != nullptr) - operation->SetSecondLinePointId(id); - operation->RefreshGeometry(); - } - } - } - break; - default: - break; - } + auto *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) + operation->SetSecondLinePointId(id); + operation->RefreshGeometry(); + } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogheight.cpp b/src/libs/vtools/dialogs/tools/dialogheight.cpp index 4fbf4f038..04844fa5d 100644 --- a/src/libs/vtools/dialogs/tools/dialogheight.cpp +++ b/src/libs/vtools/dialogs/tools/dialogheight.cpp @@ -208,14 +208,12 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) } break; case (1): - if (getCurrentObjectId(ui->comboBoxBasePoint) != id) + if (getCurrentObjectId(ui->comboBoxBasePoint) != id && + SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) { - if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) - { - m_number++; - line->SetLineP1Id(id); - line->RefreshGeometry(); - } + m_number++; + line->SetLineP1Id(id); + line->RefreshGeometry(); } break; case (2): @@ -225,15 +223,12 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) set.insert(getCurrentObjectId(ui->comboBoxP1Line)); set.insert(id); - if (set.size() == 3) + if (set.size() == 3 && SetObject(id, ui->comboBoxP2Line, QString())) { - if (SetObject(id, ui->comboBoxP2Line, QString())) - { - line->SetLineP2Id(id); - line->RefreshGeometry(); - prepare = true; - DialogAccepted(); - } + line->SetLineP2Id(id); + line->RefreshGeometry(); + prepare = true; + DialogAccepted(); } } break; diff --git a/src/libs/vtools/dialogs/tools/dialogline.cpp b/src/libs/vtools/dialogs/tools/dialogline.cpp index 2b775edaf..3745faa54 100644 --- a/src/libs/vtools/dialogs/tools/dialogline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogline.cpp @@ -178,39 +178,31 @@ void DialogLine::SaveData() */ void DialogLine::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + switch (number) { - switch (number) - { - case 0: - if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) + { + number++; + if (vis != nullptr) { - number++; - if (vis != nullptr) - { - vis->VisualMode(id); - } + vis->VisualMode(id); } - break; - case 1: - if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) - { - if (SetObject(id, ui->comboBoxSecondPoint, QString())) - { - if (flagError) - { - number = 0; - prepare = true; - DialogAccepted(); - } - } - } - break; - default: - break; - } + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id && + SetObject(id, ui->comboBoxSecondPoint, QString()) && flagError) + { + number = 0; + prepare = true; + DialogAccepted(); + } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp index ffa3f40e8..0d1844519 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp @@ -108,82 +108,74 @@ DialogLineIntersect::~DialogLineIntersect() */ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + auto *line = qobject_cast(vis); + SCASSERT(line != nullptr) + + switch (number) { - auto *line = qobject_cast(vis); - SCASSERT(line != nullptr) - - switch (number) - { - case 0: - if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line"))) - { - number++; - line->VisualMode(id); - } - break; - case 1: - if (getCurrentObjectId(ui->comboBoxP1Line1) != id) - { - if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line"))) - { - number++; - line->SetLine1P2Id(id); - line->RefreshGeometry(); - } - } - break; - case 2: - if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line"))) - { - number++; - line->SetLine2P1Id(id); - line->RefreshGeometry(); - } - break; - case 3: + case 0: + if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line"))) { - QSet set; - set.insert(getCurrentObjectId(ui->comboBoxP1Line1)); - set.insert(getCurrentObjectId(ui->comboBoxP2Line1)); - set.insert(getCurrentObjectId(ui->comboBoxP1Line2)); - set.insert(id); - - if (set.size() >= 3) - { - if (SetObject(id, ui->comboBoxP2Line2, QString())) - { - line->SetLine2P2Id(id); - line->RefreshGeometry(); - prepare = true; - flagPoint = CheckIntersecion(); - CheckState(); - if (flagPoint) - { - DialogAccepted(); - } - else - { - this->setModal(true); - this->show(); - connect(ui->comboBoxP1Line1, QOverload::of(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::PointChanged); - connect(ui->comboBoxP2Line1, QOverload::of(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::PointChanged); - connect(ui->comboBoxP1Line2, QOverload::of(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::PointChanged); - connect(ui->comboBoxP2Line2, QOverload::of(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::PointChanged); - } - } - } + number++; + line->VisualMode(id); } break; - default: - break; + case 1: + if (getCurrentObjectId(ui->comboBoxP1Line1) != id && + SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line"))) + { + number++; + line->SetLine1P2Id(id); + line->RefreshGeometry(); + } + break; + case 2: + if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line"))) + { + number++; + line->SetLine2P1Id(id); + line->RefreshGeometry(); + } + break; + case 3: + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxP1Line1)); + set.insert(getCurrentObjectId(ui->comboBoxP2Line1)); + set.insert(getCurrentObjectId(ui->comboBoxP1Line2)); + set.insert(id); + + if (set.size() >= 3 && SetObject(id, ui->comboBoxP2Line2, QString())) + { + line->SetLine2P2Id(id); + line->RefreshGeometry(); + prepare = true; + flagPoint = CheckIntersecion(); + CheckState(); + if (flagPoint) + { + DialogAccepted(); + } + else + { + this->setModal(true); + this->show(); + connect(ui->comboBoxP1Line1, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::PointChanged); + connect(ui->comboBoxP2Line1, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::PointChanged); + connect(ui->comboBoxP1Line2, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::PointChanged); + connect(ui->comboBoxP2Line2, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::PointChanged); + } + } } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp index 90acd3771..21dc7dbf6 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp @@ -277,65 +277,57 @@ void DialogLineIntersectAxis::ShowDialog(bool click) //--------------------------------------------------------------------------------------------------------------------- void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + auto *line = qobject_cast(vis); + SCASSERT(line != nullptr) + + switch (number) { - auto *line = qobject_cast(vis); - SCASSERT(line != nullptr) - - switch (number) - { - case (0): - if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second point of line"))) - { - number++; - line->VisualMode(id); - auto *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(line, &VisToolLineIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - } - break; - case (1): - if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id) - { - if (SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point"))) - { - number++; - line->SetPoint2Id(id); - line->RefreshGeometry(); - } - } - break; - case (2): + case (0): + if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second point of line"))) { - QSet set; - set.insert(getCurrentObjectId(ui->comboBoxFirstLinePoint)); - set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint)); - set.insert(id); - - if (set.size() == 3) - { - if (SetObject(id, ui->comboBoxAxisPoint, QString())) - { - line->SetAxisPointId(id); - line->RefreshGeometry(); - prepare = true; - - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - vis->SetMode(Mode::Show); - emit ToolTip(QString()); - show(); - } - } - } + number++; + line->VisualMode(id); + auto *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(line, &VisToolLineIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip); } break; - default: - break; + case (1): + if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id && + SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point"))) + { + number++; + line->SetPoint2Id(id); + line->RefreshGeometry(); + } + break; + case (2): + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstLinePoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint)); + set.insert(id); + + if (set.size() == 3 && SetObject(id, ui->comboBoxAxisPoint, QString())) + { + line->SetAxisPointId(id); + line->RefreshGeometry(); + prepare = true; + + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) + { + vis->SetMode(Mode::Show); + emit ToolTip(QString()); + show(); + } + } } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp index b5ccac12b..72fb7f929 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.cpp +++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp @@ -402,20 +402,16 @@ void DialogMove::ShowDialog(bool click) //--------------------------------------------------------------------------------------------------------------------- void DialogMove::ChosenObject(quint32 id, const SceneObject &type) { - if (not stage1 && stage2 && prepare) // After first choose we ignore all objects + if (not stage1 && stage2 && prepare && type == SceneObject::Point && + QGuiApplication::keyboardModifiers() == Qt::ControlModifier && + SetObject(id, ui->comboBoxRotationOriginPoint, QString())) // After first choose we ignore all objects { - if (type == SceneObject::Point && QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - if (SetObject(id, ui->comboBoxRotationOriginPoint, QString())) - { - auto *operation = qobject_cast(vis); - SCASSERT(operation != nullptr) + auto *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) - operation->SetRotationOriginPointId(id); - operation->RefreshGeometry(); - optionalRotationOrigin = true; - } - } + operation->SetRotationOriginPointId(id); + operation->RefreshGeometry(); + optionalRotationOrigin = true; } } diff --git a/src/libs/vtools/dialogs/tools/dialognormal.cpp b/src/libs/vtools/dialogs/tools/dialognormal.cpp index fe839aaa1..093232e96 100644 --- a/src/libs/vtools/dialogs/tools/dialognormal.cpp +++ b/src/libs/vtools/dialogs/tools/dialognormal.cpp @@ -218,23 +218,21 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id && + SetObject(id, ui->comboBoxSecondPoint, QString())) { - if (SetObject(id, ui->comboBoxSecondPoint, QString())) + line->SetPoint2Id(id); + line->RefreshGeometry(); + prepare = true; + + auto *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) { - line->SetPoint2Id(id); - line->RefreshGeometry(); - prepare = true; - - auto *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } + FinishCreating(); } } break; diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp index ea20abdd9..af3435c68 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp @@ -145,41 +145,33 @@ void DialogPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint p) //--------------------------------------------------------------------------------------------------------------------- void DialogPointFromArcAndTangent::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && + (type == SceneObject::Point || type == SceneObject::Arc)) // After first choose we ignore all objects { - if (type == SceneObject::Point || type == SceneObject::Arc) - { - auto *point = qobject_cast(vis); - SCASSERT(point != nullptr) + auto *point = qobject_cast(vis); + SCASSERT(point != nullptr) - switch (number) - { - case 0: - if (type == SceneObject::Point) - { - if (SetObject(id, ui->comboBoxTangentPoint, tr("Select an arc"))) - { - number++; - point->VisualMode(id); - } - } - break; - case 1: - if (type == SceneObject::Arc) - { - if (SetObject(id, ui->comboBoxArc, QString())) - { - number = 0; - point->SetArcId(id); - point->RefreshGeometry(); - prepare = true; - DialogAccepted(); - } - } - break; - default: - break; - } + switch (number) + { + case 0: + if (type == SceneObject::Point && SetObject(id, ui->comboBoxTangentPoint, tr("Select an arc"))) + { + number++; + point->VisualMode(id); + } + break; + case 1: + if (type == SceneObject::Arc && SetObject(id, ui->comboBoxArc, QString())) + { + number = 0; + point->SetArcId(id); + point->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp index 287addb68..d424fb326 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp @@ -254,24 +254,22 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject } break; case 1: - if (getCurrentObjectId(ui->comboBoxTangentPoint) != id) + if (getCurrentObjectId(ui->comboBoxTangentPoint) != id && + SetObject(id, ui->comboBoxCircleCenter, QString())) { - if (SetObject(id, ui->comboBoxCircleCenter, QString())) + auto *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + + m_number = 0; + point->SetCenterId(id); + point->RefreshGeometry(); + prepare = true; + + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) { - auto *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - - m_number = 0; - point->SetCenterId(id); - point->RefreshGeometry(); - prepare = true; - - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } + FinishCreating(); } } break; diff --git a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp index ff1803fa0..c072670a0 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp @@ -244,14 +244,12 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id && + SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc"))) { - if (SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc"))) - { - m_number++; - line->SetLineP2Id(id); - line->RefreshGeometry(); - } + m_number++; + line->SetLineP2Id(id); + line->RefreshGeometry(); } break; case 2: @@ -261,23 +259,19 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type) set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); set.insert(id); - if (set.size() == 3) + if (set.size() == 3 && SetObject(id, ui->comboBoxCenter, QString())) { - if (SetObject(id, ui->comboBoxCenter, QString())) + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + + line->SetRadiusId(id); + line->RefreshGeometry(); + prepare = true; + + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) { - auto *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - - line->SetRadiusId(id); - line->RefreshGeometry(); - prepare = true; - - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } + FinishCreating(); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp index abbe84231..ba584b910 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp @@ -117,38 +117,33 @@ void DialogPointOfIntersection::SetSecondPointId(quint32 value) */ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) - { - auto *line = qobject_cast(vis); - SCASSERT(line != nullptr) + auto *line = qobject_cast(vis); + SCASSERT(line != nullptr) - switch (number) - { - case 0: - if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point for Y value (horizontal)"))) - { - number++; - line->SetPoint1Id(id); - line->RefreshGeometry(); - } - break; - case 1: - if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) - { - if (SetObject(id, ui->comboBoxSecondPoint, QString())) - { - line->SetPoint2Id(id); - line->RefreshGeometry(); - prepare = true; - DialogAccepted(); - } - } - break; - default: - break; - } + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point for Y value (horizontal)"))) + { + number++; + line->SetPoint1Id(id); + line->RefreshGeometry(); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id && + SetObject(id, ui->comboBoxSecondPoint, QString())) + { + line->SetPoint2Id(id); + line->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp index e58f02528..ed6801712 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp @@ -150,38 +150,32 @@ void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossCirclesPoint p) //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && type == SceneObject::Arc) // After first choose we ignore all objects { - if (type == SceneObject::Arc) - { - auto *point = qobject_cast(vis); - SCASSERT(point != nullptr) + auto *point = qobject_cast(vis); + SCASSERT(point != nullptr) - switch (number) - { - case 0: - if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc"))) - { - number++; - point->VisualMode(id); - } - break; - case 1: - if (getCurrentObjectId(ui->comboBoxArc1) != id) - { - if (SetObject(id, ui->comboBoxArc2, QString())) - { - number = 0; - point->SetArc2Id(id); - point->RefreshGeometry(); - prepare = true; - DialogAccepted(); - } - } - break; - default: - break; - } + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc"))) + { + number++; + point->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxArc1) != id && SetObject(id, ui->comboBoxArc2, QString())) + { + number = 0; + point->SetArc2Id(id); + point->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp index aef5d96bb..5d314323f 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp @@ -330,20 +330,18 @@ void DialogPointOfIntersectionCircles::ChosenObject(quint32 id, const SceneObjec } break; case 2: - if (getCurrentObjectId(ui->comboBoxCircle1Center) != id) + if (getCurrentObjectId(ui->comboBoxCircle1Center) != id && + SetObject(id, ui->comboBoxCircle2Center, QString())) { - if (SetObject(id, ui->comboBoxCircle2Center, QString())) - { - point->SetCircle2Id(id); - point->RefreshGeometry(); - ++m_stage; - prepare = true; + point->SetCircle2Id(id); + point->RefreshGeometry(); + ++m_stage; + prepare = true; - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - return; - } + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) + { + FinishCreating(); + return; } } break; diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp index d239f9903..a60b02898 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp @@ -178,39 +178,33 @@ void DialogPointOfIntersectionCurves::SetHCrossPoint(HCrossCurvesPoint hP) //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfIntersectionCurves::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc || + type == SceneObject::SplinePath)) // After first choose we ignore all objects { - if (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc || - type == SceneObject::SplinePath) - { - auto *point = qobject_cast(vis); - SCASSERT(point != nullptr) + auto *point = qobject_cast(vis); + SCASSERT(point != nullptr) - switch (number) - { - case 0: - if (SetObject(id, ui->comboBoxCurve1, tr("Select second curve"))) - { - number++; - point->VisualMode(id); - } - break; - case 1: - if (getCurrentObjectId(ui->comboBoxCurve1) != id) - { - if (SetObject(id, ui->comboBoxCurve2, QString())) - { - number = 0; - point->SetCurve2Id(id); - point->RefreshGeometry(); - prepare = true; - DialogAccepted(); - } - } - break; - default: - break; - } + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxCurve1, tr("Select second curve"))) + { + number++; + point->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxCurve1) != id && SetObject(id, ui->comboBoxCurve2, QString())) + { + number = 0; + point->SetCurve2Id(id); + point->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index 6de48f046..d58eaf6af 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -321,44 +321,41 @@ void DialogRotation::SetSourceObjects(const QVector &value) //--------------------------------------------------------------------------------------------------------------------- void DialogRotation::ChosenObject(quint32 id, const SceneObject &type) { - if (not stage1 && not prepare) // After first choose we ignore all objects + if (not stage1 && not prepare && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + 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; }); + + if (obj != sourceObjects.end()) { - 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; }); - - if (obj != sourceObjects.end()) + if (sourceObjects.size() > 1) { - if (sourceObjects.size() > 1) - { - // It's not really logical for a user that a center of rotation no need to select. - // To fix this issue we just silently remove it from the list. - sourceObjects.erase(obj); - operation->SetObjects(SourceToObjects(sourceObjects)); - } - else - { - emit ToolTip(tr("This point cannot be origin point. Please, select another origin point")); - return; - } + // It's not really logical for a user that a center of rotation no need to select. + // To fix this issue we just silently remove it from the list. + sourceObjects.erase(obj); + operation->SetObjects(SourceToObjects(sourceObjects)); } - - if (SetObject(id, ui->comboBoxOriginPoint, QString())) + else { - auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - connect(operation, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - - operation->SetOriginPointId(id); - operation->RefreshGeometry(); - - prepare = true; + emit ToolTip(tr("This point cannot be origin point. Please, select another origin point")); + return; } } + + if (SetObject(id, ui->comboBoxOriginPoint, QString())) + { + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + connect(operation, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + + operation->SetOriginPointId(id); + operation->RefreshGeometry(); + + prepare = true; + } } } diff --git a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp index d0fbb52d0..00ffa4f5a 100644 --- a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp @@ -212,14 +212,12 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (getCurrentObjectId(ui->comboBoxP3) != id) + if (getCurrentObjectId(ui->comboBoxP3) != id && + SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) { - if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) - { - m_number++; - line->SetLineP1Id(id); - line->RefreshGeometry(); - } + m_number++; + line->SetLineP1Id(id); + line->RefreshGeometry(); } break; case 2: @@ -281,25 +279,22 @@ void DialogShoulderPoint::ChosenThirdPoint(quint32 id) set.insert(getCurrentObjectId(ui->comboBoxP1Line)); set.insert(id); - if (set.size() == 3) + if (set.size() == 3 && SetObject(id, ui->comboBoxP2Line, QString())) { - if (SetObject(id, ui->comboBoxP2Line, QString())) + auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + SCASSERT(window != nullptr) + + auto *line = qobject_cast(vis); + SCASSERT(line != nullptr) + connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); + + line->SetLineP2Id(id); + line->RefreshGeometry(); + prepare = true; + + if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) { - auto *window = qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); - SCASSERT(window != nullptr) - - auto *line = qobject_cast(vis); - SCASSERT(line != nullptr) - connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - - line->SetLineP2Id(id); - line->RefreshGeometry(); - prepare = true; - - if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) - { - FinishCreating(); - } + FinishCreating(); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogspline.cpp b/src/libs/vtools/dialogs/tools/dialogspline.cpp index 9339e7e2f..177d8d254 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogspline.cpp @@ -159,40 +159,34 @@ DialogSpline::~DialogSpline() */ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) { - if (!prepare) // After first choose we ignore all objects + if (!prepare && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + auto *path = qobject_cast(vis); + SCASSERT(path != nullptr) + + switch (number) { - auto *path = qobject_cast(vis); - SCASSERT(path != nullptr) - - switch (number) - { - case 0: - if (SetObject(id, ui->comboBoxP1, tr("Select last point of curve"))) - { - ++number; - path->VisualMode(id); - } - break; - case 1: + case 0: + if (SetObject(id, ui->comboBoxP1, tr("Select last point of curve"))) { - if (getCurrentObjectId(ui->comboBoxP1) != id) - { - if (SetObject(id, ui->comboBoxP4, QString())) - { - ++number; - - path->SetPoint4Id(id); - path->RefreshGeometry(); - prepare = true; - } - } - break; + ++number; + path->VisualMode(id); } - default: - break; + break; + case 1: + { + if (getCurrentObjectId(ui->comboBoxP1) != id && SetObject(id, ui->comboBoxP4, QString())) + { + ++number; + + path->SetPoint4Id(id); + path->RefreshGeometry(); + prepare = true; + } + break; } + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index e828a3176..be6654674 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -207,12 +207,9 @@ void DialogTool::FillComboBoxSplines(QComboBox *box) const QMap list; for (i = objs->constBegin(); i != objs->constEnd(); ++i) { - if (i.key() != toolId) + if (i.key() != toolId && IsSpline(i.value())) { - if (IsSpline(i.value())) - { - PrepareList(list, i.key()); - } + PrepareList(list, i.key()); } } FillList(box, list); @@ -231,12 +228,9 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const QMap list; for (i = objs->constBegin(); i != objs->constEnd(); ++i) { - if (i.key() != toolId) + if (i.key() != toolId && IsSplinePath(i.value())) { - if (IsSplinePath(i.value())) - { - PrepareList(list, i.key()); - } + PrepareList(list, i.key()); } } FillList(box, list); diff --git a/src/libs/vtools/dialogs/tools/dialogtriangle.cpp b/src/libs/vtools/dialogs/tools/dialogtriangle.cpp index 486b205b3..f66b8ffb4 100644 --- a/src/libs/vtools/dialogs/tools/dialogtriangle.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtriangle.cpp @@ -99,74 +99,63 @@ DialogTriangle::~DialogTriangle() */ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + auto *line = qobject_cast(vis); + SCASSERT(line != nullptr) + + switch (number) { - auto *line = qobject_cast(vis); - SCASSERT(line != nullptr) - - switch (number) + case (0): + if (SetObject(id, ui->comboBoxAxisP1, tr("Select second point of axis"))) + { + number++; + line->VisualMode(id); + } + break; + case (1): + if (getCurrentObjectId(ui->comboBoxAxisP1) != id && + SetObject(id, ui->comboBoxAxisP2, tr("Select first point"))) + { + number++; + line->SetObject2Id(id); + line->RefreshGeometry(); + } + break; + case (2): { - case (0): - if (SetObject(id, ui->comboBoxAxisP1, tr("Select second point of axis"))) - { - number++; - line->VisualMode(id); - } - break; - case (1): - if (getCurrentObjectId(ui->comboBoxAxisP1) != id) - { - if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point"))) - { - number++; - line->SetObject2Id(id); - line->RefreshGeometry(); - } - } - break; - case (2): - { - QSet set; - set.insert(getCurrentObjectId(ui->comboBoxAxisP1)); - set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); - set.insert(id); + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxAxisP1)); + set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); + set.insert(id); - if (set.size() == 3) - { - if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) - { - number++; - line->SetHypotenuseP1Id(id); - line->RefreshGeometry(); - } - } - } - break; - case (3): + if (set.size() == 3 && SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) { - QSet set; - set.insert(getCurrentObjectId(ui->comboBoxAxisP1)); - set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); - set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); - set.insert(id); - - if (set.size() == 4) - { - if (SetObject(id, ui->comboBoxSecondPoint, QString())) - { - line->SetHypotenuseP2Id(id); - line->RefreshGeometry(); - prepare = true; - DialogAccepted(); - } - } + number++; + line->SetHypotenuseP1Id(id); + line->RefreshGeometry(); } - break; - default: - break; } + break; + case (3): + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxAxisP1)); + set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(id); + + if (set.size() == 4 && SetObject(id, ui->comboBoxSecondPoint, QString())) + { + line->SetHypotenuseP2Id(id); + line->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + } + break; + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp b/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp index c973c580a..7778bfed5 100644 --- a/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp @@ -217,94 +217,80 @@ void DialogTrueDarts::SetChildrenId(const quint32 &ch1, const quint32 &ch2) //--------------------------------------------------------------------------------------------------------------------- void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects { - if (type == SceneObject::Point) + auto *points = qobject_cast(vis); + SCASSERT(points != nullptr) + + switch (number) { - auto *points = qobject_cast(vis); - SCASSERT(points != nullptr) - - switch (number) + case 0: + if (SetObject(id, ui->comboBoxFirstBasePoint, tr("Select the second base point"))) + { + number++; + points->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxFirstBasePoint) != id && + SetObject(id, ui->comboBoxSecondBasePoint, tr("Select the first dart point"))) + { + number++; + points->SetBaseLineP2Id(id); + points->RefreshGeometry(); + } + break; + case 2: { - case 0: - if (SetObject(id, ui->comboBoxFirstBasePoint, tr("Select the second base point"))) - { - number++; - points->VisualMode(id); - } - break; - case 1: - if (getCurrentObjectId(ui->comboBoxFirstBasePoint) != id) - { - if (SetObject(id, ui->comboBoxSecondBasePoint, tr("Select the first dart point"))) - { - number++; - points->SetBaseLineP2Id(id); - points->RefreshGeometry(); - } - } - break; - case 2: - { - QSet set; - set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint)); - set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint)); - set.insert(id); + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint)); + set.insert(id); - if (set.size() == 3) - { - if (SetObject(id, ui->comboBoxFirstDartPoint, tr("Select the second dart point"))) - { - number++; - points->SetD1PointId(id); - points->RefreshGeometry(); - } - } - break; - } - case 3: + if (set.size() == 3 && SetObject(id, ui->comboBoxFirstDartPoint, tr("Select the second dart point"))) { - QSet set; - set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint)); - set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint)); - set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint)); - set.insert(id); - - if (set.size() == 4) - { - if (SetObject(id, ui->comboBoxSecondDartPoint, tr("Select the third dart point"))) - { - number++; - points->SetD2PointId(id); - points->RefreshGeometry(); - } - } - break; + number++; + points->SetD1PointId(id); + points->RefreshGeometry(); } - case 4: - { - QSet set; - set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint)); - set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint)); - set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint)); - set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint)); - set.insert(id); - - if (set.size() == 5) - { - if (SetObject(id, ui->comboBoxThirdDartPoint, QString())) - { - points->SetD3PointId(id); - points->RefreshGeometry(); - prepare = true; - DialogAccepted(); - } - } - break; - } - default: - break; + break; } + case 3: + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint)); + set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint)); + set.insert(id); + + if (set.size() == 4 && SetObject(id, ui->comboBoxSecondDartPoint, tr("Select the third dart point"))) + { + number++; + points->SetD2PointId(id); + points->RefreshGeometry(); + } + break; + } + case 4: + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint)); + set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint)); + set.insert(id); + + if (set.size() == 5 && SetObject(id, ui->comboBoxThirdDartPoint, QString())) + { + points->SetD3PointId(id); + points->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + break; + } + default: + break; } } } diff --git a/src/libs/vtools/dialogs/tools/dialoguniondetails.cpp b/src/libs/vtools/dialogs/tools/dialoguniondetails.cpp index 359cfee82..8620fb159 100644 --- a/src/libs/vtools/dialogs/tools/dialoguniondetails.cpp +++ b/src/libs/vtools/dialogs/tools/dialoguniondetails.cpp @@ -133,20 +133,17 @@ auto DialogUnionDetails::CheckDetail(const quint32 &idDetail) const -> bool */ void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail, vsizetype &index) { - if (idDetail == NULL_ID) + if (idDetail == NULL_ID && type == SceneObject::Detail) { - if (type == SceneObject::Detail) + if (CheckDetail(id)) { - if (CheckDetail(id)) - { - idDetail = id; - emit ToolTip(tr("Select a first point")); - return; - } - - emit ToolTip(tr("Workpiece should have at least two points and three objects")); + idDetail = id; + emit ToolTip(tr("Select a first point")); return; } + + emit ToolTip(tr("Workpiece should have at least two points and three objects")); + return; } if (not CheckObject(id, idDetail)) diff --git a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp index f17720ed6..0e39bdf05 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp @@ -55,50 +55,44 @@ DialogDuplicateDetail::~DialogDuplicateDetail() //--------------------------------------------------------------------------------------------------------------------- void DialogDuplicateDetail::ShowDialog(bool click) { - if (prepare) + if (prepare && click) { - if (click) + // The check need to ignore first release of mouse button. + // User should have chance to place piece. + if (not m_firstRelease) { - // The check need to ignore first release of mouse button. - // User should have chance to place piece. - if (not m_firstRelease) - { - m_firstRelease = true; - return; - } - - auto *piece = qobject_cast(vis); - SCASSERT(piece != nullptr) - - m_mx = piece->Mx(); - m_my = piece->My(); - emit ToolTip(QString()); - DialogAccepted(); + m_firstRelease = true; + return; } + + auto *piece = qobject_cast(vis); + SCASSERT(piece != nullptr) + + m_mx = piece->Mx(); + m_my = piece->My(); + emit ToolTip(QString()); + DialogAccepted(); } } //--------------------------------------------------------------------------------------------------------------------- void DialogDuplicateDetail::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false) // After first choose we ignore all objects + if (prepare == false && type == SceneObject::Detail && id > NULL_ID) // After first choose we ignore all objects { - if (type == SceneObject::Detail && id > NULL_ID) + m_idDetail = id; + + auto *tool = qobject_cast(VAbstractPattern::getTool(m_idDetail)); + if (tool) { - m_idDetail = id; - - auto *tool = qobject_cast(VAbstractPattern::getTool(m_idDetail)); - if (tool) - { - vis->SetData(tool->getData()); // Includes currentSeamAllowance variable we need - } - - emit ToolTip(tr("Click to place duplicate")); - if (vis != nullptr) - { - vis->VisualMode(id); - } - prepare = true; + vis->SetData(tool->getData()); // Includes currentSeamAllowance variable we need } + + emit ToolTip(tr("Click to place duplicate")); + if (vis != nullptr) + { + vis->VisualMode(id); + } + prepare = true; } } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp index 56b43e1ec..c2d29ef41 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp @@ -211,23 +211,20 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type) //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::ShowDialog(bool click) { - if (not click) + if (not click && CreatePath().CountNodes() > 0) { - if (CreatePath().CountNodes() > 0) - { - emit ToolTip(QString()); - prepare = true; + emit ToolTip(QString()); + prepare = true; - if (not m_showMode) - { - auto *visPath = qobject_cast(vis); - SCASSERT(visPath != nullptr); - visPath->SetMode(Mode::Show); - visPath->RefreshGeometry(); - } - setModal(true); - show(); + if (not m_showMode) + { + auto *visPath = qobject_cast(vis); + SCASSERT(visPath != nullptr); + visPath->SetMode(Mode::Show); + visPath->RefreshGeometry(); } + setModal(true); + show(); } } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp index 4733c41ef..e7e3e858f 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp @@ -122,22 +122,16 @@ void DialogPin::SetPiecesList(const QVector &list) //--------------------------------------------------------------------------------------------------------------------- void DialogPin::ChosenObject(quint32 id, const SceneObject &type) { - if (not prepare) + if (not prepare && type == SceneObject::Point && SetObject(id, ui->comboBoxPoint, QString())) { - if (type == SceneObject::Point) + if (vis != nullptr) { - if (SetObject(id, ui->comboBoxPoint, QString())) - { - if (vis != nullptr) - { - vis->VisualMode(id); - } - CheckPoint(); - prepare = true; - this->setModal(true); - this->show(); - } + vis->VisualMode(id); } + CheckPoint(); + prepare = true; + this->setModal(true); + this->show(); } } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp index 8fa656083..508a6db4d 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp @@ -244,27 +244,21 @@ void DialogPlaceLabel::SetPiecesList(const QVector &list) //--------------------------------------------------------------------------------------------------------------------- void DialogPlaceLabel::ChosenObject(quint32 id, const SceneObject &type) { - if (not prepare) + if (not prepare && type == SceneObject::Point && SetObject(id, ui->comboBoxPoint, QString())) { - if (type == SceneObject::Point) + if (vis != nullptr) { - if (SetObject(id, ui->comboBoxPoint, QString())) - { - if (vis != nullptr) - { - vis->VisualMode(id); - } - CheckPoint(); - prepare = true; - - timerWidth->setSingleShot(formulaTimerTimeout.count()); - timerHeight->setSingleShot(formulaTimerTimeout.count()); - timerAngle->setSingleShot(formulaTimerTimeout.count()); - - this->setModal(true); - this->show(); - } + vis->VisualMode(id); } + CheckPoint(); + prepare = true; + + timerWidth->setSingleShot(formulaTimerTimeout.count()); + timerHeight->setSingleShot(formulaTimerTimeout.count()); + timerAngle->setSingleShot(formulaTimerTimeout.count()); + + this->setModal(true); + this->show(); } } diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.cpp b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.cpp index cd30afce7..aba1fca48 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.cpp +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.cpp @@ -312,12 +312,10 @@ void VBackgroundImageItem::mousePressEvent(QGraphicsSceneMouseEvent *event) if (not Image().Hold()) { - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) - { - SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); - } + SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); } if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) @@ -589,12 +587,9 @@ void VBackgroundImageItem::MakeFresh() const //--------------------------------------------------------------------------------------------------------------------- void VBackgroundImageItem::DeleteToolWithConfirm(bool ask) { - if (ask) + if (ask && ConfirmDeletion() == QMessageBox::No) { - if (ConfirmDeletion() == QMessageBox::No) - { - return; - } + return; } emit ActivateControls(QUuid()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 749f178eb..5cc162c83 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -388,17 +388,12 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer &obj) //--------------------------------------------------------------------------------------------------------------------- void VToolSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick && IsMovable()) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) - { - if (IsMovable()) - { - SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); - oldPosition = event->scenePos(); - event->accept(); - } - } + SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); + oldPosition = event->scenePos(); + event->accept(); } VAbstractSpline::mousePressEvent(event); } @@ -406,17 +401,12 @@ void VToolSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick && IsMovable()) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) - { - if (IsMovable()) - { - SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); + SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); - CurveReleased(); - } - } + CurveReleased(); } VAbstractSpline::mouseReleaseEvent(event); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index b2f85b464..6852eb09f 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -594,18 +594,16 @@ void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer &ob //--------------------------------------------------------------------------------------------------------------------- void VToolSplinePath::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + oldPosition = event->scenePos(); + const auto splPath = VAbstractTool::data.GeometricObject(m_id); + splIndex = splPath->Segment(oldPosition); + if (IsMovable(splIndex)) { - oldPosition = event->scenePos(); - const auto splPath = VAbstractTool::data.GeometricObject(m_id); - splIndex = splPath->Segment(oldPosition); - if (IsMovable(splIndex)) - { - SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); - event->accept(); - } + SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); + event->accept(); } } VAbstractSpline::mousePressEvent(event); @@ -614,15 +612,13 @@ void VToolSplinePath::mousePressEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) - { - oldPosition = event->scenePos(); - SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); + oldPosition = event->scenePos(); + SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); - CurveReleased(); - } + CurveReleased(); } VAbstractSpline::mouseReleaseEvent(event); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index cd4420773..40dba6d7b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -295,13 +295,11 @@ void VToolBasePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolBasePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) - { - SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); - event->accept(); - } + SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); + event->accept(); } VToolSinglePoint::mousePressEvent(event); } @@ -309,12 +307,10 @@ void VToolBasePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolBasePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) - { - SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); - } + SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } VToolSinglePoint::mouseReleaseEvent(event); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index 4d7d34467..47aba7dfc 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -242,12 +242,9 @@ void VToolSinglePoint::FullUpdateFromFile() */ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if (selectionType == SelectionType::ByMouseRelease) + if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event)) { - if (IsSelectedByReleaseEvent(this, event)) - { - PointChoosed(); - } + PointChoosed(); } VScenePoint::mouseReleaseEvent(event); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 95fe3e250..0360277e8 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -965,27 +965,18 @@ void VToolSeamAllowance::ResetChildren(QGraphicsItem *pItem) const bool selected = isSelected(); const VPiece detail = VAbstractTool::data.GetPiece(m_id); auto *pVGI = qgraphicsitem_cast(pItem); - if (pVGI != m_dataLabel) + if (pVGI != m_dataLabel && detail.GetPieceLabelData().IsVisible()) { - if (detail.GetPieceLabelData().IsVisible()) - { - m_dataLabel->Reset(); - } + m_dataLabel->Reset(); } - if (pVGI != m_patternInfo) + if (pVGI != m_patternInfo && detail.GetPatternLabelData().IsVisible()) { - if (detail.GetPatternLabelData().IsVisible()) - { - m_patternInfo->Reset(); - } + m_patternInfo->Reset(); } auto *pGLI = qgraphicsitem_cast(pItem); - if (pGLI != m_grainLine) + if (pGLI != m_grainLine && detail.GetGrainlineGeometry().IsVisible()) { - if (detail.GetGrainlineGeometry().IsVisible()) - { - m_grainLine->Reset(); - } + m_grainLine->Reset(); } setSelected(selected); @@ -1456,12 +1447,10 @@ void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event) scene()->clearSelection(); } - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) - { - SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); - } + SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); } if (selectionType == SelectionType::ByMouseRelease) @@ -1488,13 +1477,10 @@ void VToolSeamAllowance::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } - if (selectionType == SelectionType::ByMouseRelease) + if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event)) { - if (IsSelectedByReleaseEvent(this, event)) - { - doc->SelectedDetail(m_id); - emit ChoosedTool(m_id, SceneObject::Detail); - } + doc->SelectedDetail(m_id); + emit ChoosedTool(m_id, SceneObject::Detail); } QGraphicsPathItem::mouseReleaseEvent(event); } @@ -2433,12 +2419,9 @@ void VToolSeamAllowance::InitSpecialPoints(const QVector &points) const void VToolSeamAllowance::DeleteToolWithConfirm(bool ask) { std::unique_ptr delDet(new DeletePiece(doc, m_id, VAbstractTool::data, m_sceneDetails)); - if (ask) + if (ask && ConfirmDeletion() == QMessageBox::No) { - if (ConfirmDeletion() == QMessageBox::No) - { - return; - } + return; } VAbstractApplication::VApp()->getUndoStack()->push(delDet.release()); diff --git a/src/libs/vwidgets/fancytabbar/fancytabbar.cpp b/src/libs/vwidgets/fancytabbar/fancytabbar.cpp index 75b7c5460..a567cd611 100644 --- a/src/libs/vwidgets/fancytabbar/fancytabbar.cpp +++ b/src/libs/vwidgets/fancytabbar/fancytabbar.cpp @@ -316,16 +316,13 @@ void FancyTabBar::mouseMoveEvent(QMouseEvent *e) //--------------------------------------------------------------------------------------------------------------------- auto FancyTabBar::event(QEvent *event) -> bool { - if (event->type() == QEvent::ToolTip) + if (event->type() == QEvent::ToolTip && ValidIndex(m_hoverIndex)) { - if (ValidIndex(m_hoverIndex)) + QString const tt = TabToolTip(m_hoverIndex); + if (!tt.isEmpty()) { - QString const tt = TabToolTip(m_hoverIndex); - if (!tt.isEmpty()) - { - QToolTip::showText(static_cast(event)->globalPos(), tt, this); - return true; - } + QToolTip::showText(static_cast(event)->globalPos(), tt, this); + return true; } } return QWidget::event(event); diff --git a/src/libs/vwidgets/qtcolorpicker.cpp b/src/libs/vwidgets/qtcolorpicker.cpp index e077ae83c..3b7c3fb28 100644 --- a/src/libs/vwidgets/qtcolorpicker.cpp +++ b/src/libs/vwidgets/qtcolorpicker.cpp @@ -925,14 +925,11 @@ void ColorPickerPopup::showEvent(QShowEvent *) for (int j = 0; j < grid->rowCount(); ++j) { QWidget *w = widgetAt[j][i]; - if (w && w->inherits("ColorPickerItem")) + if (w && w->inherits("ColorPickerItem") && static_cast(w)->isSelected()) { - if (static_cast(w)->isSelected()) - { - w->setFocus(); - foundSelected = true; - break; - } + w->setFocus(); + foundSelected = true; + break; } } } diff --git a/src/libs/vwidgets/vcontrolpointspline.cpp b/src/libs/vwidgets/vcontrolpointspline.cpp index 51c38814f..2e187bc3e 100644 --- a/src/libs/vwidgets/vcontrolpointspline.cpp +++ b/src/libs/vwidgets/vcontrolpointspline.cpp @@ -209,13 +209,11 @@ void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick && + (freeAngle || freeLength)) { - if (freeAngle || freeLength) - { - SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); - emit Released(); - } + SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); + emit Released(); } VScenePoint::mouseReleaseEvent(event); } diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index c2fc6858a..1d1c4893d 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -290,13 +290,11 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) scene()->clearSelection(); } - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) - { - SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); - event->accept(); - } + SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); + event->accept(); } if (selectionType == SelectionType::ByMouseRelease) { @@ -315,12 +313,10 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if (flags() & QGraphicsItem::ItemIsMovable) + if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton && + event->type() != QEvent::GraphicsSceneMouseDoubleClick) { - if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) - { - SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); - } + SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event)) diff --git a/src/test/TranslationsTest/tst_abstractregexp.cpp b/src/test/TranslationsTest/tst_abstractregexp.cpp index e5861463c..b9504d8c5 100644 --- a/src/test/TranslationsTest/tst_abstractregexp.cpp +++ b/src/test/TranslationsTest/tst_abstractregexp.cpp @@ -162,14 +162,11 @@ void TST_AbstractRegExp::CallTestCheckNoOriginalNamesInTranslation() static const auto names = ConvertToSet(originalNames); const QString translated = m_trMs->VarToUser(originalName); - if (names.contains(translated)) + if (names.contains(translated) && originalName != translated) { - if (originalName != translated) - { - const QString message = u"Translation repeat original name from other place. " - "Original name:'%1', translated name:'%2'"_s.arg(originalName, translated); - QFAIL(qUtf8Printable(message)); - } + const QString message = u"Translation repeat original name from other place. " + "Original name:'%1', translated name:'%2'"_s.arg(originalName, translated); + QFAIL(qUtf8Printable(message)); } } diff --git a/src/test/TranslationsTest/tst_tslocaletranslation.cpp b/src/test/TranslationsTest/tst_tslocaletranslation.cpp index b08b4fb1f..e5746b755 100644 --- a/src/test/TranslationsTest/tst_tslocaletranslation.cpp +++ b/src/test/TranslationsTest/tst_tslocaletranslation.cpp @@ -324,15 +324,12 @@ void TST_TSLocaleTranslation::TestHTMLTags() for (const auto ®ex : regexes) { - if (source.contains(regex.first)) + if (source.contains(regex.first) && + (not translation.contains(regex.second) || translation.count(regex.second) != source.count(regex.first))) { - if (not translation.contains(regex.second) || translation.count(regex.second) != source.count(regex.first)) - { - const QString message = u"Tag mismatch. Pattern: '<%1>'. "_s.arg(regex.first.pattern()) + - u"Original name:'%1'"_s.arg(source) + - u", translated name:'%1'"_s.arg(translation); - QFAIL(qUtf8Printable(message)); - } + const QString message = u"Tag mismatch. Pattern: '<%1>'. "_s.arg(regex.first.pattern()) + + u"Original name:'%1'"_s.arg(source) + u", translated name:'%1'"_s.arg(translation); + QFAIL(qUtf8Printable(message)); } } }