33 : QDialog( parent, flags )
37 mGeoPdfStructureTreeMenu =
new QMenu(
this );
39 mTextRenderFormatComboBox->addItem( tr(
"Always Export Text as Paths (Recommended)" ),
static_cast< int >( Qgis::TextRenderFormat::AlwaysOutlines ) );
40 mTextRenderFormatComboBox->addItem( tr(
"Always Export Text as Text Objects" ),
static_cast< int >( Qgis::TextRenderFormat::AlwaysText ) );
43 mGeoPDFGroupBox->setEnabled( mGeopdfAvailable );
44 mGeoPDFGroupBox->setChecked(
false );
45 if ( !mGeopdfAvailable )
47 mGeoPDFOptionsStackedWidget->setCurrentIndex( 0 );
50 QPalette p = mGeoPdfUnavailableReason->palette();
51 p.setColor( QPalette::Disabled, QPalette::WindowText, QPalette::WindowText );
52 mGeoPdfUnavailableReason->setPalette( p );
53 mGeoPDFOptionsStackedWidget->removeWidget( mGeoPDFOptionsStackedWidget->widget( 1 ) );
57 mGeoPDFOptionsStackedWidget->setCurrentIndex( 1 );
58 mGeoPdfFormatComboBox->addItem( tr(
"ISO 32000 Extension (recommended)" ) );
59 mGeoPdfFormatComboBox->addItem( tr(
"OGC Best Practice" ) );
62 mComboImageCompression->addItem( tr(
"Lossy (JPEG)" ),
false );
63 mComboImageCompression->addItem( tr(
"Lossless" ),
true );
66 for (
const QString &theme : themes )
68 QListWidgetItem *item =
new QListWidgetItem( theme );
69 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
70 item->setCheckState( Qt::Unchecked );
71 mThemesList->addItem( item );
77 for (
int i = 0; i < order.size(); ++i )
79 if ( order.at( i )->id() == *it )
87 mGeoPdfStructureProxyModel =
new QgsGeoPdfLayerFilteredTreeModel( mGeoPdfStructureModel,
this );
88 mGeoPdfStructureTree->setModel( mGeoPdfStructureProxyModel );
89 mGeoPdfStructureTree->resizeColumnToContents( 0 );
90 mGeoPdfStructureTree->header()->show();
91 mGeoPdfStructureTree->setSelectionMode( QAbstractItemView::SingleSelection );
92 mGeoPdfStructureTree->setSelectionBehavior( QAbstractItemView::SelectRows );
94 mGeoPdfStructureTree->setDragEnabled(
true );
95 mGeoPdfStructureTree->setAcceptDrops(
true );
96 mGeoPdfStructureTree->setDragDropMode( QAbstractItemView::InternalMove );
97 mGeoPdfStructureTree->setDefaultDropAction( Qt::MoveAction );
99 mGeoPdfStructureTree->setContextMenuPolicy( Qt::CustomContextMenu );
100 connect( mGeoPdfStructureTree, &QTreeView::customContextMenuRequested,
this, [ = ](
const QPoint & point )
102 const QModelIndex index = mGeoPdfStructureTree->indexAt( point );
103 if ( index.isValid() )
104 showContextMenuForGeoPdfStructure( point, mGeoPdfStructureProxyModel->mapToSource( index ) );
107 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutPdfExportOptionsDialog::showHelp );
113 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData(
static_cast< int >( format ) ) );
123 mForceVectorCheckBox->setChecked( force );
128 return mForceVectorCheckBox->isChecked();
133 mAppendGeoreferenceCheckbox->setEnabled( enabled );
138 mAppendGeoreferenceCheckbox->setChecked( enabled );
143 return mAppendGeoreferenceCheckbox->isChecked();
148 mIncludeMetadataCheckbox->setChecked( enabled );
153 return mIncludeMetadataCheckbox->isChecked();
158 mDisableRasterTilingCheckBox->setChecked( disabled );
163 return mDisableRasterTilingCheckBox->isChecked();
168 mSimplifyGeometriesCheckbox->setChecked( enabled );
173 return mSimplifyGeometriesCheckbox->isChecked();
178 mComboImageCompression->setCurrentIndex( mComboImageCompression->findData( enabled ) );
183 return mComboImageCompression->currentData().toBool();
188 if ( !mGeopdfAvailable )
191 mGeoPDFGroupBox->setChecked( enabled );
196 if ( !mGeopdfAvailable )
199 return mGeoPDFGroupBox->isChecked();
204 if ( !mGeopdfAvailable )
208 mGeoPdfFormatComboBox->setCurrentIndex( 1 );
210 mGeoPdfFormatComboBox->setCurrentIndex( 0 );
215 if ( !mGeopdfAvailable )
218 return mGeoPdfFormatComboBox->currentIndex() == 1;
224 if ( !mGeopdfAvailable )
227 mIncludeMapThemesCheck->setChecked( !themes.isEmpty() );
228 for (
int i = 0; i < mThemesList->count(); ++i )
230 QListWidgetItem *item = mThemesList->item( i );
231 item->setCheckState( themes.contains( item->text() ) ? Qt::Checked : Qt::Unchecked );
238 if ( !mGeopdfAvailable )
241 if ( !mIncludeMapThemesCheck || !mIncludeMapThemesCheck->isChecked() )
244 res.reserve( mThemesList->count() );
245 for (
int i = 0; i < mThemesList->count(); ++i )
247 QListWidgetItem *item = mThemesList->item( i );
248 if ( item->checkState() == Qt::Checked )
257 for (
int row = 0; row < mGeoPdfStructureProxyModel->rowCount(); ++row )
264void QgsLayoutPdfExportOptionsDialog::showHelp()
269void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeoPdfStructure( QPoint point,
const QModelIndex &index )
271 mGeoPdfStructureTreeMenu->clear();
273 switch ( index.column() )
278 QAction *selectAll =
new QAction( tr(
"Select All" ), mGeoPdfStructureTreeMenu );
279 mGeoPdfStructureTreeMenu->addAction( selectAll );
280 connect( selectAll, &QAction::triggered,
this, [ = ]
282 mGeoPdfStructureModel->
checkAll(
true, QModelIndex(), index.column() );
284 QAction *deselectAll =
new QAction( tr(
"Deselect All" ), mGeoPdfStructureTreeMenu );
285 mGeoPdfStructureTreeMenu->addAction( deselectAll );
286 connect( deselectAll, &QAction::triggered,
this, [ = ]
288 mGeoPdfStructureModel->
checkAll(
false, QModelIndex(), index.column() );
297 if ( !mGeoPdfStructureTreeMenu->actions().empty() )
299 mGeoPdfStructureTreeMenu->exec( mGeoPdfStructureTree->mapToGlobal( point ) );
TextRenderFormat
Options for rendering text.
static bool geoPDFCreationAvailable()
Returns true if the current QGIS build is capable of GeoPDF support.
static QString geoPDFAvailabilityExplanation()
Returns a user-friendly, translated string explaining why GeoPDF export support is not available on t...
Layer tree model for Geo-PDF layers.
@ InitiallyVisible
Initial visiblity 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.
QgsLayoutPdfExportOptionsDialog(QWidget *parent=nullptr, bool allowGeoPdfExport=true, const QString &geoPdfReason=QString(), const QStringList &geoPdfLayerOrder=QStringList(), Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsLayoutPdfExportOptionsDialog.
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 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.
bool exportGeoPdf() const
Returns whether Geo-PDF export is enabled.
void setExportGeoPdf(bool enabled)
Sets whether to export a Geo-PDF.
QStringList geoPdfLayerOrder() const
Returns a list of map layer IDs in the desired order they should appear in a generated GeoPDF file.
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.
@ LayerIdRole
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.