Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,11 @@ Value ConstraintsParser::parseBinaryValueTag(const QDomElement &element)
return mValues.sum(leftValue, rightValue);
}

if (operation.startsWith("difference")) {
if (operation == "mul") {
return mValues.mul(leftValue, rightValue);
}

if (operation == "difference") {
return mValues.difference(leftValue, rightValue);
}

Expand All @@ -621,7 +625,7 @@ Value ConstraintsParser::parseBinaryValueTag(const QDomElement &element)
return mValues.distance(leftValue, rightValue);
}

return mValues.sum(leftValue, rightValue);
qFatal("Unknown operator: %s\n", qPrintable(operation));
}

Trigger ConstraintsParser::parseEventSetDropTag(const QDomElement &element)
Expand Down Expand Up @@ -687,7 +691,7 @@ Value ConstraintsParser::parseValue(const QDomElement &element)
return parseUnaryValueTag(element);
}

if (tag == "sum" || tag == "difference" || tag == "min" || tag == "max" || tag == "distance") {
if (tag == "mul" || tag == "sum" || tag == "difference" || tag == "min" || tag == "max" || tag == "distance") {
return parseBinaryValueTag(element);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ Value ValuesFactory::sum(const Value &left, const Value &right) const
return [left, right]() { return left().toInt() + right().toInt(); };
}

Value ValuesFactory::mul(const Value &left, const Value &right) const
{
return [left, right]() { return left().toInt() * right().toInt(); };
}


Value ValuesFactory::difference(const Value &left, const Value &right) const
{
return [left, right]() { return left().toInt() - right().toInt(); };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class ValuesFactory
/// If values cannot be implicitly converted to integers 0 will be returned.
Value sum(const Value &left, const Value &right) const;

/// Produces functor that returns a multiplication of two given integer values
/// If values cannot be implicitly converted to integers 0 will be returned.
Value mul(const Value &left, const Value &right) const;

/// Produces functor that returns a difference of two given numeric values.
/// If values cannot be implicitly converted to integers 0 will be returned.
Value difference(const Value &left, const Value &right) const;
Expand Down
4 changes: 2 additions & 2 deletions qrtranslations/fr/plugins/robots/twoDModel_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+262"/>
<location line="+266"/>
<source>Unknown value &quot;%1&quot;.</source>
<translation>Valeur inconnue &quot;%1&quot;.</translation>
</message>
Expand Down Expand Up @@ -144,7 +144,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+120"/>
<location line="+126"/>
<source>Unknown type of object &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
Expand Down
4 changes: 2 additions & 2 deletions qrtranslations/ru/plugins/robots/twoDModel_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
<translation>В выражении &quot;using&quot; должен иметься тэг &quot;return&quot;.</translation>
</message>
<message>
<location line="+262"/>
<location line="+266"/>
<source>Unknown value &quot;%1&quot;.</source>
<translation>Неизвестное значение &quot;%1&quot;.</translation>
</message>
Expand Down Expand Up @@ -350,7 +350,7 @@
<translation>Путь до объекта пуст!</translation>
</message>
<message>
<location line="+120"/>
<location line="+126"/>
<source>Unknown type of object &quot;%1&quot;</source>
<translation>Неизвестный тип объекта &quot;%1&quot;</translation>
</message>
Expand Down
Loading