39 #include <QMessageBox>    44   , mMapCanvas( mapCanvas )
    49   connect( mScaleLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mScaleLineEdit_editingFinished );
    50   connect( mActionSetToCanvasExtent, &QAction::triggered, 
this, &QgsLayoutMapWidget::setToMapCanvasExtent );
    51   connect( mActionViewExtentInCanvas, &QAction::triggered, 
this, &QgsLayoutMapWidget::viewExtentInCanvas );
    52   connect( mActionSetToCanvasScale, &QAction::triggered, 
this, &QgsLayoutMapWidget::setToMapCanvasScale );
    53   connect( mActionViewScaleInCanvas, &QAction::triggered, 
this, &QgsLayoutMapWidget::viewScaleInCanvas );
    54   connect( mActionUpdatePreview, &QAction::triggered, 
this, &QgsLayoutMapWidget::updatePreview );
    55   connect( mFollowVisibilityPresetCheckBox, &QCheckBox::stateChanged, 
this, &QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged );
    56   connect( mKeepLayerListCheckBox, &QCheckBox::stateChanged, 
this, &QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged );
    57   connect( mKeepLayerStylesCheckBox, &QCheckBox::stateChanged, 
this, &QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged );
    58   connect( mDrawCanvasItemsCheckBox, &QCheckBox::stateChanged, 
this, &QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged );
    59   connect( mOverviewBlendModeComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged );
    60   connect( mOverviewInvertCheckbox, &QCheckBox::toggled, 
this, &QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled );
    61   connect( mOverviewCenterCheckbox, &QCheckBox::toggled, 
this, &QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled );
    62   connect( mOverviewPositionComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutMapWidget::overviewStackingChanged );
    64   connect( mXMinLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mXMinLineEdit_editingFinished );
    65   connect( mXMaxLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mXMaxLineEdit_editingFinished );
    66   connect( mYMinLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mYMinLineEdit_editingFinished );
    67   connect( mYMaxLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mYMaxLineEdit_editingFinished );
    68   connect( mAtlasMarginRadio, &QRadioButton::toggled, 
this, &QgsLayoutMapWidget::mAtlasMarginRadio_toggled );
    69   connect( mAtlasCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, 
this, &QgsLayoutMapWidget::mAtlasCheckBox_toggled );
    70   connect( mAtlasMarginSpinBox, static_cast < 
void ( QSpinBox::* )( 
int ) > ( &QSpinBox::valueChanged ), 
this, &QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged );
    71   connect( mAtlasFixedScaleRadio, &QRadioButton::toggled, 
this, &QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled );
    72   connect( mAtlasPredefinedScaleRadio, &QRadioButton::toggled, 
this, &QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled );
    73   connect( mAddGridPushButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mAddGridPushButton_clicked );
    74   connect( mRemoveGridPushButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mRemoveGridPushButton_clicked );
    75   connect( mGridUpButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mGridUpButton_clicked );
    76   connect( mGridDownButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mGridDownButton_clicked );
    77   connect( mGridListWidget, &QListWidget::currentItemChanged, 
this, &QgsLayoutMapWidget::mGridListWidget_currentItemChanged );
    78   connect( mGridListWidget, &QListWidget::itemChanged, 
this, &QgsLayoutMapWidget::mGridListWidget_itemChanged );
    79   connect( mGridPropertiesButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mGridPropertiesButton_clicked );
    80   connect( mAddOverviewPushButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mAddOverviewPushButton_clicked );
    81   connect( mRemoveOverviewPushButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked );
    82   connect( mOverviewUpButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mOverviewUpButton_clicked );
    83   connect( mOverviewDownButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mOverviewDownButton_clicked );
    84   connect( mOverviewCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, 
this, &QgsLayoutMapWidget::mOverviewCheckBox_toggled );
    85   connect( mOverviewListWidget, &QListWidget::currentItemChanged, 
this, &QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged );
    86   connect( mOverviewListWidget, &QListWidget::itemChanged, 
this, &QgsLayoutMapWidget::mOverviewListWidget_itemChanged );
    87   connect( mActionLabelSettings, &QAction::triggered, 
this, &QgsLayoutMapWidget::showLabelSettings );
    89   connect( mActionMoveContent, &QAction::triggered, 
this, &QgsLayoutMapWidget::switchToMoveContentTool );
    91   mMapRotationSpinBox->setClearValue( 0 );
    95   mBookmarkMenu = 
new QMenu( 
this );
    96   QToolButton *btnBookmarks = 
new QToolButton( 
this );
    97   btnBookmarks->setAutoRaise( 
true );
    98   btnBookmarks->setToolTip( tr( 
"Bookmarks" ) );
   100   btnBookmarks->setPopupMode( QToolButton::InstantPopup );
   101   btnBookmarks->setMenu( mBookmarkMenu );
   103   mDockToolbar->insertWidget( mActionMoveContent, btnBookmarks );
   104   connect( mBookmarkMenu, &QMenu::aboutToShow, 
this, &QgsLayoutMapWidget::aboutToShowBookmarkMenu );
   108   mainLayout->addWidget( mItemPropertiesWidget );
   110   mScaleLineEdit->setValidator( 
new QDoubleValidator( mScaleLineEdit ) );
   112   mXMinLineEdit->setValidator( 
new QDoubleValidator( mXMinLineEdit ) );
   113   mXMaxLineEdit->setValidator( 
new QDoubleValidator( mXMaxLineEdit ) );
   114   mYMinLineEdit->setValidator( 
new QDoubleValidator( mYMinLineEdit ) );
   115   mYMaxLineEdit->setValidator( 
new QDoubleValidator( mYMaxLineEdit ) );
   123   blockAllSignals( 
true );
   126   mCrsSelector->setNotSetText( tr( 
"Use Project CRS" ) );
   131   mFollowVisibilityPresetCombo->setModel( 
new QStringListModel( mFollowVisibilityPresetCombo ) );
   132   connect( mFollowVisibilityPresetCombo, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutMapWidget::followVisibilityPresetSelected );
   134            this, &QgsLayoutMapWidget::onMapThemesChanged );
   135   onMapThemesChanged();
   138   QMenu *menuKeepLayers = 
