33 : QDialog( parent, flags )
37 mGeospatialPdfStructureTreeMenu =
new QMenu(
this );
44 mGeospatialPDFGroupBox->setEnabled( mGeospatialPdfAvailable );
45 mGeospatialPDFGroupBox->setChecked(
false );
46 if ( !mGeospatialPdfAvailable )
48 mGeospatialPDFOptionsStackedWidget->setCurrentIndex( 0 );
51 QPalette p = mGeospatialPdfUnavailableReason->palette();
52 p.setColor( QPalette::Disabled, QPalette::WindowText, QPalette::WindowText );
53 mGeospatialPdfUnavailableReason->setPalette( p );
54 mGeospatialPDFOptionsStackedWidget->removeWidget( mGeospatialPDFOptionsStackedWidget->widget( 1 ) );
58 mGeospatialPDFOptionsStackedWidget->setCurrentIndex( 1 );
59 mGeospatialPdfFormatComboBox->addItem( tr(
"ISO 32000 Extension (recommended)" ) );
60 mGeospatialPdfFormatComboBox->addItem( tr(
"OGC Best Practice" ) );
63 mComboImageCompression->addItem( tr(
"Lossy (JPEG)" ), false );
64 mComboImageCompression->addItem( tr(
"Lossless" ), true );
67 for (
const QString &theme : themes )
69 QListWidgetItem *item =
new QListWidgetItem( theme );
70 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
71 item->setCheckState( Qt::Unchecked );
72 mThemesList->addItem( item );
78 for (
int i = 0; i < order.size(); ++i )
80 if ( order.at( i )->id() == *it )
88 mGeospatialPdfStructureProxyModel =
new QgsGeospatialPdfLayerFilteredTreeModel( mGeospatialPdfStructureModel,
this );
89 mGeospatialPdfStructureTree->setModel( mGeospatialPdfStructureProxyModel );
90 mGeospatialPdfStructureTree->resizeColumnToContents( 0 );
91 mGeospatialPdfStructureTree->header()->show();
92 mGeospatialPdfStructureTree->setSelectionMode( QAbstractItemView::SingleSelection );
93 mGeospatialPdfStructureTree->setSelectionBehavior( QAbstractItemView::SelectRows );
95 mGeospatialPdfStructureTree->setDragEnabled(
true );
96 mGeospatialPdfStructureTree->setAcceptDrops(
true );
97 mGeospatialPdfStructureTree->setDragDropMode( QAbstractItemView::InternalMove );
98 mGeospatialPdfStructureTree->setDefaultDropAction( Qt::MoveAction );
100 mGeospatialPdfStructureTree->setContextMenuPolicy( Qt::CustomContextMenu );
101 connect( mGeospatialPdfStructureTree, &QTreeView::customContextMenuRequested,
this, [ = ](
const QPoint & point )
103 const QModelIndex index = mGeospatialPdfStructureTree->indexAt( point );
104 if ( index.isValid() )
105 showContextMenuForGeospatialPdfStructure( point, mGeospatialPdfStructureProxyModel->mapToSource( index ) );
108 connect( mHelpButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutPdfExportOptionsDialog::showHelp );
114 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData(
static_cast< int >( format ) ) );
124 mForceVectorCheckBox->setChecked( force );
129 return mForceVectorCheckBox->isChecked();
134 mAppendGeoreferenceCheckbox->setEnabled( enabled );
139 mAppendGeoreferenceCheckbox->setChecked( enabled );
144 return mAppendGeoreferenceCheckbox->isChecked();
149 mIncludeMetadataCheckbox->setChecked( enabled );
154 return mIncludeMetadataCheckbox->isChecked();
159 mDisableRasterTilingCheckBox->setChecked( disabled );
164 return mDisableRasterTilingCheckBox->isChecked();
169 mSimplifyGeometriesCheckbox->setChecked( enabled );
174 return mSimplifyGeometriesCheckbox->isChecked();
179 mComboImageCompression->setCurrentIndex( mComboImageCompression->findData( enabled ) );
184 return mComboImageCompression->currentData().toBool();
189 if ( !mGeospatialPdfAvailable )
192 mGeospatialPDFGroupBox->setChecked( enabled );
197 if ( !mGeospatialPdfAvailable )
200 return mGeospatialPDFGroupBox->isChecked();
205 if ( !mGeospatialPdfAvailable )
209 mGeospatialPdfFormatComboBox->setCurrentIndex( 1 );
211 mGeospatialPdfFormatComboBox->setCurrentIndex( 0 );
216 if ( !mGeospatialPdfAvailable )
219 return mGeospatialPdfFormatComboBox->currentIndex() == 1;
225 if ( !mGeospatialPdfAvailable )
228 mIncludeMapThemesCheck->setChecked( !themes.isEmpty() );
229 for (
int i = 0; i < mThemesList->count(); ++i )
231 QListWidgetItem *item = mThemesList->item( i );
232 item->setCheckState( themes.contains( item->text() ) ? Qt::Checked : Qt::Unchecked );
239 if ( !mGeospatialPdfAvailable )
242 if ( !mIncludeMapThemesCheck || !mIncludeMapThemesCheck->isChecked() )
245 res.reserve( mThemesList->count() );
246 for (
int i = 0; i < mThemesList->count(); ++i )
248 QListWidgetItem *item = mThemesList->item( i );
249 if ( item->checkState() == Qt::Checked )
258 for (
int row = 0; row < mGeospatialPdfStructureProxyModel->rowCount(); ++row )
270 QStringList groupOrder;
271 for (
int row = 0; row < mGeospatialPdfStructureProxyModel->rowCount(); ++row )
274 if ( !group.isEmpty() && !groupOrder.contains( group ) )
282 mOpenAfterExportingCheckBox->setChecked( enabled );
287 return mOpenAfterExportingCheckBox->isChecked();
290void QgsLayoutPdfExportOptionsDialog::showHelp()
295void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeospatialPdfStructure( QPoint point,
const QModelIndex &index )
297 mGeospatialPdfStructureTreeMenu->clear();
299 switch ( index.column() )
304 QAction *selectAll =
new QAction( tr(
"Select All" ), mGeospatialPdfStructureTreeMenu );
305 mGeospatialPdfStructureTreeMenu->addAction( selectAll );
306 connect( selectAll, &QAction::triggered,
this, [ = ]
308 mGeospatialPdfStructureModel->
checkAll(
true, QModelIndex(), index.column() );
310 QAction *deselectAll =
new QAction( tr(
"Deselect All" ), mGeospatialPdfStructureTreeMenu );
311 mGeospatialPdfStructureTreeMenu->addAction( deselectAll );
312 connect( deselectAll, &QAction::triggered,
this, [ = ]
314 mGeospatialPdfStructureModel->
checkAll(
false, QModelIndex(), index.column() );
323 if ( !mGeospatialPdfStructureTreeMenu->actions().empty() )
325 mGeospatialPdfStructureTreeMenu->exec( mGeospatialPdfStructureTree->mapToGlobal( point ) );
TextRenderFormat
Options for rendering text.
@ PreferText
Render text as text objects, unless doing so results in rendering artifacts or poor quality rendering...
@ AlwaysOutlines
Always render text using path objects (AKA outlines/curves). This setting guarantees the best quality...
@ AlwaysText
Always render text as text objects. While this mode preserves text objects as text for post-processin...
static QString geospatialPDFAvailabilityExplanation()
Returns a user-friendly, translated string explaining why Geospatial PDF export support is not availa...
static bool geospatialPDFCreationAvailable()
Returns true if the current QGIS build is capable of Geospatial PDF support.
Layer tree model for Geo-PDF layers.
@ InitiallyVisible
Initial visibility state.
@ IncludeVectorAttributes
Vector attribute.
void checkAll(bool checked, const QModelIndex &parent=QModelIndex(), int column=IncludeVectorAttributes)
Checks (or unchecks) all rows and children from the specified parent index.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas.
void setExportGeospatialPdf(bool enabled)
Sets whether to export a Geospatial PDF.
void setOpenAfterExporting(bool enabled)
Sets whether to open the pdf after exporting it.
QStringList exportThemes() const
Returns the list of export themes.
bool useOgcBestPracticeFormat() const
Returns whether use of OGC best-practice format is enabled.
bool geometriesSimplified() const
Returns whether geometry simplification is enabled.
bool losslessImageExport() const
Returns whether lossless image compression is enabled.
void setLosslessImageExport(bool enabled)
Sets whether to use lossless image compression.
void setUseOgcBestPracticeFormat(bool enabled)
Sets whether to use OGC best-practice format.
bool exportGeospatialPdf() const
Returns whether Geospatial PDF export is enabled.
bool openAfterExporting() const
Returns whether the pdf should be opened after exporting it.
bool georeferencingEnabled() const
Returns whether georeferencing is enabled.
void setRasterTilingDisabled(bool disabled)
Sets whether to disable raster tiling.
bool forceVector() const
Returns whether vector output is being forced.
void setGeometriesSimplified(bool enabled)
Sets whether to simplify geometries.
bool metadataEnabled() const
Returns whether metadata is enabled.
void setGeoreferencingEnabled(bool enabled)
Sets whether to enable georeferencing.
void setMetadataEnabled(bool enabled)
Sets whether to enable metadata.
void enableGeoreferencingOptions(bool enabled)
Sets whether to enable georeferencing options.
QStringList geospatialPdfGroupOrder() const
Returns a list of groups in the desired order they should appear in a generated Geospatial PDF file.
QgsLayoutPdfExportOptionsDialog(QWidget *parent=nullptr, bool allowGeospatialPdfExport=true, const QString &geospatialPdfReason=QString(), const QStringList &geospatialPdfLayerOrder=QStringList(), Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsLayoutPdfExportOptionsDialog.
QStringList geospatialPdfLayerOrder() const
Returns a list of map layer IDs in the desired order they should appear in a generated Geospatial PDF...
void setTextRenderFormat(Qgis::TextRenderFormat format)
Sets the text render format.
Qgis::TextRenderFormat textRenderFormat() const
Returns the current text render format.
bool rasterTilingDisabled() const
Returns whether raster tiling is disabled.
void setForceVector(bool force)
Set whether to force vector output.
void setExportThemes(const QStringList &themes)
Sets the list of export themes.
@ LayerId
Stores the map layer ID.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.