Skip to content
Permalink
Browse files

expression translation fixes

  • Loading branch information
jef-n committed May 21, 2013
1 parent 4bea357 commit beabe723bc9e72bc55a1973a89e0002ca359fe80
@@ -7950,7 +7950,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
bool canChangeAttributes = dprovider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
bool canDeleteFeatures = dprovider->capabilities() & QgsVectorDataProvider::DeleteFeatures;
bool canAddAttributes = dprovider->capabilities() & QgsVectorDataProvider::AddAttributes;
bool canDeleteAttributes = dprovider->capabilities() & QgsVectorDataProvider::DeleteAttributes;
bool canAddFeatures = dprovider->capabilities() & QgsVectorDataProvider::AddFeatures;
bool canSupportEditing = dprovider->capabilities() & QgsVectorDataProvider::EditingCapabilities;
bool canChangeGeometry = dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries;
@@ -1432,107 +1432,107 @@ const QList<QgsExpression::Function*> &QgsExpression::Functions()
if ( gmFunctions.isEmpty() )
{
gmFunctions
<< new StaticFunction( "sqrt", 1, fcnSqrt, QObject::tr( "Math" ) )
<< new StaticFunction( "abs", 1, fcnAbs, QObject::tr( "Math" ) )
<< new StaticFunction( "cos", 1, fcnCos, QObject::tr( "Math" ) )
<< new StaticFunction( "sin", 1, fcnSin, QObject::tr( "Math" ) )
<< new StaticFunction( "tan", 1, fcnTan, QObject::tr( "Math" ) )
<< new StaticFunction( "asin", 1, fcnAsin, QObject::tr( "Math" ) )
<< new StaticFunction( "acos", 1, fcnAcos, QObject::tr( "Math" ) )
<< new StaticFunction( "atan", 1, fcnAtan, QObject::tr( "Math" ) )
<< new StaticFunction( "atan2", 2, fcnAtan2, QObject::tr( "Math" ) )
<< new StaticFunction( "exp", 1, fcnExp, QObject::tr( "Math" ) )
<< new StaticFunction( "ln", 1, fcnLn, QObject::tr( "Math" ) )
<< new StaticFunction( "log10", 1, fcnLog10, QObject::tr( "Math" ) )
<< new StaticFunction( "log", 2, fcnLog, QObject::tr( "Math" ) )
<< new StaticFunction( "round", -1, fcnRound, QObject::tr( "Math" ) )
<< new StaticFunction( "rand", 2, fcnRnd, QObject::tr( "Math" ) )
<< new StaticFunction( "randf", 2, fcnRndF, QObject::tr( "Math" ) )
<< new StaticFunction( "max", -1, fcnMax, QObject::tr( "Math" ) )
<< new StaticFunction( "min", -1, fcnMin, QObject::tr( "Math" ) )
<< new StaticFunction( "clamp", 3, fcnClamp, QObject::tr( "Math" ) )
<< new StaticFunction( "scale_linear", 5, fcnLinearScale, QObject::tr( "Math" ) )
<< new StaticFunction( "scale_exp", 6, fcnExpScale, QObject::tr( "Math" ) )
<< new StaticFunction( "floor", 1, fcnFloor, QObject::tr( "Math" ) )
<< new StaticFunction( "ceil", 1, fcnCeil, QObject::tr( "Math" ) )
<< new StaticFunction( "$pi", 0, fcnPi, QObject::tr( "Math" ) )
<< new StaticFunction( "toint", 1, fcnToInt, QObject::tr( "Conversions" ) )
<< new StaticFunction( "toreal", 1, fcnToReal, QObject::tr( "Conversions" ) )
<< new StaticFunction( "tostring", 1, fcnToString, QObject::tr( "Conversions" ) )
<< new StaticFunction( "todatetime", 1, fcnToDateTime, QObject::tr( "Conversions" ) )
<< new StaticFunction( "todate", 1, fcnToDate, QObject::tr( "Conversions" ) )
<< new StaticFunction( "totime", 1, fcnToTime, QObject::tr( "Conversions" ) )
<< new StaticFunction( "tointerval", 1, fcnToInterval, QObject::tr( "Conversions" ) )
<< new StaticFunction( "coalesce", -1, fcnCoalesce, QObject::tr( "Conditionals" ) )
<< new StaticFunction( "regexp_match", 2, fcnRegexpMatch, QObject::tr( "Conditionals" ) )
<< new StaticFunction( "$now", 0, fcnNow, QObject::tr( "Date and Time" ) )
<< new StaticFunction( "age", 2, fcnAge, QObject::tr( "Date and Time" ) )
<< new StaticFunction( "year", 1, fcnYear, QObject::tr( "Date and Time" ) )
<< new StaticFunction( "month", 1, fcnMonth, QObject::tr( "Date and Time" ) )
<< new StaticFunction( "week", 1, fcnWeek, QObject::tr( "Date and Time" ) )
<< new StaticFunction( "day", 1, fcnDay, QObject::tr( "Date and Time" ) )
<< new StaticFunction( "hour", 1, fcnHour, QObject::tr( "Date and Time" ) )
<< new StaticFunction( "minute", 1, fcnMinute, QObject::tr( "Date and Time" ) )
<< new StaticFunction( "second", 1, fcnSeconds, QObject::tr( "Date and Time" ) )
<< new StaticFunction( "lower", 1, fcnLower, QObject::tr( "String" ) )
<< new StaticFunction( "upper", 1, fcnUpper, QObject::tr( "String" ) )
<< new StaticFunction( "title", 1, fcnTitle, QObject::tr( "String" ) )
<< new StaticFunction( "trim", 1, fcnTrim, QObject::tr( "String" ) )
<< new StaticFunction( "length", 1, fcnLength, QObject::tr( "String" ) )
<< new StaticFunction( "replace", 3, fcnReplace, QObject::tr( "String" ) )
<< new StaticFunction( "regexp_replace", 3, fcnRegexpReplace, QObject::tr( "String" ) )
<< new StaticFunction( "regexp_substr", 2, fcnRegexpSubstr, QObject::tr( "String" ) )
<< new StaticFunction( "substr", 3, fcnSubstr, QObject::tr( "String" ) )
<< new StaticFunction( "concat", -1, fcnConcat, QObject::tr( "String" ) )
<< new StaticFunction( "strpos", 2, fcnStrpos, QObject::tr( "String" ) )
<< new StaticFunction( "left", 2, fcnLeft, QObject::tr( "String" ) )
<< new StaticFunction( "right", 2, fcnRight, QObject::tr( "String" ) )
<< new StaticFunction( "rpad", 3, fcnRPad, QObject::tr( "String" ) )
<< new StaticFunction( "lpad", 3, fcnLPad, QObject::tr( "String" ) )
<< new StaticFunction( "format", -1, fcnFormatString, QObject::tr( "String" ) )
<< new StaticFunction( "format_number", 2, fcnFormatNumber, QObject::tr( "String" ) )
<< new StaticFunction( "format_date", 2, fcnFormatDate, QObject::tr( "String" ) )
<< new StaticFunction( "color_rgb", 3, fcnColorRgb, QObject::tr( "Color" ) )
<< new StaticFunction( "color_rgba", 4, fncColorRgba, QObject::tr( "Color" ) )
<< new StaticFunction( "ramp_color", 2, fcnRampColor, QObject::tr( "Color" ) )
<< new StaticFunction( "color_hsl", 3, fcnColorHsl, QObject::tr( "Color" ) )
<< new StaticFunction( "color_hsla", 4, fncColorHsla, QObject::tr( "Color" ) )
<< new StaticFunction( "color_hsv", 3, fcnColorHsv, QObject::tr( "Color" ) )
<< new StaticFunction( "color_hsva", 4, fncColorHsva, QObject::tr( "Color" ) )
<< new StaticFunction( "color_cmyk", 4, fcnColorCmyk, QObject::tr( "Color" ) )
<< new StaticFunction( "color_cmyka", 5, fncColorCmyka, QObject::tr( "Color" ) )
<< new StaticFunction( "xat", 1, fcnXat, QObject::tr( "Geometry" ), "", true )
<< new StaticFunction( "yat", 1, fcnYat, QObject::tr( "Geometry" ), "", true )
<< new StaticFunction( "$area", 0, fcnGeomArea, QObject::tr( "Geometry" ), "", true )
<< new StaticFunction( "$length", 0, fcnGeomLength, QObject::tr( "Geometry" ), "", true )
<< new StaticFunction( "$perimeter", 0, fcnGeomPerimeter, QObject::tr( "Geometry" ), "", true )
<< new StaticFunction( "$x", 0, fcnX, QObject::tr( "Geometry" ), "", true )
<< new StaticFunction( "$y", 0, fcnY, QObject::tr( "Geometry" ), "" , true )
<< new StaticFunction( "$geometry", 0, fcnGeometry, QObject::tr( "Geometry" ), "" , true )
<< new StaticFunction( "geomFromWKT", 1, fcnGeomFromWKT, QObject::tr( "Geometry" ) )
<< new StaticFunction( "geomFromGML", 1, fcnGeomFromGML, QObject::tr( "Geometry" ) )
<< new StaticFunction( "bbox", 2, fcnBbox, QObject::tr( "Geometry" ) )
<< new StaticFunction( "disjoint", 2, fcnDisjoint, QObject::tr( "Geometry" ) )
<< new StaticFunction( "intersects", 2, fcnIntersects, QObject::tr( "Geometry" ) )
<< new StaticFunction( "touches", 2, fcnTouches, QObject::tr( "Geometry" ) )
<< new StaticFunction( "crosses", 2, fcnCrosses, QObject::tr( "Geometry" ) )
<< new StaticFunction( "contains", 2, fcnContains, QObject::tr( "Geometry" ) )
<< new StaticFunction( "overlaps", 2, fcnOverlaps, QObject::tr( "Geometry" ) )
<< new StaticFunction( "within", 2, fcnWithin, QObject::tr( "Geometry" ) )
<< new StaticFunction( "buffer", -1, fcnBuffer, QObject::tr( "Geometry" ) )
<< new StaticFunction( "centroid", 1, fcnCentroid, QObject::tr( "Geometry" ) )
<< new StaticFunction( "convexHull", 1, fcnConvexHull, QObject::tr( "Geometry" ) )
<< new StaticFunction( "difference", 2, fcnDifference, QObject::tr( "Geometry" ) )
<< new StaticFunction( "distance", 2, fcnDistance, QObject::tr( "Geometry" ) )
<< new StaticFunction( "intersection", 2, fcnIntersection, QObject::tr( "Geometry" ) )
<< new StaticFunction( "symDifference", 2, fcnSymDifference, QObject::tr( "Geometry" ) )
<< new StaticFunction( "combine", 2, fcnCombine, QObject::tr( "Geometry" ) )
<< new StaticFunction( "union", 2, fcnCombine, QObject::tr( "Geometry" ) )
<< new StaticFunction( "geomToWKT", 1, fcnGeomToWKT, QObject::tr( "Geometry" ) )
<< new StaticFunction( "$rownum", 0, fcnRowNumber, QObject::tr( "Record" ) )
<< new StaticFunction( "$id", 0, fcnFeatureId, QObject::tr( "Record" ) )
<< new StaticFunction( "$scale", 0, fcnScale, QObject::tr( "Record" ) )
<< new StaticFunction( "_specialcol_", 1, fcnSpecialColumn, QObject::tr( "Special" ) )
<< new StaticFunction( "sqrt", 1, fcnSqrt, "Math" )
<< new StaticFunction( "abs", 1, fcnAbs, "Math" )
<< new StaticFunction( "cos", 1, fcnCos, "Math" )
<< new StaticFunction( "sin", 1, fcnSin, "Math" )
<< new StaticFunction( "tan", 1, fcnTan, "Math" )
<< new StaticFunction( "asin", 1, fcnAsin, "Math" )
<< new StaticFunction( "acos", 1, fcnAcos, "Math" )
<< new StaticFunction( "atan", 1, fcnAtan, "Math" )
<< new StaticFunction( "atan2", 2, fcnAtan2, "Math" )
<< new StaticFunction( "exp", 1, fcnExp, "Math" )
<< new StaticFunction( "ln", 1, fcnLn, "Math" )
<< new StaticFunction( "log10", 1, fcnLog10, "Math" )
<< new StaticFunction( "log", 2, fcnLog, "Math" )
<< new StaticFunction( "round", -1, fcnRound, "Math" )
<< new StaticFunction( "rand", 2, fcnRnd, "Math" )
<< new StaticFunction( "randf", 2, fcnRndF, "Math" )
<< new StaticFunction( "max", -1, fcnMax, "Math" )
<< new StaticFunction( "min", -1, fcnMin, "Math" )
<< new StaticFunction( "clamp", 3, fcnClamp, "Math" )
<< new StaticFunction( "scale_linear", 5, fcnLinearScale, "Math" )
<< new StaticFunction( "scale_exp", 6, fcnExpScale, "Math" )
<< new StaticFunction( "floor", 1, fcnFloor, "Math" )
<< new StaticFunction( "ceil", 1, fcnCeil, "Math" )
<< new StaticFunction( "$pi", 0, fcnPi, "Math" )
<< new StaticFunction( "toint", 1, fcnToInt, "Conversions" )
<< new StaticFunction( "toreal", 1, fcnToReal, "Conversions" )
<< new StaticFunction( "tostring", 1, fcnToString, "Conversions" )
<< new StaticFunction( "todatetime", 1, fcnToDateTime, "Conversions" )
<< new StaticFunction( "todate", 1, fcnToDate, "Conversions" )
<< new StaticFunction( "totime", 1, fcnToTime, "Conversions" )
<< new StaticFunction( "tointerval", 1, fcnToInterval, "Conversions" )
<< new StaticFunction( "coalesce", -1, fcnCoalesce, "Conditionals" )
<< new StaticFunction( "regexp_match", 2, fcnRegexpMatch, "Conditionals" )
<< new StaticFunction( "$now", 0, fcnNow, "Date and Time" )
<< new StaticFunction( "age", 2, fcnAge, "Date and Time" )
<< new StaticFunction( "year", 1, fcnYear, "Date and Time" )
<< new StaticFunction( "month", 1, fcnMonth, "Date and Time" )
<< new StaticFunction( "week", 1, fcnWeek, "Date and Time" )
<< new StaticFunction( "day", 1, fcnDay, "Date and Time" )
<< new StaticFunction( "hour", 1, fcnHour, "Date and Time" )
<< new StaticFunction( "minute", 1, fcnMinute, "Date and Time" )
<< new StaticFunction( "second", 1, fcnSeconds, "Date and Time" )
<< new StaticFunction( "lower", 1, fcnLower, "String" )
<< new StaticFunction( "upper", 1, fcnUpper, "String" )
<< new StaticFunction( "title", 1, fcnTitle, "String" )
<< new StaticFunction( "trim", 1, fcnTrim, "String" )
<< new StaticFunction( "length", 1, fcnLength, "String" )
<< new StaticFunction( "replace", 3, fcnReplace, "String" )
<< new StaticFunction( "regexp_replace", 3, fcnRegexpReplace, "String" )
<< new StaticFunction( "regexp_substr", 2, fcnRegexpSubstr, "String" )
<< new StaticFunction( "substr", 3, fcnSubstr, "String" )
<< new StaticFunction( "concat", -1, fcnConcat, "String" )
<< new StaticFunction( "strpos", 2, fcnStrpos, "String" )
<< new StaticFunction( "left", 2, fcnLeft, "String" )
<< new StaticFunction( "right", 2, fcnRight, "String" )
<< new StaticFunction( "rpad", 3, fcnRPad, "String" )
<< new StaticFunction( "lpad", 3, fcnLPad, "String" )
<< new StaticFunction( "format", -1, fcnFormatString, "String" )
<< new StaticFunction( "format_number", 2, fcnFormatNumber, "String" )
<< new StaticFunction( "format_date", 2, fcnFormatDate, "String" )
<< new StaticFunction( "color_rgb", 3, fcnColorRgb, "Color" )
<< new StaticFunction( "color_rgba", 4, fncColorRgba, "Color" )
<< new StaticFunction( "ramp_color", 2, fcnRampColor, "Color" )
<< new StaticFunction( "color_hsl", 3, fcnColorHsl, "Color" )
<< new StaticFunction( "color_hsla", 4, fncColorHsla, "Color" )
<< new StaticFunction( "color_hsv", 3, fcnColorHsv, "Color" )
<< new StaticFunction( "color_hsva", 4, fncColorHsva, "Color" )
<< new StaticFunction( "color_cmyk", 4, fcnColorCmyk, "Color" )
<< new StaticFunction( "color_cmyka", 5, fncColorCmyka, "Color" )
<< new StaticFunction( "xat", 1, fcnXat, "Geometry", "", true )
<< new StaticFunction( "yat", 1, fcnYat, "Geometry", "", true )
<< new StaticFunction( "$area", 0, fcnGeomArea, "Geometry", "", true )
<< new StaticFunction( "$length", 0, fcnGeomLength, "Geometry", "", true )
<< new StaticFunction( "$perimeter", 0, fcnGeomPerimeter, "Geometry", "", true )
<< new StaticFunction( "$x", 0, fcnX, "Geometry", "", true )
<< new StaticFunction( "$y", 0, fcnY, "Geometry", "" , true )
<< new StaticFunction( "$geometry", 0, fcnGeometry, "Geometry", "" , true )
<< new StaticFunction( "geomFromWKT", 1, fcnGeomFromWKT, "Geometry" )
<< new StaticFunction( "geomFromGML", 1, fcnGeomFromGML, "Geometry" )
<< new StaticFunction( "bbox", 2, fcnBbox, "Geometry" )
<< new StaticFunction( "disjoint", 2, fcnDisjoint, "Geometry" )
<< new StaticFunction( "intersects", 2, fcnIntersects, "Geometry" )
<< new StaticFunction( "touches", 2, fcnTouches, "Geometry" )
<< new StaticFunction( "crosses", 2, fcnCrosses, "Geometry" )
<< new StaticFunction( "contains", 2, fcnContains, "Geometry" )
<< new StaticFunction( "overlaps", 2, fcnOverlaps, "Geometry" )
<< new StaticFunction( "within", 2, fcnWithin, "Geometry" )
<< new StaticFunction( "buffer", -1, fcnBuffer, "Geometry" )
<< new StaticFunction( "centroid", 1, fcnCentroid, "Geometry" )
<< new StaticFunction( "convexHull", 1, fcnConvexHull, "Geometry" )
<< new StaticFunction( "difference", 2, fcnDifference, "Geometry" )
<< new StaticFunction( "distance", 2, fcnDistance, "Geometry" )
<< new StaticFunction( "intersection", 2, fcnIntersection, "Geometry" )
<< new StaticFunction( "symDifference", 2, fcnSymDifference, "Geometry" )
<< new StaticFunction( "combine", 2, fcnCombine, "Geometry" )
<< new StaticFunction( "union", 2, fcnCombine, "Geometry" )
<< new StaticFunction( "geomToWKT", 1, fcnGeomToWKT, "Geometry" )
<< new StaticFunction( "$rownum", 0, fcnRowNumber, "Record" )
<< new StaticFunction( "$id", 0, fcnFeatureId, "Record" )
<< new StaticFunction( "$scale", 0, fcnScale, "Record" )
<< new StaticFunction( "_specialcol_", 1, fcnSpecialColumn, "Special" )
;
}
return gmFunctions;
@@ -2506,11 +2506,9 @@ void QgsPalLayerSettings::parseTextBuffer()

