29 #include <QPushButton>
33 : QDialog( parent, flags )
37 mGeoPdfStructureTreeMenu =
new QMenu(
this );
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 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
63 mComboImageCompression->addItem( tr(
"Lossy (JPEG)" ),
false );
64 mComboImageCompression->addItem( tr(
"Lossless" ),
true );
66 mComboImageCompression->setDisabled(
true );
67 mComboImageCompression->addItem( tr(
"Lossy (JPEG)" ) );
68 mComboImageCompression->setCurrentIndex( 0 );
69 mComboImageCompression->setToolTip( tr(
"Lossless image compression is available only with QGIS builds using Qt 5.13 or later" ) );
74 for (
const QString &theme : themes )
76 QListWidgetItem *item =
new QListWidgetItem( theme );
77 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
78 item->setCheckState( Qt::Unchecked );
79 mThemesList->addItem( item );
85 for (
int i = 0; i < order.size(); ++i )
87 if ( order.at( i )->id() == *it )
95 mGeoPdfStructureProxyModel =
new QgsGeoPdfLayerFilteredTreeModel( mGeoPdfStructureModel,
this );
96 mGeoPdfStructureTree->setModel( mGeoPdfStructureProxyModel );
97 mGeoPdfStructureTree->resizeColumnToContents( 0 );
98 mGeoPdfStructureTree->header()->show();
99 mGeoPdfStructureTree->setSelectionMode( QAbstractItemView::SingleSelection );
100 mGeoPdfStructureTree->setSelectionBehavior( QAbstractItemView::SelectRows );
102 mGeoPdfStructureTree->setDragEnabled(
true );
103 mGeoPdfStructureTree->setAcceptDrops(
true );
104 mGeoPdfStructureTree->setDragDropMode( QAbstractItemView::InternalMove );
105 mGeoPdfStructureTree->setDefaultDropAction( Qt::MoveAction );
107 mGeoPdfStructureTree->setContextMenuPolicy( Qt::CustomContextMenu );
108 connect( mGeoPdfStructureTree, &QTreeView::customContextMenuRequested,
this, [ = ](
const QPoint & point )
110 const QModelIndex index = mGeoPdfStructureTree->indexAt( point );
111 if ( index.isValid() )
112 showContextMenuForGeoPdfStructure( point, mGeoPdfStructureProxyModel->mapToSource( index ) );
115 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutPdfExportOptionsDialog::showHelp );
121 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData( format ) );
131 mForceVectorCheckBox->setChecked( force );
136 return mForceVectorCheckBox->isChecked();
141 mAppendGeoreferenceCheckbox->setEnabled( enabled );
146 mAppendGeoreferenceCheckbox->setChecked( enabled );
151 return mAppendGeoreferenceCheckbox->isChecked();
156 mIncludeMetadataCheckbox->setChecked( enabled );
161 return mIncludeMetadataCheckbox->isChecked();
166 mDisableRasterTilingCheckBox->setChecked( disabled );
171 return mDisableRasterTilingCheckBox->isChecked();
176 mSimplifyGeometriesCheckbox->setChecked( enabled );
181 return mSimplifyGeometriesCheckbox->isChecked();
186 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
187 mComboImageCompression->setCurrentIndex( mComboImageCompression->findData( enabled ) );
195 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
196 return mComboImageCompression->currentData().toBool();
204 if ( !mGeopdfAvailable )
207 mGeoPDFGroupBox->setChecked( enabled );
212 if ( !mGeopdfAvailable )
215 return mGeoPDFGroupBox->isChecked();
220 if ( !mGeopdfAvailable )
224 mGeoPdfFormatComboBox->setCurrentIndex( 1 );
226 mGeoPdfFormatComboBox->setCurrentIndex( 0 );
231 if ( !mGeopdfAvailable )
234 return mGeoPdfFormatComboBox->currentIndex() == 1;
240 if ( !mGeopdfAvailable )
243 mIncludeMapThemesCheck->setChecked( !themes.isEmpty() );
244 for (
int i = 0; i < mThemesList->count(); ++i )
246 QListWidgetItem *item = mThemesList->item( i );
247 item->setCheckState( themes.contains( item->text() ) ? Qt::Checked : Qt::Unchecked );
254 if ( !mGeopdfAvailable )
257 if ( !mIncludeMapThemesCheck || !mIncludeMapThemesCheck->isChecked() )
260 res.reserve( mThemesList->count() );
261 for (
int i = 0; i < mThemesList->count(); ++i )
263 QListWidgetItem *item = mThemesList->item( i );
264 if ( item->checkState() == Qt::Checked )
273 for (
int row = 0; row < mGeoPdfStructureProxyModel->rowCount(); ++row )
280 void QgsLayoutPdfExportOptionsDialog::showHelp()
285 void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeoPdfStructure( QPoint point,
const QModelIndex &index )
287 mGeoPdfStructureTreeMenu->clear();
289 switch ( index.column() )
294 QAction *selectAll =
new QAction( tr(
"Select All" ), mGeoPdfStructureTreeMenu );
295 mGeoPdfStructureTreeMenu->addAction( selectAll );
296 connect( selectAll, &QAction::triggered,
this, [ = ]
298 mGeoPdfStructureModel->
checkAll(
true, QModelIndex(), index.column() );
300 QAction *deselectAll =
new QAction( tr(
"Deselect All" ), mGeoPdfStructureTreeMenu );
301 mGeoPdfStructureTreeMenu->addAction( deselectAll );
302 connect( deselectAll, &QAction::triggered,
this, [ = ]
304 mGeoPdfStructureModel->
checkAll(
false, QModelIndex(), index.column() );
313 if ( !mGeoPdfStructureTreeMenu->actions().empty() )
315 mGeoPdfStructureTreeMenu->exec( mGeoPdfStructureTree->mapToGlobal( point ) );