Skip to content
Permalink
Browse files

create joined layer to feed the join tab in vector layer properties

  • Loading branch information
3nids committed Oct 4, 2018
1 parent c842e54 commit 3ffd72a89c54751bc1d986bce93c9b4d39f97467
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/app/qgsappscreenshots.cpp
@@ -33,16 +33,26 @@
#include "qgsapplication.h"
#include "qgsoptions.h"
#include "qgsguiutils.h"
#include "qgsvectorlayerjoininfo.h"


QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
: mSaveDirectory( saveDirectory )
{
QString layerDef = QStringLiteral( "Point?crs=epsg:4326&field=pk:integer&field=my_text:string&field=my_integer:integer&field=my_double:double&key=pk" );
QString layerDef = QStringLiteral( "Point?crs=epsg:4326&field=pk:integer&field=my_text:string&field=fk_polygon:integer&field=my_double:double&key=pk" );
mLineLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Line Layer" ), QStringLiteral( "memory" ) );
layerDef = QStringLiteral( "Polygon?crs=epsg:2056&field=pk:integer&field=my_text:string&field=my_integer:integer&field=height:double&key=pk" );
mPolygonLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Polygon Layer" ), QStringLiteral( "memory" ) );

QgsVectorLayerJoinInfo join;
join.setTargetFieldName( "fk_polygon" );
join.setJoinLayer( mPolygonLayer );
join.setJoinFieldName( "pk" );
join.setUsingMemoryCache( true );
join.setEditable( true );
join.setCascadedDelete( true );
mLineLayer->addJoin( join );

QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>()
<< mLineLayer
<< mPolygonLayer );
@@ -195,8 +205,8 @@ void QgsAppScreenShots::takePicturesOf( Categories categories )

if ( !categories || categories.testFlag( VectorLayerProperties ) )
{
takeVectorLayerProperties();
takeVectorLayerProperties25DSymbol();
takeVectorLayerProperties();
}
}

@@ -214,6 +224,7 @@ void QgsAppScreenShots::takeVectorLayerProperties()
QString folder = QLatin1String( "working_with_vector/img/auto_generated/vector_layer_properties" );
QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties( mLineLayer, QgisApp::instance() );
dlg->show();
dlg->mJoinTreeWidget->expandAll(); // expand join tree
// ----------------
// do all the pages
for ( int row = 0; row < dlg->mOptionsListWidget->count(); ++row )

0 comments on commit 3ffd72a

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