new QMenu( 
this );
   139   mLayerListFromPresetButton->setMenu( menuKeepLayers );
   141   mLayerListFromPresetButton->setToolTip( tr( 
"Set layer list from a map theme" ) );
   142   connect( menuKeepLayers, &QMenu::aboutToShow, 
this, &QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu );
   147            this, &QgsLayoutMapWidget::atlasLayerChanged );
   151     compositionAtlasToggled( atlas->enabled() );
   154   mOverviewFrameMapComboBox->setCurrentLayout( item->
layout() );
   156   mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
   162   mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
   182   loadOverviewEntries();
   184   connect( mMapRotationSpinBox, static_cast < 
void ( 
QgsDoubleSpinBox::* )( 
double ) > ( &QgsDoubleSpinBox::valueChanged ), 
this, &QgsLayoutMapWidget::rotationChanged );
   188   blockAllSignals( 
false );
   193   if ( mItemPropertiesWidget )
   199   mAtlasCheckBox->setTitle( tr( 
"Controlled by %1" ).arg( 
string == tr( 
"atlas" ) ? tr( 
"Atlas" ) : tr( 
"Report" ) ) );
   200   mAtlasPredefinedScaleRadio->setToolTip( tr( 
"Use one of the predefined scales of the project where the %1 feature best fits." ).arg( 
string ) );
   222   mItemPropertiesWidget->
setItem( mMapItem );
   224     mLabelWidget->setItem( mMapItem );
   231     mOverviewFrameStyleButton->registerExpressionContextGenerator( mMapItem );
   252 void QgsLayoutMapWidget::compositionAtlasToggled( 
bool atlasEnabled )
   255        mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer()
   258     mAtlasCheckBox->setEnabled( 
true );
   262     mAtlasCheckBox->setEnabled( 
false );
   263     mAtlasCheckBox->setChecked( 
false );
   267 void QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu()
   272   QMenu *menu = qobject_cast<QMenu *>( sender() );
   278   for ( 
const QString &presetName : constMapThemes )
   280     menu->addAction( presetName, 
this, &QgsLayoutMapWidget::keepLayersVisibilityPresetSelected );
   283   if ( menu->actions().isEmpty() )
   284     menu->addAction( tr( 
"No presets defined" ) )->setEnabled( 
false );
   287 void QgsLayoutMapWidget::followVisibilityPresetSelected( 
int currentIndex )
   292   if ( currentIndex == -1 )
   296   if ( currentIndex != 0 )
   298     presetName = mFollowVisibilityPresetCombo->currentText();
   301   if ( presetName == mMapItem->followVisibilityPresetName() )
   304   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Preset" ) );
   305   mFollowVisibilityPresetCheckBox->setChecked( 
true );
   306   mMapItem->setFollowVisibilityPresetName( presetName );
   307   mMapItem->layout()->undoStack()->endCommand();
   309   mMapItem->invalidateCache();
   312 void QgsLayoutMapWidget::keepLayersVisibilityPresetSelected()
   314   QAction *action = qobject_cast<QAction *>( sender() );
   318   QString presetName = action->text();
   319   QList<QgsMapLayer *> lst = orderedPresetVisibleLayers( presetName );
   322     mKeepLayerListCheckBox->setChecked( 
true );
   323     mMapItem->setLayers( lst );
   325     mKeepLayerStylesCheckBox->setChecked( 
true );
   327     mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Preset" ) );
   328     mMapItem->setLayerStyleOverrides( 
QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverrides( presetName ) );
   329     mMapItem->layout()->undoStack()->endCommand();
   331     mMapItem->invalidateCache();
   335 void QgsLayoutMapWidget::onMapThemesChanged()
   337   if ( QStringListModel *model = qobject_cast<QStringListModel *>( mFollowVisibilityPresetCombo->model() ) )
   340     lst.append( tr( 
"(none)" ) );
   342     model->setStringList( lst );
   345     int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
   346     mFollowVisibilityPresetCombo->blockSignals( 
true );
   347     mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 ); 
   348     mFollowVisibilityPresetCombo->blockSignals( 
false );
   359   if ( mMapItem->presetCrs() == 
crs )
   365   bool updateExtent = 
false;
   371     newExtent = xForm.transformBoundingBox( prevExtent );
   379   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map CRS" ) );
   380   mMapItem->setCrs( crs );
   382     mMapItem->zoomToExtent( newExtent );
   383   mMapItem->layout()->undoStack()->endCommand();
   384   mMapItem->invalidateCache();
   387 void QgsLayoutMapWidget::overviewSymbolChanged()
   395   mMapItem->endCommand();
   396   mMapItem->invalidateCache();
   399 void QgsLayoutMapWidget::showLabelSettings()
   405 void QgsLayoutMapWidget::switchToMoveContentTool()
   411 void QgsLayoutMapWidget::aboutToShowBookmarkMenu()
   413   mBookmarkMenu->clear();
   417   if ( !mBookmarkModel )
   420   QMap< QString, QMenu * > groupMenus;
   421   for ( 
int i = 0; i < mBookmarkModel->rowCount(); ++i )
   424     QMenu *destMenu = mBookmarkMenu;
   425     if ( !group.isEmpty() )
   427       destMenu = groupMenus.value( group );
   430         destMenu = 
