Prepare App side for "show units" preference

This commit is contained in:
WandererFan
2016-10-04 09:10:38 -04:00
committed by Yorik van Havre
parent 8d139816e3
commit 62328bb54c
2 changed files with 20 additions and 2 deletions

View File

@@ -191,7 +191,10 @@ std::string DrawViewDimension::getFormatedValue() const
} else {
qVal.setUnit(Base::Unit::Length);
}
QString userStr = qVal.getUserString();
QString userStr = qVal.getUserString(); //this handles mm to inch/km/parsec etc and decimal positions
QRegExp rx2(QString::fromUtf8("\\D*$"));
QString userVal = userStr;
userVal.remove(rx2);
QRegExp rx(QString::fromUtf8("%(\\w+)%")); //any word bracketed by %
QStringList list;
@@ -202,15 +205,29 @@ std::string DrawViewDimension::getFormatedValue() const
pos += rx.matchedLength();
}
QString repl = userVal;
if (showUnits()) {
repl = userStr;
}
for(QStringList::const_iterator it = list.begin(); it != list.end(); ++it) {
if(*it == QString::fromUtf8("%value%")){
str.replace(*it,userStr);
str.replace(*it,repl);
// } else { //insert additional placeholder replacement logic here
}
}
return str.toUtf8().constData();
}
bool DrawViewDimension::showUnits() const
{
bool result = false;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
result = hGrp->GetBool("ShowUnits", true);
return result;
}
double DrawViewDimension::getDimValue() const
{
double result = 0.0;