Skip to content

Commit

Permalink
Added QgsSearchTreeNode::referencedColumns() utility function.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13351 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 23, 2010
1 parent fab9465 commit 54f6c94
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/core/qgssearchtreenode.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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:


Expand Down
24 changes: 24 additions & 0 deletions src/core/qgssearchtreenode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "qgssearchtreenode.h"
#include <QRegExp>
#include <QObject>
#include <QSet>
#include <QSettings>
#include <iostream>

Expand Down Expand Up @@ -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 )
{
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgssearchtreenode.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

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

#include <qgsfield.h>
Expand Down Expand Up @@ -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:


Expand Down

0 comments on commit 54f6c94

Please sign in to comment.