new QMenu( group, mBookmarkMenu );
   431         groupMenus[ group ] = destMenu;
   436     connect( action, &QAction::triggered, 
this, [ = ]
   446       if ( extent.crs() != mMapItem->crs() )
   451           newExtent = xForm.transformBoundingBox( newExtent );
   460       mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Extent" ) );
   461       mMapItem->zoomToExtent( newExtent );
   462       mMapItem->layout()->undoStack()->endCommand();
   464     destMenu->addAction( action );
   467   QStringList groupKeys = groupMenus.keys();
   468   groupKeys.sort( Qt::CaseInsensitive );
   469   for ( 
int i = 0; i < groupKeys.count(); ++i )
   471     if ( mBookmarkMenu->actions().value( i ) )
   472       mBookmarkMenu->insertMenu( mBookmarkMenu->actions().at( i ), groupMenus.value( groupKeys.at( i ) ) );
   474       mBookmarkMenu->addMenu( groupMenus.value( groupKeys.at( i ) ) );
   478 void QgsLayoutMapWidget::mAtlasCheckBox_toggled( 
bool checked )
   485   mAtlasFixedScaleRadio->setEnabled( checked );
   486   mAtlasMarginRadio->setEnabled( checked );
   488   if ( mAtlasMarginRadio->isEnabled() && mAtlasMarginRadio->isChecked() )
   490     mAtlasMarginSpinBox->setEnabled( 
true );
   494     mAtlasMarginSpinBox->setEnabled( 
false );
   497   mAtlasPredefinedScaleRadio->setEnabled( checked );
   502     if ( mMapItem->layout() )
   504       toggleAtlasScalingOptionsByLayerType();
   509   if ( !hasPredefinedScales() )
   511     mAtlasPredefinedScaleRadio->setEnabled( 
false );
   514   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Set Atlas Driven" ) );
   515   mMapItem->setAtlasDriven( checked );
   516   mMapItem->layout()->undoStack()->endCommand();
   520 void QgsLayoutMapWidget::updateMapForAtlas()
   523   if ( mMapItem->atlasDriven() )
   530     mMapItem->invalidateCache();
   534 void QgsLayoutMapWidget::mAtlasMarginRadio_toggled( 
bool checked )
   536   mAtlasMarginSpinBox->setEnabled( checked );
   538   if ( checked && mMapItem )
   540     mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Atlas Mode" ) );
   542     mMapItem->layout()->undoStack()->endCommand();
   547 void QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged( 
int value )
   555   mMapItem->setAtlasMargin( value / 100. );
   556   mMapItem->layout()->undoStack()->endCommand();
   560 void QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled( 
bool checked )
   569     mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Atlas Mode" ) );
   571     mMapItem->layout()->undoStack()->endCommand();
   576 void QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled( 
bool checked )
   583   if ( hasPredefinedScales() )
   587       mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Atlas Scales" ) );
   589       mMapItem->layout()->undoStack()->endCommand();
   597     mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Atlas Mode" ) );
   599     mMapItem->layout()->undoStack()->endCommand();
   603 void QgsLayoutMapWidget::mScaleLineEdit_editingFinished()
   610   bool conversionSuccess = 
false;
   611   double scaleDenominator = QLocale().toDouble( mScaleLineEdit->text(), &conversionSuccess );
   612   if ( !conversionSuccess )
   620   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Scale" ) );
   621   mMapItem->setScale( scaleDenominator );
   622   mMapItem->layout()->undoStack()->endCommand();
   625 void QgsLayoutMapWidget::rotationChanged( 
double value )
   633   mMapItem->setMapRotation( value );
   634   mMapItem->layout()->undoStack()->endCommand();
   635   mMapItem->invalidateCache();
   638 void QgsLayoutMapWidget::setToMapCanvasExtent()
   655       newExtent = xForm.transformBoundingBox( newExtent );
   664   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Extent" ) );
   665   mMapItem->zoomToExtent( newExtent );
   666   mMapItem->layout()->undoStack()->endCommand();
   669 void QgsLayoutMapWidget::setToMapCanvasScale()
   676   const double newScale = mMapCanvas->
scale();
   678   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Scale" ) );
   679   mMapItem->setScale( newScale );
   680   mMapItem->layout()->undoStack()->endCommand();
   683 void QgsLayoutMapWidget::viewExtentInCanvas()
   692   if ( !currentMapExtent.
isEmpty() )
   707 void QgsLayoutMapWidget::viewScaleInCanvas()
   714   const double currentScale = mMapItem->scale();
   718 void QgsLayoutMapWidget::mXMinLineEdit_editingFinished()
   720   updateComposerExtentFromGui();
   723 void QgsLayoutMapWidget::mXMaxLineEdit_editingFinished()
   725   updateComposerExtentFromGui();
   728 void QgsLayoutMapWidget::mYMinLineEdit_editingFinished()
   730   updateComposerExtentFromGui();
   733 void QgsLayoutMapWidget::mYMaxLineEdit_editingFinished()
   735   updateComposerExtentFromGui();
   738 void QgsLayoutMapWidget::updateGuiElements()
   745   blockAllSignals( 
true );
   746   mLabel->setText( mMapItem->displayName() );
   748   whileBlocking( mCrsSelector )->setCrs( mMapItem->presetCrs() );
   751   double scale = mMapItem->scale();
   754   if ( scale >= 10000 )
   757     mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 
'f', 0 ) );
   759   else if ( scale >= 10 )
   761     mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 
'f', 3 ) );
   763   else if ( scale >= 1 )
   766     mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 
'f', 4 ) );
   771     mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 
