Refactoring. Merge similar switch cases together.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-12-21 21:35:07 +02:00
parent 731eb9ec89
commit a6a8ef29b0
10 changed files with 13 additions and 62 deletions

View File

@ -224,8 +224,6 @@ void DialogLayoutSettings::SetGroup(const Cases &value)
ui->radioButtonTwoGroups->setChecked(true); ui->radioButtonTwoGroups->setChecked(true);
break; break;
case Cases::CaseDesc: case Cases::CaseDesc:
ui->radioButtonDescendingArea->setChecked(true);
break;
default: default:
ui->radioButtonDescendingArea->setChecked(true); ui->radioButtonDescendingArea->setChecked(true);
break; break;

View File

@ -174,11 +174,10 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
case LayoutErrors::PrepareLayoutError: case LayoutErrors::PrepareLayoutError:
qCritical() << tr("Couldn't prepare data for creation layout"); qCritical() << tr("Couldn't prepare data for creation layout");
break; break;
case LayoutErrors::ProcessStoped:
break;
case LayoutErrors::EmptyPaperError: case LayoutErrors::EmptyPaperError:
qCritical() << tr("Several workpieces left not arranged, but none of them match for paper"); qCritical() << tr("Several workpieces left not arranged, but none of them match for paper");
break; break;
case LayoutErrors::ProcessStoped:
default: default:
break; break;
} }

View File

@ -990,11 +990,6 @@ QString VPattern::GetLabelBase(quint32 index) const
alphabet = al.split(","); alphabet = al.split(",");
break; break;
} }
case 1: // en
{
alphabet = def.split(",");
break;
}
case 2: // fr 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"); 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(","); alphabet = al.split(",");
break; break;
} }
case 1: // en
default: // en default: // en
{ {
alphabet = def.split(","); alphabet = def.split(",");

View File

@ -1578,12 +1578,7 @@ bool DL_Dxf::handleXData(DL_CreationInterface* creationInterface)
creationInterface->addXDataReal(static_cast<int>(groupCode), toReal(groupValue)); creationInterface->addXDataReal(static_cast<int>(groupCode), toReal(groupValue));
return true; return true;
} }
else if (groupCode>=1060 && groupCode<=1070) else if (groupCode>=1060 && groupCode<=1071)
{
creationInterface->addXDataInt(static_cast<int>(groupCode), toInt(groupValue));
return true;
}
else if (groupCode==1071)
{ {
creationInterface->addXDataInt(static_cast<int>(groupCode), toInt(groupValue)); creationInterface->addXDataInt(static_cast<int>(groupCode), toInt(groupValue));
return true; return true;
@ -2600,7 +2595,6 @@ void DL_Dxf::writeHeader(DL_WriterA& dw) const
break; break;
case DL_Codes::AC1009_MIN: case DL_Codes::AC1009_MIN:
// minimalistic DXF version is unidentified in file: // minimalistic DXF version is unidentified in file:
break;
default: default:
break; break;
} }
@ -4231,14 +4225,7 @@ void DL_Dxf::writeLinetype(DL_WriterA& dw,
dw.dxfString(2, data.name); dw.dxfString(2, data.name);
dw.dxfInt(70, data.flags); dw.dxfInt(70, data.flags);
if (nameUpper=="BYBLOCK") if (nameUpper=="BYBLOCK" || nameUpper=="BYLAYER")
{
dw.dxfString(3, "");
dw.dxfInt(72, 65);
dw.dxfInt(73, 0);
dw.dxfReal(40, 0.0);
}
else if (nameUpper=="BYLAYER")
{ {
dw.dxfString(3, ""); dw.dxfString(3, "");
dw.dxfInt(72, 65); dw.dxfInt(72, 65);

View File

@ -479,24 +479,17 @@ std::string VDxfEngine::getPenStyle()
{ {
switch (state->pen().style()) switch (state->pen().style())
{ {
case Qt::SolidLine:
return "BYLAYER";
break;
case Qt::DashLine: case Qt::DashLine:
return "DASHED"; return "DASHED";
break;
case Qt::DotLine: case Qt::DotLine:
return "DOT"; return "DOT";
break;
case Qt::DashDotLine: case Qt::DashDotLine:
return "DASHDOT"; return "DASHDOT";
break;
case Qt::DashDotDotLine: case Qt::DashDotDotLine:
return "DIVIDE"; return "DIVIDE";
break; case Qt::SolidLine:
default: default:
return "BYLAYER"; return "BYLAYER";
break;
} }
} }

View File

@ -126,10 +126,6 @@ int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
return engine->getSize().width(); return engine->getSize().width();
case QPaintDevice::PdmHeight: case QPaintDevice::PdmHeight:
return engine->getSize().height(); return engine->getSize().height();
case QPaintDevice::PdmDpiX:
return static_cast<int>(engine->getResolution());
case QPaintDevice::PdmDpiY:
return static_cast<int>(engine->getResolution());
case QPaintDevice::PdmHeightMM: case QPaintDevice::PdmHeightMM:
return qRound(engine->getSize().height() * 25.4 / engine->getResolution()); return qRound(engine->getSize().height() * 25.4 / engine->getResolution());
case QPaintDevice::PdmWidthMM: case QPaintDevice::PdmWidthMM:
@ -137,8 +133,9 @@ int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
case QPaintDevice::PdmNumColors: case QPaintDevice::PdmNumColors:
return static_cast<int>(0xffffffff); return static_cast<int>(0xffffffff);
case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmPhysicalDpiX:
return static_cast<int>(engine->getResolution());
case QPaintDevice::PdmPhysicalDpiY: case QPaintDevice::PdmPhysicalDpiY:
case QPaintDevice::PdmDpiX:
case QPaintDevice::PdmDpiY:
return static_cast<int>(engine->getResolution()); return static_cast<int>(engine->getResolution());
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 2) #if QT_VERSION > QT_VERSION_CHECK(5, 0, 2)
case QPaintDevice::PdmDevicePixelRatio: case QPaintDevice::PdmDevicePixelRatio:

View File

@ -147,18 +147,15 @@ int VObjPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
return engine->getSize().width(); return engine->getSize().width();
case QPaintDevice::PdmHeight: case QPaintDevice::PdmHeight:
return engine->getSize().height(); return engine->getSize().height();
case QPaintDevice::PdmDpiX:
return engine->getResolution();
case QPaintDevice::PdmDpiY:
return engine->getResolution();
case QPaintDevice::PdmHeightMM: case QPaintDevice::PdmHeightMM:
return qRound(engine->getSize().height() * 25.4 / engine->getResolution()); return qRound(engine->getSize().height() * 25.4 / engine->getResolution());
case QPaintDevice::PdmWidthMM: case QPaintDevice::PdmWidthMM:
return qRound(engine->getSize().width() * 25.4 / engine->getResolution()); return qRound(engine->getSize().width() * 25.4 / engine->getResolution());
case QPaintDevice::PdmNumColors: case QPaintDevice::PdmNumColors:
return static_cast<int>(0xffffffff); return static_cast<int>(0xffffffff);
case QPaintDevice::PdmDpiX:
case QPaintDevice::PdmDpiY:
case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmPhysicalDpiX:
return engine->getResolution();
case QPaintDevice::PdmPhysicalDpiY: case QPaintDevice::PdmPhysicalDpiY:
return engine->getResolution(); return engine->getResolution();
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 2) #if QT_VERSION > QT_VERSION_CHECK(5, 0, 2)

View File

@ -228,7 +228,7 @@ void VPE::VPropertyFormWidget::commitData(int row)
if (oldValue != newValue) if (oldValue != newValue)
{ {
VProperty *parent = tmpProperty->getParent(); VProperty *parent = tmpProperty->getParent();
if (parent == nullptr) if (parent == nullptr || parent->propertyType() != Property::Complex)
{ {
tmpProperty->setValue(newValue); tmpProperty->setValue(newValue);
emit propertyDataSubmitted(tmpProperty); emit propertyDataSubmitted(tmpProperty);
@ -238,11 +238,6 @@ void VPE::VPropertyFormWidget::commitData(int row)
tmpProperty->UpdateParent(newValue); tmpProperty->UpdateParent(newValue);
emit propertyDataSubmitted(parent); emit propertyDataSubmitted(parent);
} }
else
{
tmpProperty->setValue(newValue);
emit propertyDataSubmitted(tmpProperty);
}
} }
} }
} }

