Refactoring. Merge identical cases.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-03-18 11:04:12 +02:00
parent 47e50fe06f
commit 6499c73d0c
5 changed files with 12 additions and 74 deletions

View File

@ -43,15 +43,13 @@ qreal WidthMainLine(Unit patternUnit)
qreal _widthMainLine = DefWidth; qreal _widthMainLine = DefWidth;
switch (patternUnit) switch (patternUnit)
{ {
case Unit::Mm:
_widthMainLine = DefWidth;
break;
case Unit::Cm: case Unit::Cm:
_widthMainLine = DefWidth/10.0; _widthMainLine = DefWidth/10.0;
break; break;
case Unit::Inch: case Unit::Inch:
_widthMainLine = DefWidth/25.4; _widthMainLine = DefWidth/25.4;
break; break;
case Unit::Mm:
default: default:
_widthMainLine = DefWidth; _widthMainLine = DefWidth;
break; break;

View File

@ -771,12 +771,10 @@ Unit VAbstractPattern::MUnit() const
case 0:// mm case 0:// mm
return Unit::Mm; return Unit::Mm;
break; break;
case 1:// cm
return Unit::Cm;
break;
case 2:// in case 2:// in
return Unit::Inch; return Unit::Inch;
break; break;
case 1:// cm
default: default:
return Unit::Cm; return Unit::Cm;
break; break;
@ -922,7 +920,6 @@ QMap<GHeights, bool> VAbstractPattern::GetGradationHeights() const
return map; return map;
break; break;
case 1: // TagSizes case 1: // TagSizes
break;
default: default:
break; break;
} }
@ -1021,7 +1018,6 @@ void VAbstractPattern::SetGradationHeights(const QMap<GHeights, bool> &options)
return; return;
break; break;
case 1: // TagSizes case 1: // TagSizes
break;
default: default:
break; break;
} }
@ -1081,8 +1077,6 @@ QMap<GSizes, bool> VAbstractPattern::GetGradationSizes() const
const QString defValue = trueStr; const QString defValue = trueStr;
switch (gTags.indexOf(domElement.tagName())) switch (gTags.indexOf(domElement.tagName()))
{ {
case 0: // TagHeights
break;
case 1: // TagSizes case 1: // TagSizes
if (GetParametrBool(domElement, AttrAll, defValue)) if (GetParametrBool(domElement, AttrAll, defValue))
{ {
@ -1121,6 +1115,7 @@ QMap<GSizes, bool> VAbstractPattern::GetGradationSizes() const
map.insert(GSizes::S72, GetParametrBool(domElement, AttrS72, defValue)); map.insert(GSizes::S72, GetParametrBool(domElement, AttrS72, defValue));
return map; return map;
break; break;
case 0: // TagHeights
default: default:
break; break;
} }
@ -1153,8 +1148,6 @@ void VAbstractPattern::SetGradationSizes(const QMap<GSizes, bool> &options)
{ {
switch (gTags.indexOf(domElement.tagName())) switch (gTags.indexOf(domElement.tagName()))
{ {
case 0: // TagHeights
break;
case 1: // TagSizes case 1: // TagSizes
SetAttribute(domElement, AttrAll, options.value(GSizes::ALL)); SetAttribute(domElement, AttrAll, options.value(GSizes::ALL));
if (options.value(GSizes::ALL)) if (options.value(GSizes::ALL))
@ -1220,6 +1213,7 @@ void VAbstractPattern::SetGradationSizes(const QMap<GSizes, bool> &options)
emit patternChanged(false); emit patternChanged(false);
return; return;
break; break;
case 0: // TagHeights
default: default:
break; break;
} }
@ -1509,8 +1503,6 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
<< TagCustomerName << TagSize << TagShowDate << TagShowMeasurements; << TagCustomerName << TagSize << TagShowDate << TagShowMeasurements;
switch (tags.indexOf(tag)) switch (tags.indexOf(tag))
{ {
case 0: //TagUnit
return QDomElement();// Mandatory tag
case 1: //TagImage case 1: //TagImage
element = createElement(TagImage); element = createElement(TagImage);
break; break;
@ -1557,6 +1549,7 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
case 12: // TagShowMeasurements case 12: // TagShowMeasurements
element = createElement(TagShowMeasurements); element = createElement(TagShowMeasurements);
break; break;
case 0: //TagUnit (Mandatory tag)
default: default:
return QDomElement(); return QDomElement();
} }

View File

@ -254,14 +254,10 @@ bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString
switch (bools.indexOf(parametr)) switch (bools.indexOf(parametr))
{ {
case 0: // true case 0: // true
val = true;
break;
case 1: // false
val = false;
break;
case 2: // 1 case 2: // 1
val = true; val = true;
break; break;
case 1: // false
case 3: // 0 case 3: // 0
val = false; val = false;
break; break;
@ -563,15 +559,13 @@ Unit VDomDocument::StrToUnits(const QString &unit)
case 0:// mm case 0:// mm
result = Unit::Mm; result = Unit::Mm;
break; break;
case 1:// cm
result = Unit::Cm;
break;
case 2:// inch case 2:// inch
result = Unit::Inch; result = Unit::Inch;
break; break;
case 3:// px case 3:// px
result = Unit::Px; result = Unit::Px;
break; break;
case 1:// cm
default: default:
result = Unit::Cm; result = Unit::Cm;
break; break;
@ -594,54 +588,17 @@ QString VDomDocument::UnitsToStr(const Unit &unit, const bool translate)
switch (unit) switch (unit)
{ {
case Unit::Mm: case Unit::Mm:
if (translate) translate ? result = QObject::tr("mm") : result = UnitMM;
{
result = QObject::tr("mm");
}
else
{
result = UnitMM;
}
break;
case Unit::Cm:
if (translate)
{
result = QObject::tr("cm");
}
else
{
result = UnitCM;
}
break; break;
case Unit::Inch: case Unit::Inch:
if (translate) translate ? result = QObject::tr("inch") : result = UnitINCH;
{
result = QObject::tr("inch");
}
else
{
result = UnitINCH;
}
break; break;
case Unit::Px: case Unit::Px:
if (translate) translate ? result = QObject::tr("px") : result = UnitPX;
{
result = QObject::tr("px");
}
else
{
result = UnitPX;
}
break; break;
case Unit::Cm:
default: default:
if (translate) translate ? result = QObject::tr("cm") : result = UnitCM;
{
result = QObject::tr("cm");
}
else
{
result = UnitCM;
}
break; break;
} }
return result; return result;

View File

@ -1735,14 +1735,6 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve)
switch(splTypes.indexOf(type)) switch(splTypes.indexOf(type))
{ {
case 0: //strModelingPath case 0: //strModelingPath
{
const quint32 spl = element.attribute(strIdObject).toUInt();
if (spl == id+1 || spl == id+2)
{
element.setAttribute(strIdObject, baseCurve);
}
break;
}
case 1: //strModelingSpline case 1: //strModelingSpline
{ {
const quint32 spl = element.attribute(strIdObject).toUInt(); const quint32 spl = element.attribute(strIdObject).toUInt();

View File

@ -38,8 +38,6 @@ void testMessageOutput(QtMsgType type, const QMessageLogContext &context, const
switch (type) switch (type)
{ {
case QtDebugMsg: case QtDebugMsg:
fprintf(stderr, "%s\n", localMsg.constData());
break;
case QtWarningMsg: case QtWarningMsg:
fprintf(stderr, "%s\n", localMsg.constData()); fprintf(stderr, "%s\n", localMsg.constData());
break; break;