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" ) );
63 for (
const QString &theme : themes )
65 QListWidgetItem *item =
new QListWidgetItem( theme );
66 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
67 item->setCheckState( Qt::Unchecked );
68 mThemesList->addItem( item );
74 for (
int i = 0; i < order.size(); ++i )
76 if ( order.at( i )->id() == *it )
84 mGeoPdfStructureProxyModel =
new QgsGeoPdfLayerFilteredTreeModel( mGeoPdfStructureModel,
this );
85 mGeoPdfStructureTree->setModel( mGeoPdfStructureProxyModel );
86 mGeoPdfStructureTree->resizeColumnToContents( 0 );
87 mGeoPdfStructureTree->header()->show();
88 mGeoPdfStructureTree->setSelectionMode( QAbstractItemView::SingleSelection );
89 mGeoPdfStructureTree->setSelectionBehavior( QAbstractItemView::SelectRows );
91 mGeoPdfStructureTree->setDragEnabled(
true );
92 mGeoPdfStructureTree->setAcceptDrops(
true );
93 mGeoPdfStructureTree->setDragDropMode( QAbstractItemView::InternalMove );
94 mGeoPdfStructureTree->setDefaultDropAction( Qt::MoveAction );
96 mGeoPdfStructureTree->setContextMenuPolicy( Qt::CustomContextMenu );
97 connect( mGeoPdfStructureTree, &QTreeView::customContextMenuRequested,
this, [ = ](
const QPoint & point )
99 const QModelIndex index = mGeoPdfStructureTree->indexAt( point );
100 if ( index.isValid() )
101 showContextMenuForGeoPdfStructure( point, mGeoPdfStructureProxyModel->mapToSource( index ) );
104 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutPdfExportOptionsDialog::showHelp );
110 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData( format ) );
120 mForceVectorCheckBox->setChecked( force );
125 return mForceVectorCheckBox->isChecked();
130 mAppendGeoreferenceCheckbox->setEnabled( enabled );
135 mAppendGeoreferenceCheckbox->setChecked( enabled );
140 return mAppendGeoreferenceCheckbox->isChecked();;
145 mIncludeMetadataCheckbox->setChecked( enabled );
150 return mIncludeMetadataCheckbox->isChecked();
155 mDisableRasterTilingCheckBox->setChecked( disabled );
160 return mDisableRasterTilingCheckBox->isChecked();
165 mSimplifyGeometriesCheckbox->setChecked( enabled );
170 return mSimplifyGeometriesCheckbox->isChecked();
175 if ( !mGeopdfAvailable )
178 mGeoPDFGroupBox->setChecked( enabled );
183 if ( !mGeopdfAvailable )
186 return mGeoPDFGroupBox->isChecked();
191 if ( !mGeopdfAvailable )
195 mGeoPdfFormatComboBox->setCurrentIndex( 1 );
197 mGeoPdfFormatComboBox->setCurrentIndex( 0 );
202 if ( !mGeopdfAvailable )
205 return mGeoPdfFormatComboBox->currentIndex() == 1;
211 if ( !mGeopdfAvailable )
214 mIncludeMapThemesCheck->setChecked( !themes.isEmpty() );
215 for (
int i = 0; i < mThemesList->count(); ++i )
217 QListWidgetItem *item = mThemesList->item( i );
218 item->setCheckState( themes.contains( item->text() ) ? Qt::Checked : Qt::Unchecked );
225 if ( !mGeopdfAvailable )
228 if ( !mIncludeMapThemesCheck || !mIncludeMapThemesCheck->isChecked() )
231 res.reserve( mThemesList->count() );
232 for (
int i = 0; i < mThemesList->count(); ++i )
234 QListWidgetItem *item = mThemesList->item( i );
235 if ( item->checkState() == Qt::Checked )
244 for (
int row = 0; row < mGeoPdfStructureProxyModel->rowCount(); ++row )
251 void QgsLayoutPdfExportOptionsDialog::showHelp()
256 void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeoPdfStructure( QPoint point,
const QModelIndex &index )
258 mGeoPdfStructureTreeMenu->clear();
260 switch ( index.column() )
265 QAction *selectAll =
new QAction( tr(
"Select All" ), mGeoPdfStructureTreeMenu );
266 mGeoPdfStructureTreeMenu->addAction( selectAll );
267 connect( selectAll, &QAction::triggered,
this, [ = ]
269 mGeoPdfStructureModel->
checkAll(
true, QModelIndex(), index.column() );
271 QAction *deselectAll =
new QAction( tr(
"Deselect All" ), mGeoPdfStructureTreeMenu );
272 mGeoPdfStructureTreeMenu->addAction( deselectAll );
273 connect( deselectAll, &QAction::triggered,
this, [ = ]
275 mGeoPdfStructureModel->
checkAll(
false, QModelIndex(), index.column() );
284 if ( !mGeoPdfStructureTreeMenu->actions().empty() )
286 mGeoPdfStructureTreeMenu->exec( mGeoPdfStructureTree->mapToGlobal( point ) );