Skip to content

Commit e2ec260

Browse files
committedJun 8, 2020
[geopdf] Expose option to set the initial visibility state of layers
in the created geopdf file from layouts Reworks the layer structure section of the GeoPDF export options dialog to add a new column allowing users to set the initial visibility state of layers included in the PDF. This fixes a usability issue with large generated GeoPDFs which can cause readers to grind to halt when opening complex GeoPDF files with many layers. Additionally, fixes an issue where users cannot set the logical GeoPDF group for non-vector layers Fixes #36536
1 parent 44046d7 commit e2ec260

12 files changed

+153
-115
lines changed
 

‎src/app/layout/qgslayoutdesignerdialog.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4382,7 +4382,6 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport
43824382
dialog.setGeometriesSimplified( simplify );
43834383
dialog.setExportGeoPdf( geoPdf );
43844384
dialog.setUseOgcBestPracticeFormat( useOgcBestPracticeFormat );
4385-
dialog.setExportGeoPdfFeatures( exportGeoPdfFeatures );
43864385
dialog.setExportThemes( exportThemes );
43874386

43884387
if ( dialog.exec() != QDialog::Accepted )
@@ -4396,7 +4395,6 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport
43964395
QgsRenderContext::TextRenderFormat textRenderFormat = dialog.textRenderFormat();
43974396
geoPdf = dialog.exportGeoPdf();
43984397
useOgcBestPracticeFormat = dialog.useOgcBestPracticeFormat();
4399-
exportGeoPdfFeatures = dialog.exportGeoPdfFeatures();
44004398
exportThemes = dialog.exportThemes();
44014399

44024400
if ( mLayout )
@@ -4410,7 +4408,6 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport
44104408
mLayout->setCustomProperty( QStringLiteral( "pdfSimplify" ), simplify ? 1 : 0 );
44114409
mLayout->setCustomProperty( QStringLiteral( "pdfCreateGeoPdf" ), geoPdf ? 1 : 0 );
44124410
mLayout->setCustomProperty( QStringLiteral( "pdfOgcBestPracticeFormat" ), useOgcBestPracticeFormat ? 1 : 0 );
4413-
mLayout->setCustomProperty( QStringLiteral( "pdfExportGeoPdfFeatures" ), exportGeoPdfFeatures ? 1 : 0 );
44144411
mLayout->setCustomProperty( QStringLiteral( "pdfExportThemes" ), exportThemes.join( QStringLiteral( "~~~" ) ) );
44154412
}
44164413

@@ -4422,7 +4419,6 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport
44224419
settings.writeGeoPdf = geoPdf;
44234420
settings.useOgcBestPracticeFormatGeoreferencing = useOgcBestPracticeFormat;
44244421
settings.useIso32000ExtensionFormatGeoreferencing = !useOgcBestPracticeFormat;
4425-
settings.includeGeoPdfFeatures = exportGeoPdfFeatures;
44264422
settings.exportThemes = exportThemes;
44274423
settings.predefinedMapScales = predefinedScales();
44284424

‎src/core/layout/qgslayoutexporter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToPdf( const QString &f
653653
}
654654

655655
details.customLayerTreeGroups = geoPdfExporter->customLayerTreeGroups();
656+
details.initialLayerVisibility = geoPdfExporter->initialLayerVisibility();
656657
details.includeFeatures = settings.includeGeoPdfFeatures;
657658
details.useOgcBestPracticeFormatGeoreferencing = settings.useOgcBestPracticeFormatGeoreferencing;
658659
details.useIso32000ExtensionFormatGeoreferencing = settings.useIso32000ExtensionFormatGeoreferencing;

