From a6a8ef29b0865084cfd8230bd9d1c8765e6d2dda Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 21 Dec 2016 21:35:07 +0200 Subject: [PATCH] Refactoring. Merge similar switch cases together. --HG-- branch : develop --- .../valentina/dialogs/dialoglayoutsettings.cpp | 2 -- src/app/valentina/mainwindowsnogui.cpp | 3 +-- src/app/valentina/xml/vpattern.cpp | 6 +----- src/libs/vdxf/dxflib/dl_dxf.cpp | 17 ++--------------- src/libs/vdxf/vdxfengine.cpp | 9 +-------- src/libs/vdxf/vdxfpaintdevice.cpp | 7 ++----- src/libs/vobj/vobjpaintdevice.cpp | 7 ++----- .../vpropertyexplorer/vpropertyformwidget.cpp | 7 +------ src/libs/vtools/tools/vabstracttool.cpp | 14 ++------------ src/libs/vtools/visualization/line/visline.cpp | 3 +-- 10 files changed, 13 insertions(+), 62 deletions(-) diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index eae894f50..39aa59c71 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -224,8 +224,6 @@ void DialogLayoutSettings::SetGroup(const Cases &value) ui->radioButtonTwoGroups->setChecked(true); break; case Cases::CaseDesc: - ui->radioButtonDescendingArea->setChecked(true); - break; default: ui->radioButtonDescendingArea->setChecked(true); break; diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index cd6d7c46d..b2c369fd4 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -174,11 +174,10 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state) case LayoutErrors::PrepareLayoutError: qCritical() << tr("Couldn't prepare data for creation layout"); break; - case LayoutErrors::ProcessStoped: - break; case LayoutErrors::EmptyPaperError: qCritical() << tr("Several workpieces left not arranged, but none of them match for paper"); break; + case LayoutErrors::ProcessStoped: default: break; } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 7f4e79e9d..ad5eb8c61 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -990,11 +990,6 @@ QString VPattern::GetLabelBase(quint32 index) const alphabet = al.split(","); break; } - case 1: // en - { - alphabet = def.split(","); - break; - } case 2: // fr { const QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); @@ -1031,6 +1026,7 @@ QString VPattern::GetLabelBase(quint32 index) const alphabet = al.split(","); break; } + case 1: // en default: // en { alphabet = def.split(","); diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index 01ed1b1f4..80ff93356 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -1578,12 +1578,7 @@ bool DL_Dxf::handleXData(DL_CreationInterface* creationInterface) creationInterface->addXDataReal(static_cast(groupCode), toReal(groupValue)); return true; } - else if (groupCode>=1060 && groupCode<=1070) - { - creationInterface->addXDataInt(static_cast(groupCode), toInt(groupValue)); - return true; - } - else if (groupCode==1071) + else if (groupCode>=1060 && groupCode<=1071) { creationInterface->addXDataInt(static_cast(groupCode), toInt(groupValue)); return true; @@ -2600,7 +2595,6 @@ void DL_Dxf::writeHeader(DL_WriterA& dw) const break; case DL_Codes::AC1009_MIN: // minimalistic DXF version is unidentified in file: - break; default: break; } @@ -4231,14 +4225,7 @@ void DL_Dxf::writeLinetype(DL_WriterA& dw, dw.dxfString(2, data.name); dw.dxfInt(70, data.flags); - if (nameUpper=="BYBLOCK") - { - dw.dxfString(3, ""); - dw.dxfInt(72, 65); - dw.dxfInt(73, 0); - dw.dxfReal(40, 0.0); - } - else if (nameUpper=="BYLAYER") + if (nameUpper=="BYBLOCK" || nameUpper=="BYLAYER") { dw.dxfString(3, ""); dw.dxfInt(72, 65); diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index c16932982..2ba90f46e 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -479,24 +479,17 @@ std::string VDxfEngine::getPenStyle() { switch (state->pen().style()) { - case Qt::SolidLine: - return "BYLAYER"; - break; case Qt::DashLine: return "DASHED"; - break; case Qt::DotLine: return "DOT"; - break; case Qt::DashDotLine: return "DASHDOT"; - break; case Qt::DashDotDotLine: return "DIVIDE"; - break; + case Qt::SolidLine: default: return "BYLAYER"; - break; } } diff --git a/src/libs/vdxf/vdxfpaintdevice.cpp b/src/libs/vdxf/vdxfpaintdevice.cpp index 80fcacc49..35b7bd714 100644 --- a/src/libs/vdxf/vdxfpaintdevice.cpp +++ b/src/libs/vdxf/vdxfpaintdevice.cpp @@ -126,10 +126,6 @@ int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const return engine->getSize().width(); case QPaintDevice::PdmHeight: return engine->getSize().height(); - case QPaintDevice::PdmDpiX: - return static_cast(engine->getResolution()); - case QPaintDevice::PdmDpiY: - return static_cast(engine->getResolution()); case QPaintDevice::PdmHeightMM: return qRound(engine->getSize().height() * 25.4 / engine->getResolution()); case QPaintDevice::PdmWidthMM: @@ -137,8 +133,9 @@ int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const case QPaintDevice::PdmNumColors: return static_cast(0xffffffff); case QPaintDevice::PdmPhysicalDpiX: - return static_cast(engine->getResolution()); case QPaintDevice::PdmPhysicalDpiY: + case QPaintDevice::PdmDpiX: + case QPaintDevice::PdmDpiY: return static_cast(engine->getResolution()); #if QT_VERSION > QT_VERSION_CHECK(5, 0, 2) case QPaintDevice::PdmDevicePixelRatio: diff --git a/src/libs/vobj/vobjpaintdevice.cpp b/src/libs/vobj/vobjpaintdevice.cpp index e1f42a50e..418a01619 100644 --- a/src/libs/vobj/vobjpaintdevice.cpp +++ b/src/libs/vobj/vobjpaintdevice.cpp @@ -147,18 +147,15 @@ int VObjPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const return engine->getSize().width(); case QPaintDevice::PdmHeight: return engine->getSize().height(); - case QPaintDevice::PdmDpiX: - return engine->getResolution(); - case QPaintDevice::PdmDpiY: - return engine->getResolution(); case QPaintDevice::PdmHeightMM: return qRound(engine->getSize().height() * 25.4 / engine->getResolution()); case QPaintDevice::PdmWidthMM: return qRound(engine->getSize().width() * 25.4 / engine->getResolution()); case QPaintDevice::PdmNumColors: return static_cast(0xffffffff); + case QPaintDevice::PdmDpiX: + case QPaintDevice::PdmDpiY: case QPaintDevice::PdmPhysicalDpiX: - return engine->getResolution(); case QPaintDevice::PdmPhysicalDpiY: return engine->getResolution(); #if QT_VERSION > QT_VERSION_CHECK(5, 0, 2) diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp index f694737e8..b674fe167 100644 --- a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp @@ -228,7 +228,7 @@ void VPE::VPropertyFormWidget::commitData(int row) if (oldValue != newValue) { VProperty *parent = tmpProperty->getParent(); - if (parent == nullptr) + if (parent == nullptr || parent->propertyType() != Property::Complex) { tmpProperty->setValue(newValue); emit propertyDataSubmitted(tmpProperty); @@ -238,11 +238,6 @@ void VPE::VPropertyFormWidget::commitData(int row) tmpProperty->UpdateParent(newValue); emit propertyDataSubmitted(parent); } - else - { - tmpProperty->setValue(newValue); - emit propertyDataSubmitted(tmpProperty); - } } } } diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index e77c516e5..f15c3232b 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -174,25 +174,17 @@ Qt::PenStyle VAbstractTool::LineStyleToPenStyle(const QString &typeLine) { case 0: // TypeLineNone return Qt::NoPen; - break; - case 1: // TypeLineLine - return Qt::SolidLine; - break; case 2: // TypeLineDashLine return Qt::DashLine; - break; case 3: // TypeLineDotLine return Qt::DotLine; - break; case 4: // TypeLineDashDotLine return Qt::DashDotLine; - break; case 5: // TypeLineDashDotDotLine return Qt::DashDotDotLine; - break; + case 1: // TypeLineLine default: return Qt::SolidLine; - break; } } @@ -243,9 +235,6 @@ QMap VAbstractTool::ColorsList() QString name; switch (i) { - case 0: // ColorBlack - name = tr("black"); - break; case 1: // ColorGreen name = tr("green"); break; @@ -294,6 +283,7 @@ QMap VAbstractTool::ColorsList() case 16: // ColorCornFlowerBlue name = tr("corn flower blue"); break; + case 0: // ColorBlack default: name = tr("black"); break; diff --git a/src/libs/vtools/visualization/line/visline.cpp b/src/libs/vtools/visualization/line/visline.cpp index 1bb8e1b68..d66e1d9d9 100644 --- a/src/libs/vtools/visualization/line/visline.cpp +++ b/src/libs/vtools/visualization/line/visline.cpp @@ -64,8 +64,6 @@ qreal VisLine::CorrectAngle(const qreal &angle) switch (qFloor((qAbs(ang)+22.5)/45)) { - case 0: // <22.5 - return 0; case 1: // <67.5 return 45; case 2: // <112.5 @@ -80,6 +78,7 @@ qreal VisLine::CorrectAngle(const qreal &angle) return 270; case 7: // <337.5 return 315; + case 0: // <22.5 default: // <360 return 0; }