[QGIS Commit] r13351 - in trunk/qgis: python/core src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Apr 23 06:36:35 EDT 2010


Author: wonder
Date: 2010-04-23 06:36:34 -0400 (Fri, 23 Apr 2010)
New Revision: 13351

Modified:
   trunk/qgis/python/core/qgssearchtreenode.sip
   trunk/qgis/src/core/qgssearchtreenode.cpp
   trunk/qgis/src/core/qgssearchtreenode.h
Log:
Added QgsSearchTreeNode::referencedColumns() utility function.


Modified: trunk/qgis/python/core/qgssearchtreenode.sip
===================================================================
--- trunk/qgis/python/core/qgssearchtreenode.sip	2010-04-23 08:23:44 UTC (rev 13350)
+++ trunk/qgis/python/core/qgssearchtreenode.sip	2010-04-23 10:36:34 UTC (rev 13351)
@@ -102,6 +102,10 @@
     bool getValue( QgsSearchTreeValue& value /Out/, QgsSearchTreeNode* node,
                    const QMap<int,QgsField>& fields, const QMap<int,QVariant>& attributes, QgsGeometry* geom = 0 );
 
+    //! return a list of referenced columns in the tree
+    //! @note added in 1.5
+    QStringList referencedColumns();
+
   protected:
 
 

Modified: trunk/qgis/src/core/qgssearchtreenode.cpp
===================================================================
--- trunk/qgis/src/core/qgssearchtreenode.cpp	2010-04-23 08:23:44 UTC (rev 13350)
+++ trunk/qgis/src/core/qgssearchtreenode.cpp	2010-04-23 10:36:34 UTC (rev 13351)
@@ -24,6 +24,7 @@
 #include "qgssearchtreenode.h"
 #include <QRegExp>
 #include <QObject>
+#include <QSet>
 #include <QSettings>
 #include <iostream>
 
@@ -225,7 +226,30 @@
   return str;
 }
 
+QStringList QgsSearchTreeNode::referencedColumns()
+{
+  if ( mType == tOperator )
+  {
+    QStringList lst;
+    if ( mLeft )
+      lst += mLeft->referencedColumns();
+    if ( mRight )
+      lst += mRight->referencedColumns();
+    return lst.toSet().toList(); // make union and convert back to list
+  }
+  else if ( mType == tColumnRef )
+  {
+    return QStringList( mText );
+  }
+  else
+  {
+    // string or number - do nothing
+    return QStringList();
+  }
 
+}
+
+
 bool QgsSearchTreeNode::checkAgainst( const QgsFieldMap& fields, const QgsAttributeMap& attributes )
 {
   QgsDebugMsgLevel( "checkAgainst: " + makeSearchString(), 2 );

Modified: trunk/qgis/src/core/qgssearchtreenode.h
===================================================================
--- trunk/qgis/src/core/qgssearchtreenode.h	2010-04-23 08:23:44 UTC (rev 13350)
+++ trunk/qgis/src/core/qgssearchtreenode.h	2010-04-23 10:36:34 UTC (rev 13351)
@@ -22,6 +22,7 @@
 
 #include <QMap>
 #include <QString>
+#include <QStringList>
 #include <QVariant>
 
 #include <qgsfield.h>
@@ -138,6 +139,10 @@
     bool getValue( QgsSearchTreeValue& value, QgsSearchTreeNode* node,
                    const QgsFieldMap& fields, const QgsAttributeMap& attributes, QgsGeometry* geom = 0 );
 
+    //! return a list of referenced columns in the tree
+    //! @note added in 1.5
+    QStringList referencedColumns();
+
   protected:
 
 



More information about the QGIS-commit mailing list