mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[FEATURE] implement title() expression
This commit is contained in:
parent
dc8ac451da
commit
de5f95b6f4
13
resources/function_help/title-de_DE
Normal file
13
resources/function_help/title-de_DE
Normal file
@ -0,0 +1,13 @@
|
||||
<h3>Funktion title()</h3>
|
||||
Wandelt alle Worte einer Zeichenkette in Kleinbuchstaben mit großem Anfangsbuchstaben um.
|
||||
|
||||
<p><h4>Syntax</h4>
|
||||
title(<i>zeichenkette</i>)</p>
|
||||
|
||||
<p><h4>Argumente</h4>
|
||||
<!-- List args for functions here-->
|
||||
<i> zeichenkette</i> → ist eine Zeichenkette. Die Zeichenkette, deren Worte in Kleinbuchstaben mit großem Anfangsbuchstaben umgewandelt werden.</p>
|
||||
|
||||
<p><h4>Beispiel</h4>
|
||||
<!-- Show example of function.-->
|
||||
title('hello WOrld') → 'Hello World'</p>
|
14
resources/function_help/title_en_US
Normal file
14
resources/function_help/title_en_US
Normal file
@ -0,0 +1,14 @@
|
||||
<h3>title() function</h3>
|
||||
Converts all words of a string to title case (all words lower case with leading
|
||||
capital letter).
|
||||
|
||||
<p><h4>Syntax</h4>
|
||||
title(<i>string</i>)</p>
|
||||
|
||||
<p><h4>Arguments</h4>
|
||||
<!-- List args for functions here-->
|
||||
<i> string</i> → is string. The string to convert to title case.</p>
|
||||
|
||||
<p><h4>Example</h4>
|
||||
<!-- Show example of function.-->
|
||||
upper('hello WOrld') → 'Hello World'</p>
|
@ -450,6 +450,17 @@ static QVariant fcnUpper( const QVariantList& values, QgsFeature* , QgsExpressio
|
||||
QString str = getStringValue( values.at( 0 ), parent );
|
||||
return QVariant( str.toUpper() );
|
||||
}
|
||||
static QVariant fcnTitle( const QVariantList& values, QgsFeature* , QgsExpression* parent )
|
||||
{
|
||||
QString str = getStringValue( values.at( 0 ), parent );
|
||||
QStringList elems = str.split( " " );
|
||||
for ( int i = 0; i < elems.size(); i++ )
|
||||
{
|
||||
if ( elems[i].size() > 1 )
|
||||
elems[i] = elems[i].left( 1 ).toUpper() + elems[i].mid( 1 ).toLower();
|
||||
}
|
||||
return QVariant( elems.join( " " ) );
|
||||
}
|
||||
static QVariant fcnLength( const QVariantList& values, QgsFeature* , QgsExpression* parent )
|
||||
{
|
||||
QString str = getStringValue( values.at( 0 ), parent );
|
||||
@ -800,6 +811,7 @@ const QList<QgsExpression::FunctionDef> &QgsExpression::BuiltinFunctions()
|
||||
// string manipulation
|
||||
<< FunctionDef( "lower", 1, fcnLower, QObject::tr( "String" ) )
|
||||
<< FunctionDef( "upper", 1, fcnUpper, QObject::tr( "String" ) )
|
||||
<< FunctionDef( "title", 1, fcnTitle, QObject::tr( "String" ) )
|
||||
<< FunctionDef( "length", 1, fcnLength, QObject::tr( "String" ) )
|
||||
<< FunctionDef( "replace", 3, fcnReplace, QObject::tr( "String" ) )
|
||||
<< FunctionDef( "regexp_replace", 3, fcnRegexpReplace, QObject::tr( "String" ) )
|
||||
|
Loading…
x
Reference in New Issue
Block a user