|
26 | 26 |
|
27 | 27 | #include <QCheckBox>
|
28 | 28 | #include <QPushButton>
|
| 29 | +#include <QMenu> |
29 | 30 |
|
30 | 31 | QgsLayoutPdfExportOptionsDialog::QgsLayoutPdfExportOptionsDialog( QWidget *parent, Qt::WindowFlags flags )
|
31 | 32 | : QDialog( parent, flags )
|
32 | 33 | {
|
33 | 34 | setupUi( this );
|
34 | 35 |
|
| 36 | + mGeoPdfStructureTreeMenu = new QMenu( this ); |
| 37 | + |
35 | 38 | mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Paths (Recommended)" ), QgsRenderContext::TextFormatAlwaysOutlines );
|
36 | 39 | mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Text Objects" ), QgsRenderContext::TextFormatAlwaysText );
|
37 | 40 |
|
@@ -64,12 +67,20 @@ QgsLayoutPdfExportOptionsDialog::QgsLayoutPdfExportOptionsDialog( QWidget *paren
|
64 | 67 | mThemesList->addItem( item );
|
65 | 68 | }
|
66 | 69 |
|
67 |
| - QgsGeoPdfLayerTreeModel *model = new QgsGeoPdfLayerTreeModel( QgsProject::instance()->layerTreeRoot(), this ); |
68 |
| - mGeoPdfStructureTree->setModel( model ); |
| 70 | + mGeoPdfStructureModel = new QgsGeoPdfLayerTreeModel( QgsProject::instance()->layerTreeRoot(), this ); |
| 71 | + mGeoPdfStructureTree->setModel( mGeoPdfStructureModel ); |
69 | 72 | mGeoPdfStructureTree->resizeColumnToContents( 0 );
|
70 | 73 | mGeoPdfStructureTree->header()->show();
|
71 | 74 | mGeoPdfStructureTree->setSelectionMode( QAbstractItemView::NoSelection );
|
72 | 75 |
|
| 76 | + mGeoPdfStructureTree->setContextMenuPolicy( Qt::CustomContextMenu ); |
| 77 | + connect( mGeoPdfStructureTree, &QTreeView::customContextMenuRequested, this, [ = ]( const QPoint & point ) |
| 78 | + { |
| 79 | + const QModelIndex index = mGeoPdfStructureTree->indexAt( point ); |
| 80 | + if ( index.isValid() ) |
| 81 | + showContextMenuForGeoPdfStructure( point, index ); |
| 82 | + } ); |
| 83 | + |
73 | 84 | connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsLayoutPdfExportOptionsDialog::showHelp );
|
74 | 85 | QgsGui::enableAutoGeometryRestore( this );
|
75 | 86 | }
|
@@ -226,3 +237,36 @@ void QgsLayoutPdfExportOptionsDialog::showHelp()
|
226 | 237 | {
|
227 | 238 | QgsHelp::openHelp( QStringLiteral( "print_composer/create_output.html" ) );
|
228 | 239 | }
|
| 240 | + |
| 241 | +void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeoPdfStructure( QPoint point, const QModelIndex &index ) |
| 242 | +{ |
| 243 | + mGeoPdfStructureTreeMenu->clear(); |
| 244 | + |
| 245 | + switch ( index.column() ) |
| 246 | + { |
| 247 | + case 0: |
| 248 | + { |
| 249 | + QAction *selectAll = new QAction( tr( "Select All" ), mGeoPdfStructureTreeMenu ); |
| 250 | + mGeoPdfStructureTreeMenu->addAction( selectAll ); |
| 251 | + connect( selectAll, &QAction::triggered, this, [ = ] |
| 252 | + { |
| 253 | + mGeoPdfStructureModel->checkAll( true ); |
| 254 | + } ); |
| 255 | + QAction *deselectAll = new QAction( tr( "Deselect All" ), mGeoPdfStructureTreeMenu ); |
| 256 | + mGeoPdfStructureTreeMenu->addAction( deselectAll ); |
| 257 | + connect( deselectAll, &QAction::triggered, this, [ = ] |
| 258 | + { |
| 259 | + mGeoPdfStructureModel->checkAll( false ); |
| 260 | + } ); |
| 261 | + break; |
| 262 | + } |
| 263 | + |
| 264 | + default: |
| 265 | + break; |
| 266 | + } |
| 267 | + |
| 268 | + if ( !mGeoPdfStructureTreeMenu->actions().empty() ) |
| 269 | + { |
| 270 | + mGeoPdfStructureTreeMenu->exec( mGeoPdfStructureTree->mapToGlobal( point ) ); |
| 271 | + } |
| 272 | +} |
0 commit comments