[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db
Juergen E. Fischer
jef at norbit.de
Tue Mar 20 13:43:04 UTC 2012
The following commit has been merged in the master branch:
commit 7dc309621829e39fe616c6ebddd85e5a8bd6f8b8
Author: Juergen E. Fischer <jef at norbit.de>
Date: Wed Mar 7 20:20:42 2012 +0100
fix #5132
diff --git a/src/core/qgsexpression.cpp b/src/core/qgsexpression.cpp
index d960b3f..5bb7959 100644
--- a/src/core/qgsexpression.cpp
+++ b/src/core/qgsexpression.cpp
@@ -104,7 +104,7 @@ inline bool isNull( const QVariant& v ) { return v.isNull(); }
const char* QgsExpression::BinaryOperatorText[] =
{
"OR", "AND",
- "=", "<>", "<=", ">=", "<", ">", "~", "LIKE", "ILIKE", "IS", "IS NOT",
+ "=", "<>", "<=", ">=", "<", ">", "~", "LIKE", "NOT LIKE", "ILIKE", "NOT ILIKE", "IS", "IS NOT",
"+", "-", "*", "/", "%", "^",
"||"
};
@@ -722,7 +722,9 @@ QVariant QgsExpression::NodeBinaryOperator::eval( QgsExpression* parent, QgsFeat
case boRegexp:
case boLike:
+ case boNotLike:
case boILike:
+ case boNotILike:
if ( isNull( vL ) || isNull( vR ) )
return TVL_Unknown;
else
@@ -731,17 +733,23 @@ QVariant QgsExpression::NodeBinaryOperator::eval( QgsExpression* parent, QgsFeat
QString regexp = getStringValue( vR, parent ); ENSURE_NO_EVAL_ERROR;
// TODO: cache QRegExp in case that regexp is a literal string (i.e. it will stay constant)
bool matches;
- if ( mOp == boLike || mOp == boILike ) // change from LIKE syntax to regexp
+ if ( mOp == boLike || mOp == boILike || mOp == boNotLike || mOp == boNotILike ) // change from LIKE syntax to regexp
{
// XXX escape % and _ ???
regexp.replace( "%", ".*" );
regexp.replace( "_", "." );
- matches = QRegExp( regexp, mOp == boLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
+ matches = QRegExp( regexp, mOp == boLike || mOp == boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
}
else
{
matches = QRegExp( regexp ).indexIn( str ) != -1;
}
+
+ if( mOp == boNotLike || mOp == boNotILike )
+ {
+ matches = !matches;
+ }
+
return matches ? TVL_True : TVL_False;
}
diff --git a/src/core/qgsexpression.h b/src/core/qgsexpression.h
index cdd0e6e..4f64f82 100644
--- a/src/core/qgsexpression.h
+++ b/src/core/qgsexpression.h
@@ -149,7 +149,9 @@ class CORE_EXPORT QgsExpression
boGT, // >
boRegexp,
boLike,
+ boNotLike,
boILike,
+ boNotILike,
boIs,
boIsNot,
diff --git a/src/core/qgsexpressionlexer.ll b/src/core/qgsexpressionlexer.ll
index 758c49c..78f1989 100644
--- a/src/core/qgsexpressionlexer.ll
+++ b/src/core/qgsexpressionlexer.ll
@@ -124,12 +124,14 @@ string "'"{str_char}*"'"
"<" { B_OP(boLT); return LT; }
">" { B_OP(boGT); return GT; }
-"~" { B_OP(boRegexp); return REGEXP; }
-"LIKE" { B_OP(boLike); return LIKE; }
-"ILIKE" { B_OP(boILike); return ILIKE; }
-"IS" { B_OP(boIs); return IS; }
-"IS NOT" { B_OP(boIsNot); return ISNOT; }
-"||" { B_OP(boConcat); return CONCAT; }
+"~" { B_OP(boRegexp); return REGEXP; }
+"LIKE" { B_OP(boLike); return LIKE; }
+"NOT LIKE" { B_OP(boNotLike); return LIKE; }
+"ILIKE" { B_OP(boILike); return LIKE; }
+"NOT ILIKE" { B_OP(boNotILike); return LIKE; }
+"IS" { B_OP(boIs); return IS; }
+"IS NOT" { B_OP(boIsNot); return IS; }
+"||" { B_OP(boConcat); return CONCAT; }
"+" { B_OP(boPlus); return PLUS; }
"-" { B_OP(boMinus); return MINUS; }
diff --git a/src/core/qgsexpressionparser.yy b/src/core/qgsexpressionparser.yy
index 75fa6e6..f96810e 100644
--- a/src/core/qgsexpressionparser.yy
+++ b/src/core/qgsexpressionparser.yy
@@ -74,7 +74,7 @@ QgsExpression::Node* gExpParserRootNode;
//
// operator tokens
-%token <b_op> OR AND EQ NE LE GE LT GT REGEXP LIKE ILIKE IS ISNOT PLUS MINUS MUL DIV MOD CONCAT POW
+%token <b_op> OR AND EQ NE LE GE LT GT REGEXP LIKE IS PLUS MINUS MUL DIV MOD CONCAT POW
%token <u_op> NOT
%token IN
@@ -114,7 +114,7 @@ QgsExpression::Node* gExpParserRootNode;
%left OR
%left AND
%right NOT
-%left EQ NE LE GE LT GT REGEXP LIKE ILIKE IS ISNOT IN
+%left EQ NE LE GE LT GT REGEXP LIKE IS IN
%left PLUS MINUS
%left MUL DIV MOD
%right POW
@@ -134,28 +134,26 @@ root: expression { gExpParserRootNode = $1; }
;
expression:
- expression AND expression { $$ = BINOP($2, $1, $3); }
- | expression OR expression { $$ = BINOP($2, $1, $3); }
- | expression EQ expression { $$ = BINOP($2, $1, $3); }
- | expression NE expression { $$ = BINOP($2, $1, $3); }
- | expression LE expression { $$ = BINOP($2, $1, $3); }
- | expression GE expression { $$ = BINOP($2, $1, $3); }
- | expression LT expression { $$ = BINOP($2, $1, $3); }
- | expression GT expression { $$ = BINOP($2, $1, $3); }
- | expression REGEXP expression { $$ = BINOP($2, $1, $3); }
- | expression LIKE expression { $$ = BINOP($2, $1, $3); }
- | expression ILIKE expression { $$ = BINOP($2, $1, $3); }
- | expression IS expression { $$ = BINOP($2, $1, $3); }
- | expression ISNOT expression { $$ = BINOP($2, $1, $3); }
- | expression PLUS expression { $$ = BINOP($2, $1, $3); }
- | expression MINUS expression { $$ = BINOP($2, $1, $3); }
- | expression MUL expression { $$ = BINOP($2, $1, $3); }
- | expression DIV expression { $$ = BINOP($2, $1, $3); }
- | expression MOD expression { $$ = BINOP($2, $1, $3); }
- | expression POW expression { $$ = BINOP($2, $1, $3); }
- | expression CONCAT expression { $$ = BINOP($2, $1, $3); }
- | NOT expression { $$ = new QgsExpression::NodeUnaryOperator($1, $2); }
- | '(' expression ')' { $$ = $2; }
+ expression AND expression { $$ = BINOP($2, $1, $3); }
+ | expression OR expression { $$ = BINOP($2, $1, $3); }
+ | expression EQ expression { $$ = BINOP($2, $1, $3); }
+ | expression NE expression { $$ = BINOP($2, $1, $3); }
+ | expression LE expression { $$ = BINOP($2, $1, $3); }
+ | expression GE expression { $$ = BINOP($2, $1, $3); }
+ | expression LT expression { $$ = BINOP($2, $1, $3); }
+ | expression GT expression { $$ = BINOP($2, $1, $3); }
+ | expression REGEXP expression { $$ = BINOP($2, $1, $3); }
+ | expression LIKE expression { $$ = BINOP($2, $1, $3); }
+ | expression IS expression { $$ = BINOP($2, $1, $3); }
+ | expression PLUS expression { $$ = BINOP($2, $1, $3); }
+ | expression MINUS expression { $$ = BINOP($2, $1, $3); }
+ | expression MUL expression { $$ = BINOP($2, $1, $3); }
+ | expression DIV expression { $$ = BINOP($2, $1, $3); }
+ | expression MOD expression { $$ = BINOP($2, $1, $3); }
+ | expression POW expression { $$ = BINOP($2, $1, $3); }
+ | expression CONCAT expression { $$ = BINOP($2, $1, $3); }
+ | NOT expression { $$ = new QgsExpression::NodeUnaryOperator($1, $2); }
+ | '(' expression ')' { $$ = $2; }
| FUNCTION '(' exp_list ')'
{
diff --git a/src/gui/qgsexpressionbuilderwidget.cpp b/src/gui/qgsexpressionbuilderwidget.cpp
index 450770a..2484015 100644
--- a/src/gui/qgsexpressionbuilderwidget.cpp
+++ b/src/gui/qgsexpressionbuilderwidget.cpp
@@ -180,7 +180,12 @@ void QgsExpressionBuilderWidget::fillFieldValues( int fieldIndex, int countLimit
mLayer->uniqueValues( fieldIndex, values, countLimit );
foreach( QVariant value, values )
{
- mValueListWidget->addItem( value.toString() );
+ if ( value.isNull() )
+ mValueListWidget->addItem( "NULL" );
+ else if ( value.type() == QVariant::Int || value.type() == QVariant::Double || value.type() == QVariant::LongLong )
+ mValueListWidget->addItem( value.toString() );
+ else
+ mValueListWidget->addItem( "'" + value.toString().replace( "'", "''" ) + "'" );
}
mValueListWidget->setUpdatesEnabled( true );
@@ -202,7 +207,7 @@ void QgsExpressionBuilderWidget::registerItem( QString group,
}
else
{
- // If the group doesn't exsit yet we make it first.
+ // If the group doesn't exist yet we make it first.
QgsExpressionItem* newgroupNode = new QgsExpressionItem( group, "", QgsExpressionItem::Header );
newgroupNode->appendRow( item );
mModel->appendRow( newgroupNode );
--
The Quantum GIS in Debian project
More information about the Pkg-grass-devel
mailing list