Fix translation variables.
(grafted from dff11ab321d8eb16de58f01b70913190f527809c) --HG-- branch : develop
This commit is contained in:
parent
2be8bf2206
commit
474c0949e2
|
@ -44,6 +44,7 @@
|
|||
- [#729] Moved Bezier curves can't be rotated.
|
||||
- [#742] Valentina produces wrong seam allowance.
|
||||
- [#743] Valentina doesn't update update pattern after adding item.
|
||||
- Fix translation variables.
|
||||
|
||||
# Version 0.5.0 May 9, 2017
|
||||
- [#581] User can now filter input lists by keyword in function wizard.
|
||||
|
|
|
@ -2045,10 +2045,17 @@ bool VAbstractPattern::IsVariable(const QString &token) const
|
|||
for (int i = 0; i < builInVariables.size(); ++i)
|
||||
{
|
||||
if (token.indexOf( builInVariables.at(i) ) == 0)
|
||||
{
|
||||
if (builInVariables.at(i) == currentLength || builInVariables.at(i) == currentSeamAllowance)
|
||||
{
|
||||
return token == builInVariables.at(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -530,15 +530,26 @@ void VTranslateVars::BiasTokens(int position, int bias, QMap<int, QString> &toke
|
|||
*/
|
||||
bool VTranslateVars::VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const
|
||||
{
|
||||
const QString currentLengthTr = variables.value(currentLength).translate();
|
||||
const QString currentSeamAllowanceTr = variables.value(currentSeamAllowance).translate();
|
||||
|
||||
QMap<QString, qmu::QmuTranslation>::const_iterator i = variables.constBegin();
|
||||
while (i != variables.constEnd())
|
||||
{
|
||||
const qmu::QmuTranslation &var = i.value();
|
||||
if (token.indexOf( var.translate() ) == 0)
|
||||
const QString varTr = var.translate();
|
||||
|
||||
if (token.indexOf(varTr) == 0)
|
||||
{
|
||||
newFormula.replace(position, var.translate().length(), i.key());
|
||||
if ((varTr == currentLengthTr || varTr == currentSeamAllowanceTr) && token != varTr)
|
||||
{
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
||||
newFormula.replace(position, varTr.length(), i.key());
|
||||
QString newToken = token;
|
||||
newToken.replace(0, var.translate().length(), i.key());
|
||||
newToken.replace(0, varTr.length(), i.key());
|
||||
bias = token.length() - newToken.length();
|
||||
return true;
|
||||
}
|
||||
|
@ -613,6 +624,12 @@ bool VTranslateVars::VariablesToUser(QString &newFormula, int position, const QS
|
|||
{
|
||||
if (token.indexOf( i.key() ) == 0)
|
||||
{
|
||||
if ((i.key() == currentLength || i.key() == currentSeamAllowance) && token != i.key())
|
||||
{
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
||||
newFormula.replace(position, i.key().length(), i.value().translate());
|
||||
|
||||
QString newToken = token;
|
||||
|
|
Loading…
Reference in New Issue
Block a user