'f', 10 ) );
   776   mXMinLineEdit->setText( QLocale().toString( composerMapExtent.
xMinimum(), 
'f', 3 ) );
   777   mXMaxLineEdit->setText( QLocale().toString( composerMapExtent.
xMaximum(), 
'f', 3 ) );
   778   mYMinLineEdit->setText( QLocale().toString( composerMapExtent.
yMinimum(), 
'f', 3 ) );
   779   mYMaxLineEdit->setText( QLocale().toString( composerMapExtent.
yMaximum(), 
'f', 3 ) );
   784   mFollowVisibilityPresetCheckBox->setCheckState(
   785     mMapItem->followVisibilityPreset() ? Qt::Checked : Qt::Unchecked );
   786   int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
   787   mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 ); 
   790   if ( mMapItem->keepLayerSet() )
   792     mKeepLayerListCheckBox->setCheckState( Qt::Checked );
   796     mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
   799   mKeepLayerStylesCheckBox->setEnabled( mMapItem->keepLayerSet() );
   800   mKeepLayerStylesCheckBox->setCheckState( mMapItem->keepLayerStyles() ? Qt::Checked : Qt::Unchecked );
   803   if ( mMapItem->drawAnnotations() )
   805     mDrawCanvasItemsCheckBox->setCheckState( Qt::Checked );
   809     mDrawCanvasItemsCheckBox->setCheckState( Qt::Unchecked );
   813   mAtlasCheckBox->setChecked( mMapItem->atlasDriven() );
   816   mAtlasFixedScaleRadio->setEnabled( mMapItem->atlasDriven() );
   819   mAtlasMarginRadio->setEnabled( mMapItem->atlasDriven() );
   821   mAtlasPredefinedScaleRadio->setEnabled( mMapItem->atlasDriven() );
   824   if ( mMapItem->atlasDriven() )
   826     toggleAtlasScalingOptionsByLayerType();
   829   if ( !hasPredefinedScales() )
   831     mAtlasPredefinedScaleRadio->setEnabled( 
false );
   836   loadOverviewEntries();
   838   blockAllSignals( 
false );
   841 void QgsLayoutMapWidget::toggleAtlasScalingOptionsByLayerType()
   858     mAtlasFixedScaleRadio->setChecked( 
true );
   859     mAtlasMarginRadio->setEnabled( 
false );
   860     mAtlasPredefinedScaleRadio->setEnabled( 
false );
   865     mAtlasMarginRadio->setEnabled( 
true );
   866     mAtlasPredefinedScaleRadio->setEnabled( 
true );
   870 void QgsLayoutMapWidget::updateComposerExtentFromGui()
   877   double xmin, ymin, xmax, ymax;
   878   bool conversionSuccess;
   880   xmin = QLocale().toDouble( mXMinLineEdit->text(), &conversionSuccess );
   881   if ( !conversionSuccess )
   883   xmax = QLocale().toDouble( mXMaxLineEdit->text(), &conversionSuccess );
   884   if ( !conversionSuccess )
   886   ymin = QLocale().toDouble( mYMinLineEdit->text(), &conversionSuccess );
   887   if ( !conversionSuccess )
   889   ymax = QLocale().toDouble( mYMaxLineEdit->text(), &conversionSuccess );
   890   if ( !conversionSuccess )
   895   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Extent" ) );
   896   mMapItem->setExtent( newExtent );
   897   mMapItem->layout()->undoStack()->endCommand();
   900 void QgsLayoutMapWidget::blockAllSignals( 
bool b )
   902   mScaleLineEdit->blockSignals( b );
   903   mXMinLineEdit->blockSignals( b );
   904   mXMaxLineEdit->blockSignals( b );
   905   mYMinLineEdit->blockSignals( b );
   906   mYMaxLineEdit->blockSignals( b );
   907   mDrawCanvasItemsCheckBox->blockSignals( b );
   908   mOverviewFrameMapComboBox->blockSignals( b );
   909   mOverviewFrameStyleButton->blockSignals( b );
   910   mOverviewBlendModeComboBox->blockSignals( b );
   911   mOverviewInvertCheckbox->blockSignals( b );
   912   mOverviewCenterCheckbox->blockSignals( b );
   913   mAtlasCheckBox->blockSignals( b );
   914   mAtlasMarginSpinBox->blockSignals( b );
   915   mAtlasFixedScaleRadio->blockSignals( b );
   916   mAtlasMarginRadio->blockSignals( b );
   917   mFollowVisibilityPresetCheckBox->blockSignals( b );
   918   mFollowVisibilityPresetCombo->blockSignals( b );
   919   mKeepLayerListCheckBox->blockSignals( b );
   920   mKeepLayerStylesCheckBox->blockSignals( b );
   921   mActionSetToCanvasExtent->blockSignals( b );
   922   mActionUpdatePreview->blockSignals( b );
   924   blockOverviewItemsSignals( b );
   927 void QgsLayoutMapWidget::updatePreview()
   936 void QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged( 
int state )
   943   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Preset" ) );
   944   if ( state == Qt::Checked )
   946     mMapItem->setFollowVisibilityPreset( 
true );
   949     mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
   950     mKeepLayerStylesCheckBox->setCheckState( Qt::Unchecked );
   952     mMapItem->invalidateCache();
   956     mMapItem->setFollowVisibilityPreset( 
false );
   958   mMapItem->layout()->undoStack()->endCommand();
   961 void QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged( 
int state )
   969   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Map Preset Changed" ) );
   970   storeCurrentLayerSet();
   971   mMapItem->setKeepLayerSet( state == Qt::Checked );
   972   if ( state == Qt::Unchecked )
   974     mMapItem->setLayers( QList< QgsMapLayer * >() );
   976   mMapItem->layout()->undoStack()->endCommand();
   979   if ( state == Qt::Checked )
   982     mFollowVisibilityPresetCheckBox->setCheckState( Qt::Unchecked );
   986     mKeepLayerStylesCheckBox->setChecked( Qt::Unchecked );
   987     mMapItem->invalidateCache();
   990   mKeepLayerStylesCheckBox->setEnabled( state == Qt::Checked );
   993 void QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged( 
int state )
  1000   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Preset" ) );
  1001   if ( state == Qt::Checked )
  1003     mMapItem->storeCurrentLayerStyles();
  1004     mMapItem->setKeepLayerStyles( 
true );
  1008     mMapItem->setLayerStyleOverrides( QMap<QString, QString>() );
  1009     mMapItem->setKeepLayerStyles( 
false );
  1011   mMapItem->layout()->undoStack()->endCommand();
  1014 void QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged( 
int state )
  1021   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Toggle Map Item" ) );
  1022   mMapItem->setDrawAnnotations( state == Qt::Checked );
  1023   mMapItem->invalidateCache();
  1024   mMapItem->layout()->undoStack()->endCommand();
  1027 void QgsLayoutMapWidget::atlasLayerChanged( 
QgsVectorLayer *layer )
  1032     mAtlasCheckBox->setChecked( 
false );
  1033     mAtlasCheckBox->setEnabled( 
false );
  1038     mAtlasCheckBox->setEnabled( 
true );
  1042   if ( mAtlasCheckBox->isChecked() )
  1043     toggleAtlasScalingOptionsByLayerType();
  1046 bool QgsLayoutMapWidget::hasPredefinedScales()
 const  1051   if ( !hasProjectScales || scales.isEmpty() )
  1056     QStringList myScalesList = scalesStr.split( 
',' );
  1057     return !myScalesList.isEmpty() && !myScalesList[0].isEmpty();
  1062 void QgsLayoutMapWidget::mAddGridPushButton_clicked()
  1069   QString itemName = tr( 
"Grid %1" ).arg( mMapItem->grids()->size() + 1 );
  1071   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Add Map Grid" ) );
  1072   mMapItem->grids()->addGrid( grid );
  1073   mMapItem->layout()->undoStack()->endCommand();
  1074   mMapItem->updateBoundingRect();
  1077   addGridListItem( grid->
id(), grid->
name() );
  1078   mGridListWidget->setCurrentRow( 0 );
  1079   mGridListWidget_currentItemChanged( mGridListWidget->currentItem(), nullptr );
  1082 void QgsLayoutMapWidget::mRemoveGridPushButton_clicked()
  1084   QListWidgetItem *item = mGridListWidget->currentItem();
  1090   mMapItem->beginCommand( tr( 
"Remove Grid" ) );
  1091   mMapItem->grids()->removeGrid( item->data( Qt::UserRole ).toString() );
  1092   QListWidgetItem *delItem = mGridListWidget->takeItem( mGridListWidget->row( item ) );
  1094   mMapItem->endCommand();
  1095   mMapItem->updateBoundingRect();
  1099 void QgsLayoutMapWidget::mGridUpButton_clicked()
  1101   QListWidgetItem *item = mGridListWidget->currentItem();
  1107   int row = mGridListWidget->row( item );
  1112   mGridListWidget->takeItem( row );
  1113   mGridListWidget->insertItem( row - 1, item );
  1114   mGridListWidget->setCurrentItem( item );
  1115   mMapItem->beginCommand( tr( 
"Move Grid Up" ) );
  1116   mMapItem->grids()->moveGridUp( item->data( Qt::UserRole ).toString() );
  1117   mMapItem->endCommand();
  1121 void QgsLayoutMapWidget::mGridDownButton_clicked()
  1123   QListWidgetItem *item = mGridListWidget->currentItem();
  1129   int row = mGridListWidget->row( item );
  1130   if ( mGridListWidget->count() <= row )
  1134   mGridListWidget->takeItem( row );
  1135   mGridListWidget->insertItem( row + 1, item );
  1136   mGridListWidget->setCurrentItem( item );
  1137   mMapItem->beginCommand( tr( 
"Move Grid Down" ) );
  1138   mMapItem->grids()->moveGridDown( item->data( Qt::UserRole ).toString() );
  1139   mMapItem->endCommand();
  1150   QListWidgetItem *item = mGridListWidget->currentItem();
  1155   return mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
  1158 void QgsLayoutMapWidget::mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
  1160   mGridPropertiesButton->setEnabled( static_cast< bool >( current ) );
  1163 void QgsLayoutMapWidget::mGridListWidget_itemChanged( QListWidgetItem *item )
  1176   mMapItem->beginCommand( tr( 
"Rename Grid" ) );
  1177   grid->