View File

@ -174,25 +174,17 @@ Qt::PenStyle VAbstractTool::LineStyleToPenStyle(const QString &typeLine)
{ {
case 0: // TypeLineNone case 0: // TypeLineNone
return Qt::NoPen; return Qt::NoPen;
break;
case 1: // TypeLineLine
return Qt::SolidLine;
break;
case 2: // TypeLineDashLine case 2: // TypeLineDashLine
return Qt::DashLine; return Qt::DashLine;
break;
case 3: // TypeLineDotLine case 3: // TypeLineDotLine
return Qt::DotLine; return Qt::DotLine;
break;
case 4: // TypeLineDashDotLine case 4: // TypeLineDashDotLine
return Qt::DashDotLine; return Qt::DashDotLine;
break;
case 5: // TypeLineDashDotDotLine case 5: // TypeLineDashDotDotLine
return Qt::DashDotDotLine; return Qt::DashDotDotLine;
break; case 1: // TypeLineLine
default: default:
return Qt::SolidLine; return Qt::SolidLine;
break;
} }
} }
@ -243,9 +235,6 @@ QMap<QString, QString> VAbstractTool::ColorsList()
QString name; QString name;
switch (i) switch (i)
{ {
case 0: // ColorBlack
name = tr("black");
break;
case 1: // ColorGreen case 1: // ColorGreen
name = tr("green"); name = tr("green");
break; break;
@ -294,6 +283,7 @@ QMap<QString, QString> VAbstractTool::ColorsList()
case 16: // ColorCornFlowerBlue case 16: // ColorCornFlowerBlue
name = tr("corn flower blue"); name = tr("corn flower blue");
break; break;
case 0: // ColorBlack
default: default:
name = tr("black"); name = tr("black");
break; break;

View File

@ -64,8 +64,6 @@ qreal VisLine::CorrectAngle(const qreal &angle)
switch (qFloor((qAbs(ang)+22.5)/45)) switch (qFloor((qAbs(ang)+22.5)/45))
{ {
case 0: // <22.5
return 0;
case 1: // <67.5 case 1: // <67.5
return 45; return 45;
case 2: // <112.5 case 2: // <112.5
@ -80,6 +78,7 @@ qreal VisLine::CorrectAngle(const qreal &angle)
return 270; return 270;
case 7: // <337.5 case 7: // <337.5
return 315; return 315;
case 0: // <22.5
default: // <360 default: // <360
return 0; return 0;
} }