Skip to content

Commit

Permalink
create joined layer to feed the join tab in vector layer properties
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Oct 4, 2018
1 parent c842e54 commit 3ffd72a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/app/qgsappscreenshots.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,16 +33,26 @@
#include "qgsapplication.h" #include "qgsapplication.h"
#include "qgsoptions.h" #include "qgsoptions.h"
#include "qgsguiutils.h" #include "qgsguiutils.h"
#include "qgsvectorlayerjoininfo.h"




QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory ) QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
: mSaveDirectory( 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" ) ); 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" ); 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" ) ); 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 *>() QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>()
<< mLineLayer << mLineLayer
<< mPolygonLayer ); << mPolygonLayer );
Expand Down Expand Up @@ -195,8 +205,8 @@ void QgsAppScreenShots::takePicturesOf( Categories categories )


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


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

0 comments on commit 3ffd72a

Please sign in to comment.