Skip to content

Commit 7357268

Browse files
committed
make wfs/ogc error message translatable
1 parent 10a26e6 commit 7357268

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

src/core/qgsogcutils.cpp

+26-25
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <QColor>
2323
#include <QStringList>
2424
#include <QTextStream>
25+
#include <QObject>
2526

2627
#ifndef Q_OS_WIN
2728
#include <netinet/in.h>
@@ -1604,7 +1605,7 @@ QgsExpression::Node* QgsOgcUtils::nodeFromOgcFilter( QDomElement &element, QStri
16041605
return nodeIsBetweenFromOgcFilter( element, errorMessage );
16051606
}
16061607

1607-
errorMessage += QString( "unable to convert '%1' element to a valid expression: it is not supported yet or it has invalid arguments" ).arg( element.tagName() );
1608+
errorMessage += QObject::tr( "unable to convert '%1' element to a valid expression: it is not supported yet or it has invalid arguments" ).arg( element.tagName() );
16081609
return nullptr;
16091610
}
16101611

@@ -1619,7 +1620,7 @@ QgsExpression::NodeBinaryOperator* QgsOgcUtils::nodeBinaryOperatorFromOgcFilter(
16191620
if ( op < 0 )
16201621
{
16211622
if ( errorMessage.isEmpty() )
1622-
errorMessage = QString( "'%1' binary operator not supported." ).arg( element.tagName() );
1623+
errorMessage = QObject::tr( "'%1' binary operator not supported." ).arg( element.tagName() );
16231624
return nullptr;
16241625
}
16251626

@@ -1628,7 +1629,7 @@ QgsExpression::NodeBinaryOperator* QgsOgcUtils::nodeBinaryOperatorFromOgcFilter(
16281629
if ( !expr )
16291630
{
16301631
if ( errorMessage.isEmpty() )
1631-
errorMessage = QString( "invalid left operand for '%1' binary operator" ).arg( element.tagName() );
1632+
errorMessage = QObject::tr( "invalid left operand for '%1' binary operator" ).arg( element.tagName() );
16321633
return nullptr;
16331634
}
16341635

@@ -1638,7 +1639,7 @@ QgsExpression::NodeBinaryOperator* QgsOgcUtils::nodeBinaryOperatorFromOgcFilter(
16381639
if ( !opRight )
16391640
{
16401641
if ( errorMessage.isEmpty() )
1641-
errorMessage = QString( "invalid right operand for '%1' binary operator" ).arg( element.tagName() );
1642+
errorMessage = QObject::tr( "invalid right operand for '%1' binary operator" ).arg( element.tagName() );
16421643
delete expr;
16431644
return nullptr;
16441645
}
@@ -1649,7 +1650,7 @@ QgsExpression::NodeBinaryOperator* QgsOgcUtils::nodeBinaryOperatorFromOgcFilter(
16491650
if ( expr == leftOp )
16501651
{
16511652
if ( errorMessage.isEmpty() )
1652-
errorMessage = QString( "only one operand for '%1' binary operator" ).arg( element.tagName() );
1653+
errorMessage = QObject::tr( "only one operand for '%1' binary operator" ).arg( element.tagName() );
16531654
delete expr;
16541655
return nullptr;
16551656
}
@@ -1685,7 +1686,7 @@ QgsExpression::NodeFunction* QgsOgcUtils::nodeSpatialOperatorFromOgcFilter( QDom
16851686
}
16861687
else
16871688
{
1688-
errorMessage = "No OGC Geometry found";
1689+
errorMessage = QObject::tr( "No OGC Geometry found" );
16891690
delete gml2Args;
16901691
return nullptr;
16911692
}
@@ -1708,7 +1709,7 @@ QgsExpression::NodeUnaryOperator* QgsOgcUtils::nodeNotFromOgcFilter( QDomElement
17081709
if ( !operand )
17091710
{
17101711
if ( errorMessage.isEmpty() )
1711-
errorMessage = QString( "invalid operand for '%1' unary operator" ).arg( element.tagName() );
1712+
errorMessage = QObject::tr( "invalid operand for '%1' unary operator" ).arg( element.tagName() );
17121713
return nullptr;
17131714
}
17141715

@@ -1720,7 +1721,7 @@ QgsExpression::NodeFunction* QgsOgcUtils::nodeFunctionFromOgcFilter( QDomElement
17201721
{
17211722
if ( element.isNull() || element.tagName() != "Function" )
17221723
{
1723-
errorMessage = QString( "ogc:Function expected, got %1" ).arg( element.tagName() );
1724+
errorMessage = QObject::tr( "ogc:Function expected, got %1" ).arg( element.tagName() );
17241725
return nullptr;
17251726
}
17261727

@@ -1759,7 +1760,7 @@ QgsExpression::Node* QgsOgcUtils::nodeLiteralFromOgcFilter( QDomElement &element
17591760
{
17601761
if ( element.isNull() || element.tagName() != "Literal" )
17611762
{
1762-
errorMessage = QString( "ogc:Literal expected, got %1" ).arg( element.tagName() );
1763+
errorMessage = QObject::tr( "ogc:Literal expected, got %1" ).arg( element.tagName() );
17631764
return nullptr;
17641765
}
17651766

@@ -1781,7 +1782,7 @@ QgsExpression::Node* QgsOgcUtils::nodeLiteralFromOgcFilter( QDomElement &element
17811782
if ( root )
17821783
delete root;
17831784

1784-
errorMessage = QString( "'%1' is an invalid or not supported content for ogc:Literal" ).arg( operandElem.tagName() );
1785+
errorMessage = QObject::tr( "'%1' is an invalid or not supported content for ogc:Literal" ).arg( operandElem.tagName() );
17851786
return nullptr;
17861787
}
17871788
}
@@ -1826,7 +1827,7 @@ QgsExpression::NodeColumnRef* QgsOgcUtils::nodeColumnRefFromOgcFilter( QDomEleme
18261827
{
18271828
if ( element.isNull() || element.tagName() != "PropertyName" )
18281829
{
1829-
errorMessage = QString( "ogc:PropertyName expected, got %1" ).arg( element.tagName() );
1830+
errorMessage = QObject::tr( "ogc:PropertyName expected, got %1" ).arg( element.tagName() );
18301831
return nullptr;
18311832
}
18321833

@@ -1879,7 +1880,7 @@ QgsExpression::Node* QgsOgcUtils::nodeIsBetweenFromOgcFilter( QDomElement& eleme
18791880
if ( upperBound )
18801881
delete upperBound;
18811882

1882-
errorMessage = "missing some required sub-elements in ogc:PropertyIsBetween";
1883+
errorMessage = QObject::tr( "missing some required sub-elements in ogc:PropertyIsBetween" );
18831884
return nullptr;
18841885
}
18851886

@@ -1947,7 +1948,7 @@ QDomElement QgsOgcUtils::expressionNodeToOgcFilter( const QgsExpression::Node* n
19471948
return expressionColumnRefToOgcFilter( static_cast<const QgsExpression::NodeColumnRef*>( node ), doc, errorMessage );
19481949

19491950
default:
1950-
errorMessage = QString( "Node type not supported: %1" ).arg( node->nodeType() );
1951+
errorMessage = QObject::tr( "Node type not supported: %1" ).arg( node->nodeType() );
19511952
return QDomElement();
19521953
}
19531954
}
@@ -1974,7 +1975,7 @@ QDomElement QgsOgcUtils::expressionUnaryOperatorToOgcFilter( const QgsExpression
19741975
}
19751976
else
19761977
{
1977-
errorMessage = QString( "This use of unary operator not implemented yet" );
1978+
errorMessage = QObject::tr( "This use of unary operator not implemented yet" );
19781979
return QDomElement();
19791980
}
19801981
break;
@@ -1984,7 +1985,7 @@ QDomElement QgsOgcUtils::expressionUnaryOperatorToOgcFilter( const QgsExpression
19841985
break;
19851986

19861987
default:
1987-
errorMessage = QString( "Unary operator %1 not implemented yet" ).arg( QgsExpression::UnaryOperatorText[node->op()] );
1988+
errorMessage = QObject::tr( "Unary operator %1 not implemented yet" ).arg( QgsExpression::UnaryOperatorText[node->op()] );
19881989
return QDomElement();
19891990
}
19901991

@@ -2038,7 +2039,7 @@ QDomElement QgsOgcUtils::expressionBinaryOperatorToOgcFilter( const QgsExpressio
20382039
{
20392040
// not implemented binary operators
20402041
// TODO: regex, % (mod), ^ (pow) are not supported yet
2041-
errorMessage = QString( "Binary operator %1 not implemented yet" ).arg( QgsExpression::BinaryOperatorText[op] );
2042+
errorMessage = QObject::tr( "Binary operator %1 not implemented yet" ).arg( QgsExpression::BinaryOperatorText[op] );
20422043
return QDomElement();
20432044
}
20442045

@@ -2077,7 +2078,7 @@ QDomElement QgsOgcUtils::expressionLiteralToOgcFilter( const QgsExpression::Node
20772078
break;
20782079

20792080
default:
2080-
errorMessage = QString( "Literal type not supported: %1" ).arg( node->value().type() );
2081+
errorMessage = QObject::tr( "Literal type not supported: %1" ).arg( node->value().type() );
20812082
return QDomElement();
20822083
}
20832084

@@ -2207,7 +2208,7 @@ QDomElement QgsOgcUtils::expressionFunctionToOgcFilter( const QgsExpression::Nod
22072208
{
22082209
delete geom;
22092210

2210-
errorMessage = QString( "<BBOX> is currently supported only in form: bbox($geometry, geomFromWKT('...'))" );
2211+
errorMessage = QObject::tr( "<BBOX> is currently supported only in form: bbox($geometry, geomFromWKT('...'))" );
22112212
return QDomElement();
22122213
}
22132214
}
@@ -2224,7 +2225,7 @@ QDomElement QgsOgcUtils::expressionFunctionToOgcFilter( const QgsExpression::Nod
22242225
otherNode = argNodes[0];
22252226
else
22262227
{
2227-
errorMessage = QString( "Unable to translate spatial operator: at least one must refer to geometry." );
2228+
errorMessage = QObject::tr( "Unable to translate spatial operator: at least one must refer to geometry." );
22282229
return QDomElement();
22292230
}
22302231

@@ -2233,7 +2234,7 @@ QDomElement QgsOgcUtils::expressionFunctionToOgcFilter( const QgsExpression::Nod
22332234
// the other node must be a geometry constructor
22342235
if ( otherNode->nodeType() != QgsExpression::ntFunction )
22352236
{
2236-
errorMessage = "spatial operator: the other operator must be a geometry constructor function";
2237+
errorMessage = QObject::tr( "spatial operator: the other operator must be a geometry constructor function" );
22372238
return QDomElement();
22382239
}
22392240

@@ -2244,7 +2245,7 @@ QDomElement QgsOgcUtils::expressionFunctionToOgcFilter( const QgsExpression::Nod
22442245
QgsExpression::Node* firstFnArg = otherFn->args()->list()[0];
22452246
if ( firstFnArg->nodeType() != QgsExpression::ntLiteral )
22462247
{
2247-
errorMessage = "geom_from_wkt: argument must be string literal";
2248+
errorMessage = QObject::tr( "geom_from_wkt: argument must be string literal" );
22482249
return QDomElement();
22492250
}
22502251
QString wkt = static_cast<const QgsExpression::NodeLiteral*>( firstFnArg )->value().toString();
@@ -2257,15 +2258,15 @@ QDomElement QgsOgcUtils::expressionFunctionToOgcFilter( const QgsExpression::Nod
22572258
QgsExpression::Node* firstFnArg = otherFn->args()->list()[0];
22582259
if ( firstFnArg->nodeType() != QgsExpression::ntLiteral )
22592260
{
2260-
errorMessage = "geom_from_gml: argument must be string literal";
2261+
errorMessage = QObject::tr( "geom_from_gml: argument must be string literal" );
22612262
return QDomElement();
22622263
}
22632264

22642265
QDomDocument geomDoc;
22652266
QString gml = static_cast<const QgsExpression::NodeLiteral*>( firstFnArg )->value().toString();
22662267
if ( !geomDoc.setContent( gml, true ) )
22672268
{
2268-
errorMessage = "geom_from_gml: unable to parse XML";
2269+
errorMessage = QObject::tr( "geom_from_gml: unable to parse XML" );
22692270
return QDomElement();
22702271
}
22712272

@@ -2274,7 +2275,7 @@ QDomElement QgsOgcUtils::expressionFunctionToOgcFilter( const QgsExpression::Nod
22742275
}
22752276
else
22762277
{
2277-
errorMessage = "spatial operator: unknown geometry constructor function";
2278+
errorMessage = QObject::tr( "spatial operator: unknown geometry constructor function" );
22782279
return QDomElement();
22792280
}
22802281

@@ -2288,7 +2289,7 @@ QDomElement QgsOgcUtils::expressionFunctionToOgcFilter( const QgsExpression::Nod
22882289

22892290
if ( fd->params() == 0 )
22902291
{
2291-
errorMessage = QString( "Special columns / constants are not supported." );
2292+
errorMessage = QObject::tr( "Special columns/constants are not supported." );
22922293
return QDomElement();
22932294
}
22942295

0 commit comments

Comments
 (0)