setName( item->text() );
  1178   mMapItem->endCommand();
  1181 void QgsLayoutMapWidget::mGridPropertiesButton_clicked()
  1198 QListWidgetItem *QgsLayoutMapWidget::addGridListItem( 
const QString &
id, 
const QString &name )
  1200   QListWidgetItem *item = 
new QListWidgetItem( name, 
nullptr );
  1201   item->setData( Qt::UserRole, 
id );
  1202   item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
  1203   mGridListWidget->insertItem( 0, item );
  1207 void QgsLayoutMapWidget::loadGridEntries()
  1210   QSet<QString> selectedIds;
  1211   QList<QListWidgetItem *> itemSelection = mGridListWidget->selectedItems();
  1212   QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
  1213   for ( ; sIt != itemSelection.constEnd(); ++sIt )
  1215     selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
  1218   mGridListWidget->clear();
  1224   QList< QgsLayoutItemMapGrid * > grids = mMapItem->grids()->asList();
  1225   QList< QgsLayoutItemMapGrid * >::const_iterator gridIt = grids.constBegin();
  1226   for ( ; gridIt != grids.constEnd(); ++gridIt )
  1228     QListWidgetItem *item = addGridListItem( ( *gridIt )->id(), ( *gridIt )->name() );
  1229     if ( selectedIds.contains( ( *gridIt )->id() ) )
  1231       item->setSelected( 
true );
  1232       mGridListWidget->setCurrentItem( item );
  1236   if ( mGridListWidget->currentItem() )
  1238     mGridListWidget_currentItemChanged( mGridListWidget->currentItem(), nullptr );
  1242     mGridListWidget_currentItemChanged( 
nullptr, 
nullptr );
  1246 void QgsLayoutMapWidget::mAddOverviewPushButton_clicked()
  1253   QString itemName = tr( 
"Overview %1" ).arg( mMapItem->overviews()->size() + 1 );
  1255   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Add Map Overview" ) );
  1256   mMapItem->overviews()->addOverview( overview );
  1257   mMapItem->layout()->undoStack()->endCommand();
  1258   mMapItem->invalidateCache();
  1260   addOverviewListItem( overview->
id(), overview->
name() );
  1262   mOverviewListWidget->setCurrentRow( 0 );
  1265 void QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked()
  1267   QListWidgetItem *item = mOverviewListWidget->currentItem();
  1272   mMapItem->beginCommand( tr( 
"Remove Map Overview" ) );
  1273   mMapItem->overviews()->removeOverview( item->data( Qt::UserRole ).toString() );
  1274   mMapItem->endCommand();
  1275   QListWidgetItem *delItem = mOverviewListWidget->takeItem( mOverviewListWidget->row( item ) );
  1277   mMapItem->invalidateCache();
  1280 void QgsLayoutMapWidget::mOverviewUpButton_clicked()
  1282   QListWidgetItem *item = mOverviewListWidget->currentItem();
  1288   int row = mOverviewListWidget->row( item );
  1293   mOverviewListWidget->takeItem( row );
  1294   mOverviewListWidget->insertItem( row - 1, item );
  1295   mOverviewListWidget->setCurrentItem( item );
  1296   mMapItem->beginCommand( tr( 
"Move Overview Up" ) );
  1297   mMapItem->overviews()->moveOverviewUp( item->data( Qt::UserRole ).toString() );
  1298   mMapItem->endCommand();
  1299   mMapItem->invalidateCache();
  1302 void QgsLayoutMapWidget::mOverviewDownButton_clicked()
  1304   QListWidgetItem *item = mOverviewListWidget->currentItem();
  1310   int row = mOverviewListWidget->row( item );
  1311   if ( mOverviewListWidget->count() <= row )
  1315   mOverviewListWidget->takeItem( row );
  1316   mOverviewListWidget->insertItem( row + 1, item );
  1317   mOverviewListWidget->setCurrentItem( item );
  1318   mMapItem->beginCommand( tr( 
"Move Overview Down" ) );
  1319   mMapItem->overviews()->moveOverviewDown( item->data( Qt::UserRole ).toString() );
  1320   mMapItem->endCommand();
  1321   mMapItem->invalidateCache();
  1331   QListWidgetItem *item = mOverviewListWidget->currentItem();
  1337   return mMapItem->overviews()->overview( item->data( Qt::UserRole ).toString() );
  1340 void QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous )
  1342   Q_UNUSED( previous )
  1345     mOverviewCheckBox->setEnabled( 
false );
  1349   mOverviewCheckBox->setEnabled( 
true );
  1350   setOverviewItems( mMapItem->overviews()->overview( current->data( Qt::UserRole ).toString() ) );
  1353 void QgsLayoutMapWidget::mOverviewListWidget_itemChanged( QListWidgetItem *item )
  1366   mMapItem->beginCommand( QStringLiteral( 
"Rename Overview" ) );
  1367   overview->
