Skip to content
Permalink
Browse files

Added QgsSearchTreeNode::referencedColumns() utility function.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13351 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Apr 23, 2010
1 parent fab9465 commit 54f6c94fa8d52b902a400de5c5ce6928aa14451d
Showing with 33 additions and 0 deletions.
  1. +4 −0 python/core/qgssearchtreenode.sip
  2. +24 −0 src/core/qgssearchtreenode.cpp
  3. +5 −0 src/core/qgssearchtreenode.h
@@ -102,6 +102,10 @@ class QgsSearchTreeNode
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:


@@ -24,6 +24,7 @@
#include "qgssearchtreenode.h"
#include <QRegExp>
#include <QObject>
#include <QSet>
#include <QSettings>
#include <iostream>

@@ -225,6 +226,29 @@ QString QgsSearchTreeNode::makeSearchString()
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 )
{
@@ -22,6 +22,7 @@

#include <QMap>
#include <QString>
#include <QStringList>
#include <QVariant>

#include <qgsfield.h>
@@ -138,6 +139,10 @@ class CORE_EXPORT QgsSearchTreeNode
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:


0 comments on commit 54f6c94

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