‎src/core/layout/qgslayoutgeopdfexporter.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,22 @@ QgsLayoutGeoPdfExporter::QgsLayoutGeoPdfExporter( QgsLayout *layout )
115115
const QMap< QString, QgsMapLayer * > layers = mLayout->project()->mapLayers( true );
116116
for ( auto it = layers.constBegin(); it != layers.constEnd(); ++it )
117117
{
118-
if ( QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( it.value() ) )
118+
if ( QgsMapLayer *ml = it.value() )
119119
{
120-
const QVariant v = vl->customProperty( QStringLiteral( "geopdf/includeFeatures" ) );
121-
if ( !v.isValid() || v.toBool() )
120+
const QVariant visibility = ml->customProperty( QStringLiteral( "geopdf/initiallyVisible" ), true );
121+
mInitialLayerVisibility.insert( ml->id(), !visibility.isValid() ? true : visibility.toBool() );
122+
if ( ml->type() == QgsMapLayerType::VectorLayer )
122123
{
123-
exportableLayerIds << vl->id();
124+
const QVariant v = ml->customProperty( QStringLiteral( "geopdf/includeFeatures" ) );
125+
if ( !v.isValid() || v.toBool() )
126+
{
127+
exportableLayerIds << ml->id();
128+
}
124129
}
125130

126-
const QString groupName = vl->customProperty( QStringLiteral( "geopdf/groupName" ) ).toString();
131+
const QString groupName = ml->customProperty( QStringLiteral( "geopdf/groupName" ) ).toString();
127132
if ( !groupName.isEmpty() )
128-
mCustomLayerTreeGroups.insert( vl->id(), groupName );
133+
mCustomLayerTreeGroups.insert( ml->id(), groupName );
129134
}
130135
}
131136

‎src/core/layout/qgslayoutgeopdfexporter.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,22 @@ class CORE_EXPORT QgsLayoutGeoPdfExporter : public QgsAbstractGeoPdfExporter
6060
*/
6161
QMap< QString, QString > customLayerTreeGroups() const { return mCustomLayerTreeGroups; }
6262

63+
/**
64+
* Optional map of map layer ID to initial visibility state. If a layer ID is not present in this,
65+
* it will default to being initially visible when opening the PDF.
66+
*
67+
* \since QGIS 3.14
68+
*/
69+
QMap< QString, bool > initialLayerVisibility() const { return mInitialLayerVisibility; }
70+
6371
private:
6472

6573
VectorComponentDetail componentDetailForLayerId( const QString &layerId ) override;
6674

6775
QgsLayout *mLayout = nullptr;
6876
QHash< QgsLayoutItemMap *, QgsGeoPdfRenderedFeatureHandler * > mMapHandlers;
6977

78+
QMap< QString, bool > mInitialLayerVisibility;
7079
QMap< QString, QString > mCustomLayerTreeGroups;
7180

7281
friend class TestQgsLayoutGeoPdfExport;

‎src/core/qgsabstractgeopdfexporter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ QString QgsAbstractGeoPdfExporter::createCompositionXml( const QList<ComponentLa
274274
QDomElement layer = doc.createElement( QStringLiteral( "Layer" ) );
275275
layer.setAttribute( QStringLiteral( "id" ), component.group.isEmpty() ? component.mapLayerId : QStringLiteral( "%1_%2" ).arg( component.group, component.mapLayerId ) );
276276
layer.setAttribute( QStringLiteral( "name" ), details.layerIdToPdfLayerTreeNameMap.contains( component.mapLayerId ) ? details.layerIdToPdfLayerTreeNameMap.value( component.mapLayerId ) : component.name );
277-
layer.setAttribute( QStringLiteral( "initiallyVisible" ), QStringLiteral( "true" ) );
277+
layer.setAttribute( QStringLiteral( "initiallyVisible" ), details.initialLayerVisibility.value( component.mapLayerId, true ) ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
278278

279279
if ( !component.group.isEmpty() )
280280
{
@@ -302,7 +302,7 @@ QString QgsAbstractGeoPdfExporter::createCompositionXml( const QList<ComponentLa
302302
createdLayerIds[ component.group ].insert( component.mapLayerId );
303303
}
304304
}
305-
// some PDF components may not be linked to vector components - e.g. layers with labels but no features
305+
// some PDF components may not be linked to vector components - e.g. layers with labels but no features (or raster layers)
306306
for ( const ComponentLayerDetail &component : components )
307307
{
308308
if ( component.mapLayerId.isEmpty() || createdLayerIds.value( component.group ).contains( component.mapLayerId ) )
@@ -314,7 +314,7 @@ QString QgsAbstractGeoPdfExporter::createCompositionXml( const QList<ComponentLa
314314
QDomElement layer = doc.createElement( QStringLiteral( "Layer" ) );
315315
layer.setAttribute( QStringLiteral( "id" ), component.group.isEmpty() ? component.mapLayerId : QStringLiteral( "%1_%2" ).arg( component.group, component.mapLayerId ) );
316316
layer.setAttribute( QStringLiteral( "name" ), details.layerIdToPdfLayerTreeNameMap.contains( component.mapLayerId ) ? details.layerIdToPdfLayerTreeNameMap.value( component.mapLayerId ) : component.name );
317-
layer.setAttribute( QStringLiteral( "initiallyVisible" ), QStringLiteral( "true" ) );
317+
layer.setAttribute( QStringLiteral( "initiallyVisible" ), details.initialLayerVisibility.value( component.mapLayerId, true ) ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
318318

319319
if ( !component.group.isEmpty() )
320320
{

‎src/core/qgsabstractgeopdfexporter.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,21 @@ class CORE_EXPORT QgsAbstractGeoPdfExporter
252252
*/
253253
QMap< QString, QString > customLayerTreeGroups;
254254

255-
256255
/**
257256
* Optional map of map layer ID to custom layer tree name to show in the created PDF file.
258257
*
259258
* \since QGIS 3.14
260259
*/
261260
QMap< QString, QString > layerIdToPdfLayerTreeNameMap;
262261

262+
/**
263+
* Optional map of map layer ID to initial visibility state. If a layer ID is not present in this,
264+
* it will default to being initially visible when opening the PDF.
265+
*
266+
* \since QGIS 3.14
267+
*/
268+
QMap< QString, bool > initialLayerVisibility;
269+
263270
};
264271

265272
/**

‎src/gui/layout/qgsgeopdflayertreemodel.cpp

Lines changed: 89 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,47 @@ QgsGeoPdfLayerTreeModel::QgsGeoPdfLayerTreeModel( QgsLayerTree *rootNode, QObjec
3131
int QgsGeoPdfLayerTreeModel::columnCount( const QModelIndex &parent ) const
3232
{
3333
Q_UNUSED( parent )
34-
return 2;
34+
return 4;
3535
}
3636

3737
Qt::ItemFlags QgsGeoPdfLayerTreeModel::flags( const QModelIndex &idx ) const
3838
{
39-
if ( idx.column() == LayerColumn )
39+
if ( idx.column() == IncludeVectorAttributes )
40+
{
41+
if ( vectorLayer( idx ) )
42+
return QgsLayerTreeModel::flags( idx ) | Qt::ItemIsUserCheckable;
43+
else
44+
return QgsLayerTreeModel::flags( idx );
45+
}
46+
47+
if ( idx.column() == InitiallyVisible )
4048
{
4149
return QgsLayerTreeModel::flags( idx ) | Qt::ItemIsUserCheckable;
4250
}
4351

44-
QgsVectorLayer *vl = vectorLayer( idx );
45-
if ( !vl )
52+
if ( !mapLayer( idx ) )
4653
{
4754
return Qt::NoItemFlags;
4855
}
4956
else
5057
{
51-
const QModelIndex layerIndex = sibling( idx.row(), LayerColumn, idx );
52-
if ( data( layerIndex, Qt::CheckStateRole ) == Qt::Checked )
53-
{
54-
return Qt::ItemIsEnabled | Qt::ItemIsEditable;
55-
}
58+
return Qt::ItemIsEnabled | Qt::ItemIsEditable;
5659
}
5760
return Qt::NoItemFlags;
5861
}
5962

60-
QgsVectorLayer *QgsGeoPdfLayerTreeModel::vectorLayer( const QModelIndex &idx ) const
63+
QgsMapLayer *QgsGeoPdfLayerTreeModel::mapLayer( const QModelIndex &idx ) const
6164
{
6265
QgsLayerTreeNode *node = index2node( index( idx.row(), LayerColumn, idx.parent() ) );
6366
if ( !node || !QgsLayerTree::isLayer( node ) )
6467
return nullptr;
6568

66-
return qobject_cast<QgsVectorLayer *>( QgsLayerTree::toLayer( node )->layer() );
69+
return QgsLayerTree::toLayer( node )->layer();
70+
}
71+
72+
QgsVectorLayer *QgsGeoPdfLayerTreeModel::vectorLayer( const QModelIndex &idx ) const
73+
{
74+
return qobject_cast<QgsVectorLayer *>( mapLayer( idx ) );
6775
}
6876

6977
QVariant QgsGeoPdfLayerTreeModel::headerData( int section, Qt::Orientation orientation, int role ) const
@@ -74,10 +82,14 @@ QVariant QgsGeoPdfLayerTreeModel::headerData( int section, Qt::Orientation orien
7482
{
7583
switch ( section )
7684
{
77-
case 0:
85+
case LayerColumn:
7886
return tr( "Layer" );
79-
case 1:
87+
case GroupColumn:
8088
return tr( "PDF Group" );
89+
case InitiallyVisible:
90+
return tr( "Initially Visible" );
91+
case IncludeVectorAttributes:
92+
return tr( "Include Attributes" );
8193
default:
8294
return QVariant();
8395
}
@@ -91,44 +103,71 @@ QVariant QgsGeoPdfLayerTreeModel::data( const QModelIndex &idx, int role ) const
91103
switch ( idx.column() )
92104
{
93105
case LayerColumn:
106+
if ( role == Qt::CheckStateRole )
107+
return QVariant();
108+
109+
return QgsLayerTreeModel::data( idx, role );
110+
111+
case GroupColumn:
112+
{
113+
switch ( role )
114+
{
115+
case Qt::DisplayRole:
116+
case Qt::EditRole:
117+
{
118+
if ( QgsMapLayer *ml = mapLayer( idx ) )
119+
{
120+
return ml->customProperty( QStringLiteral( "geopdf/groupName" ) ).toString();
121+
}
122+
break;
123+
}
124+
}
125+
126+
return QVariant();
127+
}
128+
129+
case InitiallyVisible:
94130
{
95131
if ( role == Qt::CheckStateRole )
96132
{
97-
QgsLayerTreeNode *node = index2node( index( idx.row(), LayerColumn, idx.parent() ) );
98-
QgsVectorLayer *vl = vectorLayer( idx );
99-
if ( vl )
133+
if ( QgsMapLayer *ml = mapLayer( idx ) )
100134
{
101-
const QVariant v = vl->customProperty( QStringLiteral( "geopdf/includeFeatures" ) );
135+
const QVariant v = ml->customProperty( QStringLiteral( "geopdf/initiallyVisible" ) );
102136
if ( v.isValid() )
103137
{
104138
return v.toBool() ? Qt::Checked : Qt::Unchecked;
105139
}
106140
else
107141
{
108-
// otherwise, we default to the layer's visibility
109-
return node->itemVisibilityChecked() ? Qt::Checked : Qt::Unchecked;
142+
// otherwise, we default to showing by default
143+
return Qt::Checked;
110144
}
111145
}
112146
return QVariant();
113147
}
114148
return QgsLayerTreeModel::data( idx, role );
115149
}
116-
case GroupColumn:
150+
151+
case IncludeVectorAttributes:
117152
{
118-
switch ( role )
153+
if ( role == Qt::CheckStateRole )
119154
{
120-
case Qt::DisplayRole:
121-
case Qt::EditRole:
155+
QgsLayerTreeNode *node = index2node( index( idx.row(), LayerColumn, idx.parent() ) );
156+
if ( QgsVectorLayer *vl = vectorLayer( idx ) )
122157
{
123-
if ( QgsVectorLayer *vl = vectorLayer( idx ) )
158+
const QVariant v = vl->customProperty( QStringLiteral( "geopdf/includeFeatures" ) );
159+
if ( v.isValid() )
124160
{
125-
return vl->customProperty( QStringLiteral( "geopdf/groupName" ) ).toString();
161+
return v.toBool() ? Qt::Checked : Qt::Unchecked;
162+
}
163+
else
164+
{
165+
// otherwise, we default to the layer's visibility
166+
return node->itemVisibilityChecked() ? Qt::Checked : Qt::Unchecked;
126167
}
127-
break;
128168
}
169+
return QVariant();
129170
}
130-
131-
return QVariant();
132171
}
133172
}
134173

@@ -139,7 +178,7 @@ bool QgsGeoPdfLayerTreeModel::setData( const QModelIndex &index, const QVariant
139178
{
140179
switch ( index.column() )
141180
{
142-
case LayerColumn:
181+
case IncludeVectorAttributes:
143182
{
144183
if ( role == Qt::CheckStateRole )
145184
{
@@ -157,9 +196,23 @@ bool QgsGeoPdfLayerTreeModel::setData( const QModelIndex &index, const QVariant
157196
{
158197
if ( role == Qt::EditRole )
159198
{
160-
if ( QgsVectorLayer *vl = vectorLayer( index ) )
199+
if ( QgsMapLayer *ml = mapLayer( index ) )
161200
{
162-
vl->setCustomProperty( QStringLiteral( "geopdf/groupName" ), value.toString() );
201+
ml->setCustomProperty( QStringLiteral( "geopdf/groupName" ), value.toString() );
202+
emit dataChanged( index, index );
203+
return true;
204+
}
205+
}
206+
break;
207+
}
208+
209+
case InitiallyVisible:
210+
{
211+
if ( role == Qt::CheckStateRole )
212+
{
213+
if ( QgsMapLayer *ml = mapLayer( index ) )
214+
{
215+
ml->setCustomProperty( QStringLiteral( "geopdf/initiallyVisible" ), value.toInt() == Qt::Checked );
163216
emit dataChanged( index, index );
164217
return true;
165218
}
@@ -170,16 +223,17 @@ bool QgsGeoPdfLayerTreeModel::setData( const QModelIndex &index, const QVariant
170223
return false;
171224
}
172225

173-
void QgsGeoPdfLayerTreeModel::checkAll( bool checked, const QModelIndex &parent )
226+
void QgsGeoPdfLayerTreeModel::checkAll( bool checked, const QModelIndex &parent, int column )
174227
{
175228
for ( int row = 0; row < rowCount( parent ); ++row )
176229
{
177-
const QModelIndex childIndex = index( row, LayerColumn, parent );
230+
const QModelIndex childIndex = index( row, column, parent );
178231
setData( childIndex, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole );
179232
checkAll( checked, childIndex );
180233
}
181234
}
182235

236+
183237
///@cond PRIVATE
184238
QgsGeoPdfLayerFilteredTreeModel::QgsGeoPdfLayerFilteredTreeModel( QgsGeoPdfLayerTreeModel *sourceModel, QObject *parent )
185239
: QSortFilterProxyModel( parent )
@@ -192,13 +246,10 @@ bool QgsGeoPdfLayerFilteredTreeModel::filterAcceptsRow( int source_row, const QM
192246
{
193247
if ( QgsLayerTreeNode *node = mLayerTreeModel->index2node( sourceModel()->index( source_row, 0, source_parent ) ) )
194248
{
195-
// filter out non-vector layers
196-
if ( QgsLayerTree::isLayer( node ) && QgsLayerTree::toLayer( node ) && QgsLayerTree::toLayer( node )->layer() && QgsLayerTree::toLayer( node )->layer()->type() != QgsMapLayerType::VectorLayer )
249+
// filter out non-spatial layers
250+
if ( QgsLayerTree::isLayer( node ) && QgsLayerTree::toLayer( node ) && QgsLayerTree::toLayer( node )->layer() && !QgsLayerTree::toLayer( node )->layer()->isSpatial() )
197251
return false;
198252

199-
// also filter out non-spatial vector layers
200-
if ( !qobject_cast< QgsVectorLayer * >( QgsLayerTree::toLayer( node )->layer() )->isSpatial() )
201-
return false;
202253
}
203254
return true;
204255
}

‎src/gui/layout/qgsgeopdflayertreemodel.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ class GUI_EXPORT QgsGeoPdfLayerTreeModel : public QgsLayerTreeModel
4040
Q_OBJECT
4141

4242
public:
43+
enum Columns
44+
{
45+
LayerColumn = 0,
46+
GroupColumn,
47+
InitiallyVisible,
48+
IncludeVectorAttributes
49+
};
50+
4351
//! constructor
4452
QgsGeoPdfLayerTreeModel( QgsLayerTree *rootNode, QObject *parent = nullptr );
4553

@@ -52,15 +60,11 @@ class GUI_EXPORT QgsGeoPdfLayerTreeModel : public QgsLayerTreeModel
5260
/**
5361
* Checks (or unchecks) all rows and children from the specified \a parent index.
5462
*/
55-
void checkAll( bool checked, const QModelIndex &parent = QModelIndex() );
63+
void checkAll( bool checked, const QModelIndex &parent = QModelIndex(), int column = IncludeVectorAttributes );
5664

5765
private:
58-
enum Columns
59-
{
60-
LayerColumn = 0,
61-
GroupColumn
62-
};
6366

67+
QgsMapLayer *mapLayer( const QModelIndex &idx ) const;
6468
QgsVectorLayer *vectorLayer( const QModelIndex &idx ) const;
6569
};
6670

‎src/gui/layout/qgslayoutpdfexportoptionsdialog.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -186,21 +186,6 @@ bool QgsLayoutPdfExportOptionsDialog::useOgcBestPracticeFormat() const
186186
return mGeoPdfFormatComboBox->currentIndex() == 1;
187187
}
188188

189-
void QgsLayoutPdfExportOptionsDialog::setExportGeoPdfFeatures( bool enabled )
190-
{
191-
if ( !mGeopdfAvailable )
192-
return;
193-
194-
mExportGeoPdfFeaturesCheckBox->setChecked( enabled );
195-
}
196-
197-
bool QgsLayoutPdfExportOptionsDialog::exportGeoPdfFeatures() const
198-
{
199-
if ( !mGeopdfAvailable )
200-
return false;
201-
202-
return mExportGeoPdfFeaturesCheckBox->isChecked();
203-
}
204189

205190
void QgsLayoutPdfExportOptionsDialog::setExportThemes( const QStringList &themes )
206191
{
@@ -245,19 +230,20 @@ void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeoPdfStructure( QPoint
245230

246231
switch ( index.column() )
247232
{
248-
case 0:
233+
case QgsGeoPdfLayerTreeModel::IncludeVectorAttributes:
234+
case QgsGeoPdfLayerTreeModel::InitiallyVisible:
249235
{
250236
QAction *selectAll = new QAction( tr( "Select All" ), mGeoPdfStructureTreeMenu );
251237
mGeoPdfStructureTreeMenu->addAction( selectAll );
252238
connect( selectAll, &QAction::triggered, this, [ = ]
253239
{
254-
mGeoPdfStructureModel->checkAll( true );
240+
mGeoPdfStructureModel->checkAll( true, QModelIndex(), index.column() );
255241
} );
256242
QAction *deselectAll = new QAction( tr( "Deselect All" ), mGeoPdfStructureTreeMenu );
257243
mGeoPdfStructureTreeMenu->addAction( deselectAll );
258244
connect( deselectAll, &QAction::triggered, this, [ = ]
259245
{
260-
mGeoPdfStructureModel->checkAll( false );
246+
mGeoPdfStructureModel->checkAll( false, QModelIndex(), index.column() );
261247
} );
262248
break;
263249
}

‎src/gui/layout/qgslayoutpdfexportoptionsdialog.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ class GUI_EXPORT QgsLayoutPdfExportOptionsDialog: public QDialog, private Ui::Qg
9292
//! Returns whether use of OGC best-practice format is enabled
9393
bool useOgcBestPracticeFormat() const;
9494

95-
//! Sets whether to export Geo-PDF features
96-
void setExportGeoPdfFeatures( bool enabled );
97-
//! Returns whether export of Geo-PDF features is enabled
98-
bool exportGeoPdfFeatures() const;
99-
10095
//! Sets the list of export themes
10196
void setExportThemes( const QStringList &themes );
10297
//! Returns the list of export themes

‎src/ui/layout/qgspdfexportoptions.ui

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@
9999
<property name="geometry">
100100
<rect>
101101
<x>0</x>
102-
<y>-214</y>
102+
<y>0</y>
103103
<width>451</width>
104-
<height>616</height>
104+
<height>630</height>
105105
</rect>
106106
</property>
107107
<layout class="QVBoxLayout" name="verticalLayout_6">
@@ -140,7 +140,7 @@
140140
</layout>
141141
</widget>
142142
<widget class="QWidget" name="page_2">
143-
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,0">
143+
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,2,5" columnstretch="0,0">
144144
<property name="leftMargin">
145145
<number>0</number>
146146
</property>
@@ -171,13 +171,23 @@
171171
</layout>
172172
</widget>
173173
</item>
174+
<item row="1" column="0">
175+
<widget class="QLabel" name="label">
176+
<property name="text">
177+
<string>Format</string>
178+
</property>
179+
</widget>
180+
</item>
181+
<item row="1" column="1">
182+
<widget class="QComboBox" name="mGeoPdfFormatComboBox"/>
183+
</item>
174184
<item row="3" column="0" colspan="2">
175-
<widget class="QgsCollapsibleGroupBoxBasic" name="mExportGeoPdfFeaturesCheckBox">
185+
<widget class="QGroupBox" name="mExportGeoPdfFeaturesCheckBox">
176186
<property name="title">
177-
<string>Include vector feature information</string>
187+
<string>Layer Structure</string>
178188
</property>
179189
<property name="checkable">
180-
<bool>true</bool>
190+
<bool>false</bool>
181191
</property>
182192
<layout class="QVBoxLayout" name="verticalLayout_5">
183193
<item>
@@ -200,36 +210,10 @@
200210
</layout>
201211
</widget>
202212
</item>
203-
<item row="1" column="0">
204-
<widget class="QLabel" name="label">
205-
<property name="text">
206-
<string>Format</string>
207-
</property>
208-
</widget>
209-
</item>
210-
<item row="1" column="1">
211-
<widget class="QComboBox" name="mGeoPdfFormatComboBox"/>
212-
</item>
213213
</layout>
214214
</widget>
215215
</widget>
216216
</item>
217-
<item>
218-
<spacer name="verticalSpacer">
219-
<property name="orientation">
220-
<enum>Qt::Vertical</enum>
221-
</property>
222-
<property name="sizeType">
223-
<enum>QSizePolicy::Expanding</enum>
224-
</property>
225-
<property name="sizeHint" stdset="0">
226-
<size>
227-
<width>20</width>
228-
<height>40</height>
229-
</size>
230-
</property>
231-
</spacer>
232-
</item>
233217
</layout>
234218
</widget>
235219
</widget>

‎tests/src/core/testqgsgeopdfexport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ void TestQgsGeoPdfExport::testComposition()
226226
QList< QgsAbstractGeoPdfExporter::ComponentLayerDetail > renderedLayers; // no extra layers for now
227227
QgsAbstractGeoPdfExporter::ExportDetails details;
228228
details.layerIdToPdfLayerTreeNameMap.insert( QStringLiteral( "layer1" ), QStringLiteral( "my first layer" ) );
229+
details.initialLayerVisibility.insert( QStringLiteral( "layer2" ), false );
229230
QString composition = geoPdfExporter.createCompositionXml( renderedLayers, details );
230231
QgsDebugMsg( composition );
231232
QDomDocument doc;
@@ -261,8 +262,7 @@ void TestQgsGeoPdfExport::testComposition()
261262

262263
QCOMPARE( layerTreeList.at( layer2Idx ).toElement().attribute( QStringLiteral( "id" ) ), QStringLiteral( "layer2" ) );
263264
QCOMPARE( layerTreeList.at( layer2Idx ).toElement().attribute( QStringLiteral( "name" ) ), QStringLiteral( "name layer2" ) );
264-
QCOMPARE( layerTreeList.at( layer2Idx ).toElement().attribute( QStringLiteral( "initiallyVisible" ) ), QStringLiteral( "true" ) );
265-
265+
QCOMPARE( layerTreeList.at( layer2Idx ).toElement().attribute( QStringLiteral( "initiallyVisible" ) ), QStringLiteral( "false" ) );
266266
}
267267

268268
void TestQgsGeoPdfExport::testMetadata()

0 commit comments

Comments
 (0)
Please sign in to comment.