setName( item->text() );
  1368   mMapItem->endCommand();
  1369   if ( item->isSelected() )
  1372     mOverviewCheckBox->setTitle( QString( tr( 
"Draw \"%1\" overview" ) ).arg( overview->
name() ) );
  1376 void QgsLayoutMapWidget::setOverviewItemsEnabled( 
bool enabled )
  1378   mOverviewFrameMapLabel->setEnabled( enabled );
  1379   mOverviewFrameMapComboBox->setEnabled( enabled );
  1380   mOverviewFrameStyleLabel->setEnabled( enabled );
  1381   mOverviewFrameStyleButton->setEnabled( enabled );
  1382   mOverviewBlendModeLabel->setEnabled( enabled );
  1383   mOverviewBlendModeComboBox->setEnabled( enabled );
  1384   mOverviewInvertCheckbox->setEnabled( enabled );
  1385   mOverviewCenterCheckbox->setEnabled( enabled );
  1386   mOverviewPositionComboBox->setEnabled( enabled );
  1392 void QgsLayoutMapWidget::blockOverviewItemsSignals( 
const bool block )
  1394   mOverviewFrameMapComboBox->blockSignals( block );
  1395   mOverviewFrameStyleButton->blockSignals( block );
  1396   mOverviewBlendModeComboBox->blockSignals( block );
  1397   mOverviewInvertCheckbox->blockSignals( block );
  1398   mOverviewCenterCheckbox->blockSignals( block );
  1399   mOverviewPositionComboBox->blockSignals( block );
  1400   mOverviewStackingLayerComboBox->blockSignals( block );
  1410   blockOverviewItemsSignals( 
true );
  1412   mOverviewCheckBox->setTitle( QString( tr( 
"Draw \"%1\" overview" ) ).arg( overview->
name() ) );
  1413   mOverviewCheckBox->setChecked( overview->
enabled() );
  1416   mOverviewFrameMapComboBox->setItem( overview->
linkedMap() );
  1419   mOverviewBlendModeComboBox->setBlendMode( overview->
blendMode() );
  1421   mOverviewInvertCheckbox->setChecked( overview->
inverted() );
  1423   mOverviewCenterCheckbox->setChecked( overview->
centered() );
  1425   mOverviewPositionComboBox->setCurrentIndex( mOverviewPositionComboBox->findData( overview->
stackingPosition() ) );
  1426   mOverviewStackingLayerComboBox->setLayer( overview->
stackingLayer() );
  1432   blockOverviewItemsSignals( 
false );
  1435 void QgsLayoutMapWidget::storeCurrentLayerSet()
  1441   mMapItem->setLayers( layers );
  1443   if ( mMapItem->keepLayerStyles() )
  1446     mMapItem->storeCurrentLayerStyles();
  1450 QList<QgsMapLayer *> QgsLayoutMapWidget::orderedPresetVisibleLayers( 
const QString &name )
 const  1455   QList<QgsMapLayer *> lst;
  1459     if ( visibleIds.contains( layer->
id() ) )
  1467 QListWidgetItem *QgsLayoutMapWidget::addOverviewListItem( 
const QString &
id, 
const QString &name )
  1469   QListWidgetItem *item = 
new QListWidgetItem( name, 
nullptr );
  1470   item->setData( Qt::UserRole, 
id );
  1471   item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
  1472   mOverviewListWidget->insertItem( 0, item );
  1476 void QgsLayoutMapWidget::loadOverviewEntries()
  1479   QSet<QString> selectedIds;
  1480   QList<QListWidgetItem *> itemSelection = mOverviewListWidget->selectedItems();
  1481   QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
  1482   for ( ; sIt != itemSelection.constEnd(); ++sIt )
  1484     selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
  1487   mOverviewListWidget->clear();
  1493   mOverviewFrameMapComboBox->setExceptedItemList( QList< QgsLayoutItem * >() << mMapItem );
  1496   QList< QgsLayoutItemMapOverview * > overviews = mMapItem->overviews()->asList();
  1497   QList< QgsLayoutItemMapOverview * >::const_iterator overviewIt = overviews.constBegin();
  1498   for ( ; overviewIt != overviews.constEnd(); ++overviewIt )
  1500     QListWidgetItem *item = addOverviewListItem( ( *overviewIt )->id(), ( *overviewIt )->name() );
  1501     if ( selectedIds.contains( ( *overviewIt )->id() ) )
  1503       item->setSelected( 
true );
  1504       mOverviewListWidget->setCurrentItem( item );
  1508   if ( mOverviewListWidget->currentItem() )
  1510     mOverviewListWidget_currentItemChanged( mOverviewListWidget->currentItem(), nullptr );
  1514     mOverviewListWidget_currentItemChanged( 
nullptr, 
nullptr );
  1518 void QgsLayoutMapWidget::mOverviewCheckBox_toggled( 
bool state )
  1526   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Overview Display Toggled" ) );
  1528   mMapItem->invalidateCache();
  1529   mMapItem->layout()->undoStack()->endCommand();
  1532 void QgsLayoutMapWidget::overviewMapChanged( 
QgsLayoutItem *item )
  1544   mMapItem->beginCommand( tr( 
"Change Overview Map" ) );
  1546   mMapItem->invalidateCache();
  1547   mMapItem->endCommand();
  1550 void QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged( 
int index )
  1559   mMapItem->beginCommand( tr( 
"Change Overview Blend Mode" ) );
  1560   overview->
