Skip to content

Commit 3ffd72a

Browse files
committed
create joined layer to feed the join tab in vector layer properties
1 parent c842e54 commit 3ffd72a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/app/qgsappscreenshots.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,26 @@
3333
#include "qgsapplication.h"
3434
#include "qgsoptions.h"
3535
#include "qgsguiutils.h"
36+
#include "qgsvectorlayerjoininfo.h"
3637

3738

3839
QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
3940
: mSaveDirectory( saveDirectory )
4041
{
41-
QString layerDef = QStringLiteral( "Point?crs=epsg:4326&field=pk:integer&field=my_text:string&field=my_integer:integer&field=my_double:double&key=pk" );
42+
QString layerDef = QStringLiteral( "Point?crs=epsg:4326&field=pk:integer&field=my_text:string&field=fk_polygon:integer&field=my_double:double&key=pk" );
4243
mLineLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Line Layer" ), QStringLiteral( "memory" ) );
4344
layerDef = QStringLiteral( "Polygon?crs=epsg:2056&field=pk:integer&field=my_text:string&field=my_integer:integer&field=height:double&key=pk" );
4445
mPolygonLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Polygon Layer" ), QStringLiteral( "memory" ) );
4546

47+
QgsVectorLayerJoinInfo join;
48+
join.setTargetFieldName( "fk_polygon" );
49+
join.setJoinLayer( mPolygonLayer );
50+
join.setJoinFieldName( "pk" );
51+
join.setUsingMemoryCache( true );
52+
join.setEditable( true );
53+
join.setCascadedDelete( true );
54+
mLineLayer->addJoin( join );
55+
4656
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>()
4757
<< mLineLayer
4858
<< mPolygonLayer );
@@ -195,8 +205,8 @@ void QgsAppScreenShots::takePicturesOf( Categories categories )
195205

196206
if ( !categories || categories.testFlag( VectorLayerProperties ) )
197207
{
198-
takeVectorLayerProperties();
199208
takeVectorLayerProperties25DSymbol();
209+
takeVectorLayerProperties();
200210
}
201211
}
202212

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

0 commit comments

Comments
 (0)