Skip to content

Commit

Permalink
Added missing python bindings for table joins
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15327 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Mar 3, 2011
1 parent a8f8dcd commit 7975295
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 10 deletions.
48 changes: 47 additions & 1 deletion python/core/qgsvectorlayer.sip
Expand Up @@ -4,6 +4,27 @@ typedef QSet<int> QgsFeatureIds;
typedef QSet<int> QgsAttributeIds;


/** @note added in 1.7 */
struct QgsVectorJoinInfo
{
%TypeHeaderCode
#include "qgsvectorlayer.h"
%End

/**Join field in the target layer*/
int targetField;
/**Source layer*/
QString joinLayerId;
/**Join field in the source layer*/
int joinField;
/**True if the join is cached in virtual memory*/
bool memoryCache;
/**Cache for joined attributes to provide fast lookup (size is 0 if no memory caching)*/
// TODO: needs conversion
// QHash< QString, QgsAttributeMap> cachedAttributes;
};


class QgsVectorLayer : QgsMapLayer
{
%TypeHeaderCode
Expand Down Expand Up @@ -88,6 +109,19 @@ public:
/** Setup the coordinate system tranformation for the layer */
void setCoordinateSystem();

/** Joins another vector layer to this layer
@param joinInfo join object containing join layer id, target and source field
@param cacheInMemory if true: caches the content of the join layer in virtual memory
@note added in 1.7 */
void addJoin( QgsVectorJoinInfo joinInfo );

/** Removes a vector layer join
@note added in 1.7 */
void removeJoin( const QString& joinLayerId );

/** @note added in 1.7 */
const QList< QgsVectorJoinInfo >& vectorJoins() const;

QgsLabel *label();

QgsAttributeAction *actions();
Expand Down Expand Up @@ -549,12 +583,20 @@ public:
@note public and static from version 1.4 */
static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );

/** Assembles mUpdatedFields considering provider fields, joined fields and added fields
@note added in 1.7 */
void updateFieldMap();

/** Caches joined attributes if required (and not already done)
@note added in 1.7 */
void createJoinCaches();

/**Returns unique values for column
@param index column index for attribute
@param uniqueValues out: result list
@limit maximum number of values to return (-1 if unlimited)
@note: this method was added in version 1.7*/
void uniqueValues( int index, QList<QVariant>& uniqueValues, int limit );
void uniqueValues( int index, QList<QVariant>& uniqueValues /Out/, int limit );

public slots:

Expand All @@ -574,6 +616,10 @@ public slots:
*/
virtual void updateExtents();

/** Check if there is a join with a layer that will be removed
@note added in 1.7 */
void checkJoinLayerRemove( QString theLayerId );

signals:

/** This signal is emited when selection was changed */
Expand Down
26 changes: 17 additions & 9 deletions src/core/qgsvectorlayer.h
Expand Up @@ -55,6 +55,7 @@ typedef QList<int> QgsAttributeList;
typedef QSet<int> QgsFeatureIds;
typedef QSet<int> QgsAttributeIds;

/** @note added in 1.7 */
struct CORE_EXPORT QgsVectorJoinInfo
{
/**Join field in the target layer*/
Expand All @@ -69,8 +70,10 @@ struct CORE_EXPORT QgsVectorJoinInfo
QHash< QString, QgsAttributeMap> cachedAttributes;
};

/**Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAttributes().
Created in the select() method of QgsVectorLayerJoinBuffer for the joins that contain fetched attributes*/
/** Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAttributes().
Created in the select() method of QgsVectorLayerJoinBuffer for the joins that contain fetched attributes
@note added in 1.7
*/
struct CORE_EXPORT QgsFetchJoinInfo
{
const QgsVectorJoinInfo* joinInfo;
Expand Down Expand Up @@ -150,14 +153,17 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Setup the coordinate system tranformation for the layer */
void setCoordinateSystem();

/**Joins another vector layer to this layer
/** Joins another vector layer to this layer
@param joinInfo join object containing join layer id, target and source field
@param cacheInMemory if true: caches the content of the join layer in virtual memory*/
@param cacheInMemory if true: caches the content of the join layer in virtual memory
@note added in 1.7 */
void addJoin( QgsVectorJoinInfo joinInfo );

/**Removes a vector layer join*/
/** Removes a vector layer join
@note added in 1.7 */
void removeJoin( const QString& joinLayerId );

/** @note added in 1.7 */
const QList< QgsVectorJoinInfo >& vectorJoins() const;

/** Get the label object associated with this layer */
Expand Down Expand Up @@ -631,11 +637,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
@note public and static from version 1.4 */
static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );

/**Assembles mUpdatedFields considering provider fields, joined fields and added fields
@note added in version 1.6*/
/** Assembles mUpdatedFields considering provider fields, joined fields and added fields
@note added in 1.7 */
void updateFieldMap();

/**Caches joined attributes if required (and not already done)*/
/** Caches joined attributes if required (and not already done)
@note added in 1.7 */
void createJoinCaches();

/**Returns unique values for column
Expand Down Expand Up @@ -663,7 +670,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
virtual void updateExtents();

/**Check if there is a join with a layer that will be removed*/
/** Check if there is a join with a layer that will be removed
@note added in 1.7 */
void checkJoinLayerRemove( QString theLayerId );

signals:
Expand Down

0 comments on commit 7975295

Please sign in to comment.