setBlendMode( mOverviewBlendModeComboBox->blendMode() );
  1561   mMapItem->invalidateCache();
  1562   mMapItem->endCommand();
  1565 void QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled( 
bool state )
  1573   mMapItem->beginCommand( tr( 
"Toggle Overview Inverted" ) );
  1575   mMapItem->invalidateCache();
  1576   mMapItem->endCommand();
  1579 void QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled( 
bool state )
  1587   mMapItem->beginCommand( tr( 
"Toggle Overview Centered" ) );
  1589   mMapItem->invalidateCache();
  1590   mMapItem->endCommand();
  1593 void QgsLayoutMapWidget::overviewStackingChanged( 
int )
  1601   mMapItem->beginCommand( tr( 
"Change Overview Position" ) );
  1602   overview->
setStackingPosition( static_cast< QgsLayoutItemMapItem::StackingPosition >( mOverviewPositionComboBox->currentData().toInt() ) );
  1603   mMapItem->invalidateCache();
  1604   mMapItem->endCommand();
  1611       mOverviewStackingLayerComboBox->setEnabled( 
false );
  1616       mOverviewStackingLayerComboBox->setEnabled( 
true );
  1621 void QgsLayoutMapWidget::overviewStackingLayerChanged( 
QgsMapLayer *layer )
  1629   mMapItem->beginCommand( tr( 
"Change Overview Position" ) );
  1631   mMapItem->invalidateCache();
  1632   mMapItem->endCommand();
  1646   mLabelBoundarySpinBox->setClearValue( 0 );
  1647   mLabelBoundarySpinBox->setShowClearButton( 
true );
  1649   mLabelBoundaryUnitsCombo->linkToWidget( mLabelBoundarySpinBox );
  1650   mLabelBoundaryUnitsCombo->setConverter( &mMapItem->layout()->renderContext().measurementConverter() );
  1653   connect( mLabelBoundarySpinBox, static_cast < 
void ( QDoubleSpinBox::* )( 
double ) > ( &QDoubleSpinBox::valueChanged ), 
this, &QgsLayoutMapLabelingWidget::labelMarginChanged );
  1654   connect( mShowPartialLabelsCheckBox, &QCheckBox::toggled, 
this, &QgsLayoutMapLabelingWidget::showPartialsToggled );
  1655   connect( mShowUnplacedCheckBox, &QCheckBox::toggled, 
this, &QgsLayoutMapLabelingWidget::showUnplacedToggled );
  1679   updateGuiElements();
  1684 void QgsLayoutMapLabelingWidget::updateGuiElements()
  1686   whileBlocking( mLabelBoundarySpinBox )->setValue( mMapItem->labelMargin().length() );
  1687   whileBlocking( mLabelBoundaryUnitsCombo )->setUnit( mMapItem->labelMargin().units() );
  1691   if ( mBlockingItemsListView->model() )
  1693     QAbstractItemModel *oldModel = mBlockingItemsListView->model();
  1694     mBlockingItemsListView->setModel( 
nullptr );
  1695     oldModel->deleteLater();
  1699   mBlockingItemsListView->setModel( model );
  1704 void QgsLayoutMapLabelingWidget::labelMarginChanged( 
double val )
  1711   mMapItem->layout()->undoStack()->endCommand();
  1712   mMapItem->invalidateCache();
  1715 void QgsLayoutMapLabelingWidget::labelMarginUnitsChanged()
  1721   mMapItem->setLabelMargin( 
QgsLayoutMeasurement( mLabelBoundarySpinBox->value(), mLabelBoundaryUnitsCombo->unit() ) );
  1722   mMapItem->layout()->undoStack()->endCommand();
  1723   mMapItem->invalidateCache();
  1726 void QgsLayoutMapLabelingWidget::showPartialsToggled( 
bool checked )
  1731   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Label Visibility" ) );
  1732   QgsLayoutItemMap::MapItemFlags flags = mMapItem->mapFlags();
  1737   mMapItem->setMapFlags( flags );
  1738   mMapItem->layout()->undoStack()->endCommand();
  1739   mMapItem->invalidateCache();
  1742 void QgsLayoutMapLabelingWidget::showUnplacedToggled( 
bool checked )
  1747   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Label Visibility" ) );
  1748   QgsLayoutItemMap::MapItemFlags flags = mMapItem->mapFlags();
  1753   mMapItem->setMapFlags( flags );
  1754   mMapItem->layout()->undoStack()->endCommand();
  1755   mMapItem->invalidateCache();
  1759   : QSortFilterProxyModel( parent )
  1760   , mLayoutModel( layoutModel )
  1763   setSourceModel( layoutModel );
  1776   if ( i.column() != 0 )
  1789     case Qt::CheckStateRole:
  1790       switch ( i.column() )
  1793           return mMapItem ? ( mMapItem->isLabelBlockingItem( item ) ? Qt::Checked : Qt::Unchecked ) : Qt::Unchecked;
  1799       return mLayoutModel->
data( sourceIndex, role );
  1807   if ( !index.isValid() )
  1811   if ( !item || !mMapItem )
  1816   mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Label Blocking Items" ) );
  1818   if ( value.toBool() )
  1820     mMapItem->addLabelBlockingItem( item );
  1824     mMapItem->removeLabelBlockingItem( item );
  1826   emit dataChanged( index, index, QVector<int>() << role );
  1828   mMapItem->layout()->undoStack()->endCommand();
  1829   mMapItem->invalidateCache();
  1836   Qt::ItemFlags 
flags = QAbstractItemModel::flags( index );
  1838   if ( ! index.isValid() )
  1843   switch ( index.column() )
  1846       return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
  1848       return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
  1855   if ( !item || item == mMapItem )
 The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
 
