Skip to content

Commit

Permalink
Improve expression help
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 20, 2015
1 parent 6bfdafe commit b2c404d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
5 changes: 3 additions & 2 deletions resources/function_help/json/concat
@@ -1,9 +1,10 @@
{
"function": "concat",
"description": "Concatenates several strings to one.",
"description": "Concatenates several strings to one. NULL values are converted to empty strings.",
"variableLenArguments": true,
"arguments": [ {"arg":"string1", "syntaxOnly": true},
{"arg":"string2", "syntaxOnly": true},
{"arg":"string", "descOnly": true, "description":"a string value"}],
"examples": [ { "expression":"concat('a','b','c','d','e')", "returns":"'abcde'"}]
"examples": [ { "expression":"concat('a','b','c','d','e')", "returns":"'abcde'"},
{ "expression":"concat('The Wall', NULL)", "returns":"'The Wall'"}]
}
8 changes: 5 additions & 3 deletions resources/function_help/text/AND
Expand Up @@ -7,7 +7,9 @@ Returns 1 when condition a and b are true.
<h4>Arguments</h4>
None

<h4>Example</h4>
<pre> 4 = 2+2 AND 1 = 1 &rarr; returns 1 </pre>
<pre> 4 = 2+2 AND 1 = 2 &rarr; returns 0 </pre>
<h4>Examples</h4>
<pre> TRUE AND TRUE &rarr; 1 </pre>
<pre> TRUE AND FALSE &rarr; 0 </pre>
<pre> 4 = 2+2 AND 1 = 1 &rarr; 1 </pre>
<pre> 4 = 2+2 AND 1 = 2 &rarr; 0 </pre>

14 changes: 14 additions & 0 deletions resources/function_help/text/||
@@ -0,0 +1,14 @@
<h3>|| concatenation operator</h3>
<p>Joins two values together into a string.</p>
<p>If one of the values is NULL the result will be NULL. See the CONCAT function for a different behavior.</p>

<h4>Syntax</h4>
<pre> value1 || value2</pre>

<h4>Arguments</h4>
None

<h4>Examples</h4>
<pre> 'Here ' || 'and ' || 'there' &rarr; 'Here and there' </pre>
<pre> 'Nothing' || NULL &rarr; NULL </pre>
<pre> 1 || 2 &rarr; '12' </pre>
8 changes: 2 additions & 6 deletions src/gui/qgsexpressionbuilderwidget.cpp
Expand Up @@ -362,6 +362,7 @@ void QgsExpressionBuilderWidget::registerItem( QString group,
newgroupNode->setData( group, Qt::UserRole );
newgroupNode->setData( group == "Recent (Selection)" ? 2 : 1, QgsExpressionItem::CustomSortRole );
newgroupNode->appendRow( item );
newgroupNode->setBackground( QBrush( QColor( "#eee" ) ) );
mModel->appendRow( newgroupNode );
mExpressionGroups.insert( group, newgroupNode );
}
Expand Down Expand Up @@ -439,12 +440,7 @@ void QgsExpressionBuilderWidget::updateFunctionTree()
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)" ) )
.arg( tr( "Joins two values together into a string" ) )
.arg( tr( "Usage" ) )
.arg( tr( "'Dia' || Diameter" ) ) );
registerItem( "Operators", "||", " || " );
registerItem( "Operators", "IN", " IN " );
registerItem( "Operators", "LIKE", " LIKE " );
registerItem( "Operators", "ILIKE", " ILIKE " );
Expand Down

0 comments on commit b2c404d

Please sign in to comment.