Skip to content
Permalink
Browse files

Loading of function list from QgsExpression now working

  • Loading branch information
NathanW2 committed Sep 26, 2011
1 parent d90dcef commit f64ae1c7ea03570e1800bd27c2af7a185f5e96a7
Showing with 14 additions and 3 deletions.
  1. +6 −1 src/core/qgsexpression.cpp
  2. +5 −0 src/core/qgsexpression.h
  3. +3 −2 src/gui/qgsexpressionbuilder.cpp
@@ -386,7 +386,7 @@ bool QgsExpression::isFunctionName( QString name )

int QgsExpression::functionIndex( QString name )
{
int count = sizeof( BuiltinFunctions ) / sizeof( FunctionDef);
int count = functionCount();
for ( int i = 0; i < count; i++ )
{
if ( QString::compare( name, BuiltinFunctions[i].mName, Qt::CaseInsensitive ) == 0 )
@@ -395,6 +395,11 @@ int QgsExpression::functionIndex( QString name )
return -1;
}

int QgsExpression::functionCount()
{
return ( sizeof( BuiltinFunctions ) / sizeof( FunctionDef) );
}


QgsExpression::QgsExpression( const QString& expr )
: mExpression( expr ), mRowNumber( 0 ), mCalc( NULL )
@@ -194,6 +194,11 @@ class CORE_EXPORT QgsExpression
// return index of the function in BuiltinFunctions array
static int functionIndex( QString name );

/** Returns the number of functions defined in the parser
* @return The number of function defined in the parser.
*/
static int functionCount();

//! return quoted column reference (in double quotes)
static QString quotedColumnRef( QString name ) { return QString( "\"%1\"" ).arg( name.replace( "\"", "\"\"" ) ); }

@@ -41,13 +41,14 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget(QgsVectorLayer *layer)
"<br> Joins two values together into a string " \
"<br> <i>Usage:</i><br>'Dia' || Diameter");

int count = sizeof( QgsExpression::BuiltinFunctions ) / sizeof( QgsExpression::FunctionDef);
// Load the fuctions from the QgsExpression class
int count = QgsExpression::functionCount();
for ( int i = 0; i < count; i++ )
{
QgsExpression::FunctionDef func = QgsExpression::BuiltinFunctions[i];
QString name = func.mName;
if ( func.mParams >= 1 )
name + "(";
name += "(";
this->registerItem(func.mGroup,func.mName, " " + name + " ", func.mHelpText);
};
}

0 comments on commit f64ae1c

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