// data defined draw buffer?
bool drawBuffer = bufferDraw;
bool newStyleTrigger = false;
if ( dataDefinedValEval( "bool", QgsPalLayerSettings::BufferDraw, exprVal ) )
{
drawBuffer = exprVal.toBool();
newStyleTrigger = true;
}

// data defined buffer size?
@@ -54,18 +54,18 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
}

// TODO Can we move this stuff to QgsExpression, like the functions?
registerItem( "Operators", "+", " + " );
registerItem( "Operators", "-", " -" );
registerItem( "Operators", "*", " * " );
registerItem( "Operators", "/", " / " );
registerItem( "Operators", "%", " % " );
registerItem( "Operators", "^", " ^ " );
registerItem( "Operators", "=", " = " );
registerItem( "Operators", ">", " > " );
registerItem( "Operators", "<", " < " );
registerItem( "Operators", "<>", " <> " );
registerItem( "Operators", "<=", " <= " );
registerItem( "Operators", ">=", " >= " );
registerItem( "Operators", "+", " + ", tr( "Addition operator" ) );
registerItem( "Operators", "-", " -" , tr( "Subtraction operator" ) );
registerItem( "Operators", "*", " * ", tr( "Multiplication operator" ) );
registerItem( "Operators", "/", " / ", tr( "Division operator" ) );
registerItem( "Operators", "%", " % ", tr( "Modulo operator" ) );
registerItem( "Operators", "^", " ^ ", tr( "Power operator" ) );
registerItem( "Operators", "=", " = ", tr( "Equal operator" ) );
registerItem( "Operators", ">", " > ", tr( "Greater as operator" ) );
registerItem( "Operators", "<", " < ", tr( "Less than operator" ) );
registerItem( "Operators", "<>", " <> ", tr( "Unequal operator" ) );
registerItem( "Operators", "<=", " <= ", tr( "Less or equal operator" ) );
registerItem( "Operators", ">=", " >= ", tr( "Greater or equal operator" ) );
registerItem( "Operators", "||", " || ",
QString( "<b>|| %1</b><br><i>%2</i><br><i>%3:</i>%4" )
.arg( tr( "(String Concatenation)" ) )
@@ -223,17 +223,17 @@ void QgsExpressionBuilderWidget::registerItem( QString group,
// Look up the group and insert the new function.
if ( mExpressionGroups.contains( group ) )
{
QgsExpressionItem* groupNode = mExpressionGroups.value( group );
QgsExpressionItem *groupNode = mExpressionGroups.value( group );
groupNode->appendRow( item );
}
else
{
// If the group doesn't exist yet we make it first.
QgsExpressionItem* newgroupNode = new QgsExpressionItem( QgsExpression::group( group ), "", QgsExpressionItem::Header );
QgsExpressionItem *newgroupNode = new QgsExpressionItem( QgsExpression::group( group ), "", QgsExpressionItem::Header );
newgroupNode->setData( group, Qt::UserRole );
newgroupNode->appendRow( item );
mModel->appendRow( newgroupNode );
mExpressionGroups.insert( group , newgroupNode );
mExpressionGroups.insert( group, newgroupNode );
}
}

@@ -413,17 +413,13 @@ void QgsExpressionBuilderWidget::setExpressionState( bool state )

QString QgsExpressionBuilderWidget::loadFunctionHelp( QgsExpressionItem* expressionItem )
{
if ( expressionItem == NULL )
if ( !expressionItem )
return "";

QString helpContents;
QString helpContents = expressionItem->getHelpText();

// Return the function help that is set for the function if there is one.
if ( !expressionItem->getHelpText().isEmpty() )
{
helpContents = expressionItem->getHelpText();
}
else
if ( helpContents.isEmpty() )
{
QString name = expressionItem->data( Qt::UserRole ).toString();

@@ -93,7 +93,7 @@ class QgsExpressionItem : public QStandardItem
*
* @return The QgsExpressionItem::ItemType
*/
QgsExpressionItem::ItemType getItemType() { return mType ; }
QgsExpressionItem::ItemType getItemType() { return mType; }

private:
QString mExpressionText;

0 comments on commit beabe72

Please sign in to comment.
You can’t perform that action at this time.