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;
switch (patternUnit)
{
case Unit::Mm:
_widthMainLine = DefWidth;
break;
case Unit::Cm:
_widthMainLine = DefWidth/10.0;
break;
case Unit::Inch:
_widthMainLine = DefWidth/25.4;
break;
case Unit::Mm:
default:
_widthMainLine = DefWidth;
break;

View File

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

View File

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

View File

@ -1735,14 +1735,6 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve)
switch(splTypes.indexOf(type))
{
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
{
const quint32 spl = element.attribute(strIdObject).toUInt();

View File

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