[QGIS Commit] r13950 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jul 21 06:10:43 EDT 2010


Author: wonder
Date: 2010-07-21 10:10:43 +0000 (Wed, 21 Jul 2010)
New Revision: 13950

Modified:
   trunk/qgis/src/core/qgssearchtreenode.cpp
Log:
added missing conversions from expression tree nodes to string.


Modified: trunk/qgis/src/core/qgssearchtreenode.cpp
===================================================================
--- trunk/qgis/src/core/qgssearchtreenode.cpp	2010-07-21 08:41:24 UTC (rev 13949)
+++ trunk/qgis/src/core/qgssearchtreenode.cpp	2010-07-21 10:10:43 UTC (rev 13950)
@@ -190,9 +190,48 @@
   QString str;
   if ( mType == tOperator )
   {
-    str += "(";
-    if ( mOp != opNOT )
+    if ( mOp == opSQRT || mOp == opSIN || mOp == opCOS || mOp == opTAN ||
+         mOp == opASIN || mOp == opACOS || mOp == opATAN ||
+         mOp == opTOINT || mOp == opTOREAL || mOp == opTOSTRING )
     {
+      // functions
+      switch ( mOp )
+      {
+        case opSQRT: str += "sqrt"; break;
+        case opSIN: str += "sin"; break;
+        case opCOS: str += "cos"; break;
+        case opTAN: str += "tan"; break;
+        case opASIN: str += "asin"; break;
+        case opACOS: str += "acos"; break;
+        case opATAN: str += "atan"; break;
+        case opTOINT: str += "to int"; break;
+        case opTOREAL: str += "to real"; break;
+        case opTOSTRING: str += "to string"; break;
+        default: str += "?";
+      }
+      // currently all functions take one parameter
+      str += QString( "(%1)" ).arg( mLeft->makeSearchString() );
+    }
+    else if ( mOp == opLENGTH || mOp == opAREA || mOp == opROWNUM )
+    {
+      // special nullary opeators
+      switch ( mOp )
+      {
+        case opLENGTH: str += "$length"; break;
+        case opAREA: str += "$area"; break;
+        case opROWNUM: str += "$rownum"; break;
+        default: str += "?";
+      }
+    }
+    else if ( mOp == opNOT )
+    {
+      // unary NOT operator
+      str += "(NOT " + mLeft->makeSearchString() + ")";
+    }
+    else
+    {
+      // the rest of operator using infix notation
+      str += "(";
       if ( mLeft )
       {
         str += mLeft->makeSearchString();
@@ -206,6 +245,7 @@
         case opMINUS: str += "-"; break;
         case opMUL:   str += "*"; break;
         case opDIV:   str += "/"; break;
+        case opPOW:   str += "^"; break;
 
         case opEQ: str += " = "; break;
         case opNE: str += " != "; break;
@@ -214,10 +254,12 @@
         case opGE: str += " >= "; break;
         case opLE: str += " <= "; break;
 
+        case opISNULL: str += " IS NULL"; break;
+        case opISNOTNULL: str += " IS NOT NULL"; break;
+
         case opRegexp: str += " ~ "; break;
         case opLike: str += " LIKE "; break;
 
-          // TODO: other opeators / functions
         case opCONCAT: str += " || "; break;
 
         default: str += " ? ";
@@ -227,13 +269,8 @@
       {
         str += mRight->makeSearchString();
       }
+      str += ")";
     }
-    else
-    {
-      str += "NOT ";
-      str += mLeft->makeSearchString();
-    }
-    str += ")";
   }
   else if ( mType == tNumber )
   {



More information about the QGIS-commit mailing list