bool setReferencedExtent(const QgsReferencedRectangle &extent) SIP_THROW(QgsCsException)
Sets the canvas to the specified extent. 
 
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map to show the overview extent of. 
 
A rectangle specified with double values. 
 
Base class for all map layer types. 
 
void setFrameSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used for drawing the overview extent. 
 
QgsLayoutItem * itemFromIndex(const QModelIndex &index) const
Returns the QgsLayoutItem corresponding to a QModelIndex index, if possible. 
 
Base class for graphical items within a QgsLayout. 
 
An individual overview which is drawn above the map content in a QgsLayoutItemMap, and shows the extent of another QgsLayoutItemMap. 
 
int type() const override
Returns a unique graphics item type identifier. 
 
bool setData(const QModelIndex &index, const QVariant &value, int role) override
 
QVariant data(const QModelIndex &index, int role) const override
 
StackingPosition
Item stacking position, specifies where the in the map's stack the item should be rendered...
 
void setInverted(bool inverted)
Sets whether the overview frame is inverted, ie, whether the shaded area is drawn outside the extent ...
 
This class is a composition of two QSettings instances: 
 
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error. 
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key. 
 
Layer and style map theme. 
 
void extentChanged()
Emitted when the map's extent changes. 
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference) 
 
Render above a specific map layer (see stackingLayer()) 
 
QVariant data(const QModelIndex &index, int role) const override
 
void refresh()
Repaints the canvas map. 
 
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon. 
 
A common interface for layout designer dialogs and widgets. 
 
void toggled(bool)
Emitted when atlas is enabled or disabled. 
 
QgsFillSymbol * frameSymbol()
Returns the fill symbol used for drawing the overview extent. 
 
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
 
const QgsCoordinateReferenceSystem & crs
 
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes. 
 
void mapThemesChanged()
Emitted when map themes within the collection are changed. 
 
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the overview. 
 
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
 
Map canvas is a class for displaying all GIS data types on a canvas. 
 
Render below a specific map layer (see stackingLayer()) 
 
Render above all map layers, but below map labels. 
 
Margin for labels from edge of map. 
 
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system 
 
QStringList mapThemeVisibleLayerIds(const QString &name) const
Returns the list of layer IDs that are visible for the specified map theme. 
 
Qt::ItemFlags flags(const QModelIndex &index) const override
 
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
 
virtual void activateTool(StandardTool tool)=0
Activates a standard layout designer tool. 
 
Layout graphical items for displaying a map. 
 
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject. 
 
const QgsLayout * layout() const
Returns the layout the object is attached to. 
 
QgsMapThemeCollection mapThemeCollection
 
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
 
bool isEmpty() const
Returns true if the rectangle is empty. 
 
void setName(const QString &name)
Sets the friendly display name for the item. 
 
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol. 
 
QgsCoordinateReferenceSystem crs
 
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview. 
 
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
 
StackingPosition stackingPosition() const
Returns the item's stacking position, which specifies where the in the map's stack the item should be...
 
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
 
bool enabled() const
Returns whether the item will be drawn. 
 
Whether to draw labels which are partially outside of the map view. 
 
QgsMapLayer * stackingLayer() const
Returns the item's stacking layer, which specifies where the in the map's stack the item should be re...
 
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed. 
 
A QgsRectangle with associated coordinate reference system. 
 
void changed(QgsUnitTypes::LayoutUnit unit)
Emitted when the unit is changed. 
 
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons. 
 
void setStackingLayer(QgsMapLayer *layer)
Sets the item's stacking layer, which specifies where the in the map's stack the item should be rende...
 
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes. 
 
void setCentered(bool centered)
Sets whether the extent of the map is forced to center on the overview. 
 
The extent is adjusted so that each feature is fully visible. 
 
An individual grid which is drawn above the map content in a QgsLayoutItemMap. 
 
static QString defaultProjectScales()
A string with default project scales. 
 
void mapRotationChanged(double newRotation)
Emitted when the map's rotation changes. 
 
double yMinimum() const
Returns the y minimum value (bottom side of rectangle). 
 
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree. 
 
double scale() const
Returns the last reported scale of the canvas. 
 
double xMaximum() const
Returns the x maximum value (right side of rectangle). 
 
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering. 
 
QgsLayoutReportContext & reportContext()
Returns a reference to the layout's report context, which stores information relating to the current ...
 
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas. 
 
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object. 
 
void setStackingPosition(StackingPosition position)
Sets the item's stacking position, which specifies where the in the map's stack the item should be re...
 
The current scale of the map is used for each feature of the atlas. 
 
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel. 
 
static QgsProject * instance()
Returns the QgsProject singleton instance. 
 
This class represents a coordinate reference system (CRS). 
 
QgsLayoutMapItemBlocksLabelsModel(QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent=nullptr)
constructor 
 
int columnCount(const QModelIndex &parent=QModelIndex()) const override
 
void zoomScale(double scale)
Zooms the canvas to a specific scale. 
 
bool centered() const
Returns whether the extent of the map is forced to center on the overview. 
 
double xMinimum() const
Returns the x minimum value (left side of rectangle). 
 
static QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks. 
 
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
 
QString id() const
Returns the unique id for the map item. 
 
double yMaximum() const
Returns the y maximum value (top side of rectangle). 
 
A fill symbol type, for rendering Polygon and MultiPolygon geometries. 
 
Custom exception class for Coordinate Reference System related exceptions. 
 
A model for items attached to a layout. 
 
Bookmark extent as a QgsReferencedRectangle. 
 
Model for label blocking items. 
 
Interface for master layout type objects, such as print layouts and reports. 
 
virtual void setEnabled(bool enabled)
Controls whether the item will be drawn. 
 
void changed()
Emitted when the object's properties change. 
 
Represents a vector layer which manages a vector based data sets. 
 
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
Whether to render unplaced labels in the map view. 
 
QString name() const
Returns the friendly display name for the item. 
 
Render above all map layers and labels. 
 
Return the original, user set value. 
 
A scale is chosen from the predefined scales. 
 
Map atlas margin changed. 
 
QgsLayoutItemMap * linkedMap()
Returns the source map to show the overview extent of. 
 
Render below all map layers. 
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable.