20#include "moc_qgslayoutmapwidget.cpp" 
   41#include <QStringListModel> 
   46  , mMapCanvas( mapCanvas )
 
   51  connect( mScaleLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mScaleLineEdit_editingFinished );
 
   52  connect( mActionSetToCanvasExtent, &QAction::triggered, 
this, &QgsLayoutMapWidget::setToMapCanvasExtent );
 
   53  connect( mActionViewExtentInCanvas, &QAction::triggered, 
this, &QgsLayoutMapWidget::viewExtentInCanvas );
 
   54  connect( mActionSetToCanvasScale, &QAction::triggered, 
this, &QgsLayoutMapWidget::setToMapCanvasScale );
 
   55  connect( mActionViewScaleInCanvas, &QAction::triggered, 
this, &QgsLayoutMapWidget::viewScaleInCanvas );
 
   56  connect( mActionUpdatePreview, &QAction::triggered, 
this, &QgsLayoutMapWidget::updatePreview );
 
   57  connect( mFollowVisibilityPresetCheckBox, &QCheckBox::stateChanged, 
this, &QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged );
 
   58  connect( mKeepLayerListCheckBox, &QCheckBox::stateChanged, 
this, &QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged );
 
   59  connect( mKeepLayerStylesCheckBox, &QCheckBox::stateChanged, 
this, &QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged );
 
   60  connect( mDrawCanvasItemsCheckBox, &QCheckBox::stateChanged, 
this, &QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged );
 
   61  connect( mOverviewBlendModeComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged );
 
   62  connect( mOverviewInvertCheckbox, &QCheckBox::toggled, 
this, &QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled );
 
   63  connect( mOverviewCenterCheckbox, &QCheckBox::toggled, 
this, &QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled );
 
   64  connect( mOverviewPositionComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutMapWidget::overviewStackingChanged );
 
   66  connect( mXMinLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mXMinLineEdit_editingFinished );
 
   67  connect( mXMaxLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mXMaxLineEdit_editingFinished );
 
   68  connect( mYMinLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mYMinLineEdit_editingFinished );
 
   69  connect( mYMaxLineEdit, &QLineEdit::editingFinished, 
this, &QgsLayoutMapWidget::mYMaxLineEdit_editingFinished );
 
   70  connect( mAtlasMarginRadio, &QRadioButton::toggled, 
this, &QgsLayoutMapWidget::mAtlasMarginRadio_toggled );
 
   71  connect( mAtlasCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, 
this, &QgsLayoutMapWidget::mAtlasCheckBox_toggled );
 
   72  connect( mAtlasMarginSpinBox, 
static_cast<void ( QSpinBox::* )( 
int )
>( &QSpinBox::valueChanged ), 
this, &QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged );
 
   73  connect( mAtlasFixedScaleRadio, &QRadioButton::toggled, 
this, &QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled );
 
   74  connect( mAtlasPredefinedScaleRadio, &QRadioButton::toggled, 
this, &QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled );
 
   75  connect( mAddGridPushButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mAddGridPushButton_clicked );
 
   76  connect( mRemoveGridPushButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mRemoveGridPushButton_clicked );
 
   77  connect( mCopyGridPushButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mCopyGridPushButton_clicked );
 
   78  connect( mGridUpButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mGridUpButton_clicked );
 
   79  connect( mGridDownButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mGridDownButton_clicked );
 
   80  connect( mGridListWidget, &QListWidget::currentItemChanged, 
this, &QgsLayoutMapWidget::mGridListWidget_currentItemChanged );
 
   81  connect( mGridListWidget, &QListWidget::itemChanged, 
this, &QgsLayoutMapWidget::mGridListWidget_itemChanged );
 
   82  connect( mGridPropertiesButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mGridPropertiesButton_clicked );
 
   83  connect( mAddOverviewPushButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mAddOverviewPushButton_clicked );
 
   84  connect( mRemoveOverviewPushButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked );
 
   85  connect( mOverviewUpButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mOverviewUpButton_clicked );
 
   86  connect( mOverviewDownButton, &QPushButton::clicked, 
this, &QgsLayoutMapWidget::mOverviewDownButton_clicked );
 
   87  connect( mOverviewCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, 
this, &QgsLayoutMapWidget::mOverviewCheckBox_toggled );
 
   88  connect( mOverviewListWidget, &QListWidget::currentItemChanged, 
this, &QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged );
 
   89  connect( mOverviewListWidget, &QListWidget::itemChanged, 
this, &QgsLayoutMapWidget::mOverviewListWidget_itemChanged );
 
   90  connect( mActionLabelSettings, &QAction::triggered, 
this, &QgsLayoutMapWidget::showLabelSettings );
 
   91  connect( mActionClipSettings, &QAction::triggered, 
this, &QgsLayoutMapWidget::showClipSettings );
 
   93  connect( mTemporalCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, 
this, &QgsLayoutMapWidget::mTemporalCheckBox_toggled );
 
   94  connect( mStartDateTime, &QDateTimeEdit::dateTimeChanged, 
this, &QgsLayoutMapWidget::updateTemporalExtent );
 
   95  connect( mEndDateTime, &QDateTimeEdit::dateTimeChanged, 
this, &QgsLayoutMapWidget::updateTemporalExtent );
 
   99  connect( mElevationRangeCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, 
this, &QgsLayoutMapWidget::mElevationRangeCheckBox_toggled );
 
  100  connect( mZLowerSpin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, &QgsLayoutMapWidget::updateZRange );
 
  101  connect( mZUpperSpin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, &QgsLayoutMapWidget::updateZRange );
 
  103  mStartDateTime->setDateTimeRange( QDateTime( QDate( 1, 1, 1 ), QTime( 0, 0, 0 ) ), mStartDateTime->maximumDateTime() );
 
  104  mEndDateTime->setDateTimeRange( QDateTime( QDate( 1, 1, 1 ), QTime( 0, 0, 0 ) ), mStartDateTime->maximumDateTime() );
 
  105  mStartDateTime->setDisplayFormat( 
"yyyy-MM-dd HH:mm:ss" );
 
  106  mEndDateTime->setDisplayFormat( 
"yyyy-MM-dd HH:mm:ss" );
 
  108  connect( mActionMoveContent, &QAction::triggered, 
this, &QgsLayoutMapWidget::switchToMoveContentTool );
 
  110  mMapRotationSpinBox->setClearValue( 0 );
 
  114  mLayersMenu = 
new QMenu( 
this );
 
  115  QToolButton *btnLayers = 
new QToolButton( 
this );
 
  116  btnLayers->setAutoRaise( 
true );
 
  117  btnLayers->setToolTip( tr( 
"Set Map Extent to Layer Extent" ) );
 
  119  btnLayers->setPopupMode( QToolButton::InstantPopup );
 
  120  btnLayers->setMenu( mLayersMenu );
 
  122  mDockToolbar->insertWidget( mActionMoveContent, btnLayers );
 
  123  connect( mLayersMenu, &QMenu::aboutToShow, 
this, &QgsLayoutMapWidget::aboutToShowLayersMenu );
 
  125  mBookmarkMenu = 
new QMenu( 
this );
 
  126  QToolButton *btnBookmarks = 
new QToolButton( 
this );
 
  127  btnBookmarks->setAutoRaise( 
true );
 
  128  btnBookmarks->setToolTip( tr( 
"Set Map Extent to Bookmark Extent" ) );
 
  130  btnBookmarks->setPopupMode( QToolButton::InstantPopup );
 
  131  btnBookmarks->setMenu( mBookmarkMenu );
 
  133  mDockToolbar->insertWidget( mActionMoveContent, btnBookmarks );
 
  134  connect( mBookmarkMenu, &QMenu::aboutToShow, 
this, &QgsLayoutMapWidget::aboutToShowBookmarkMenu );
 
  138  mainLayout->addWidget( mItemPropertiesWidget );
 
  140  mScaleLineEdit->setValidator( 
new QDoubleValidator( mScaleLineEdit ) );
 
  142  mXMinLineEdit->setValidator( 
new QDoubleValidator( mXMinLineEdit ) );
 
  143  mXMaxLineEdit->setValidator( 
new QDoubleValidator( mXMaxLineEdit ) );
 
  144  mYMinLineEdit->setValidator( 
new QDoubleValidator( mYMinLineEdit ) );
 
  145  mYMaxLineEdit->setValidator( 
new QDoubleValidator( mYMaxLineEdit ) );
 
  153  blockAllSignals( 
true );
 
  156  mCrsSelector->setNotSetText( tr( 
"Use Project CRS" ) );
 
  157  mCrsSelector->setDialogTitle( tr( 
"Map Item CRS" ) );
 
  162  mFollowVisibilityPresetCombo->setModel( 
new QStringListModel( mFollowVisibilityPresetCombo ) );
 
  163  connect( mFollowVisibilityPresetCombo, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutMapWidget::followVisibilityPresetSelected );
 
  165  onMapThemesChanged();
 
  168  QMenu *menuKeepLayers = 
new QMenu( 
this );
 
  169  mLayerListFromPresetButton->setMenu( menuKeepLayers );
 
  171  mLayerListFromPresetButton->setToolTip( tr( 
"Set layer list from a map theme" ) );
 
  172  connect( menuKeepLayers, &QMenu::aboutToShow, 
this, &QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu );
 
  180    compositionAtlasToggled( atlas->enabled() );
 
  183  mOverviewFrameMapComboBox->setCurrentLayout( item->
layout() );
 
  185  mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
 
  191  mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
 
  216  loadOverviewEntries();
 
  218  connect( mMapRotationSpinBox, 
static_cast<void ( 
QgsDoubleSpinBox::* )( 
double )
>( &QgsDoubleSpinBox::valueChanged ), 
this, &QgsLayoutMapWidget::rotationChanged );
 
  222  blockAllSignals( 
false );
 
 
  227  if ( mItemPropertiesWidget )
 
 
  233  mReportTypeString = string;
 
  234  mAtlasCheckBox->setTitle( tr( 
"Controlled by %1" ).arg( 
string == tr( 
"atlas" ) ? tr( 
"Atlas" ) : tr( 
"Report" ) ) );
 
  235  mAtlasPredefinedScaleRadio->setToolTip( tr( 
"Use one of the predefined scales of the project where the %1 feature best fits." ).arg( 
string ) );
 
  238    mClipWidget->setReportTypeString( 
string );
 
  240    mLabelWidget->setReportTypeString( 
string );
 
 
  261  mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
 
  262  mItemPropertiesWidget->
setItem( mMapItem );
 
  264    mLabelWidget->setItem( mMapItem );
 
  266    mClipWidget->setItem( mMapItem );
 
  273    mOverviewFrameStyleButton->registerExpressionContextGenerator( mMapItem );
 
 
  297void QgsLayoutMapWidget::compositionAtlasToggled( 
bool atlasEnabled )
 
  299  if ( atlasEnabled && mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer()
 
  302    mAtlasCheckBox->setEnabled( 
true );
 
  306    mAtlasCheckBox->setEnabled( 
false );
 
  307    mAtlasCheckBox->setChecked( 
false );
 
  311void QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu()
 
  316  QMenu *menu = qobject_cast<QMenu *>( sender() );
 
  322  for ( 
const QString &presetName : constMapThemes )
 
  324    menu->addAction( presetName, 
this, &QgsLayoutMapWidget::keepLayersVisibilityPresetSelected );
 
  327  if ( menu->actions().isEmpty() )
 
  328    menu->addAction( tr( 
"No presets defined" ) )->setEnabled( 
false );
 
  331void QgsLayoutMapWidget::followVisibilityPresetSelected( 
int currentIndex )
 
  336  if ( mBlockThemeComboChanges != 0 )
 
  339  if ( currentIndex == -1 )
 
  343  if ( currentIndex != 0 )
 
  345    presetName = mFollowVisibilityPresetCombo->currentText();
 
  348  if ( presetName == mMapItem->followVisibilityPresetName() )
 
  351  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Preset" ) );
 
  352  mFollowVisibilityPresetCheckBox->setChecked( 
true );
 
  353  mMapItem->setFollowVisibilityPresetName( presetName );
 
  354  mMapItem->layout()->undoStack()->endCommand();
 
  356  mMapItem->invalidateCache();
 
  359void QgsLayoutMapWidget::keepLayersVisibilityPresetSelected()
 
  361  QAction *action = qobject_cast<QAction *>( sender() );
 
  365  const QString presetName = action->text();
 
  366  const QList<QgsMapLayer *> lst = orderedPresetVisibleLayers( presetName );
 
  369    mKeepLayerListCheckBox->setChecked( 
true );
 
  370    mMapItem->setLayers( lst );
 
  372    mKeepLayerStylesCheckBox->setChecked( 
true );
 
  374    mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Preset" ) );
 
  375    mMapItem->setLayerStyleOverrides( 
QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverrides( presetName ) );
 
  376    mMapItem->layout()->undoStack()->endCommand();
 
  378    mMapItem->invalidateCache();
 
  382void QgsLayoutMapWidget::onMapThemesChanged()
 
  384  if ( QStringListModel *model = qobject_cast<QStringListModel *>( mFollowVisibilityPresetCombo->model() ) )
 
  386    mBlockThemeComboChanges++;
 
  388    lst.append( tr( 
"(none)" ) );
 
  390    model->setStringList( lst );
 
  393    const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
 
  394    mFollowVisibilityPresetCombo->blockSignals( 
true );
 
  395    mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 ); 
 
  396    mFollowVisibilityPresetCombo->blockSignals( 
false );
 
  397    mBlockThemeComboChanges--;
 
  408  if ( mMapItem->presetCrs() == 
crs )
 
  414  bool updateExtent = 
false;
 
  421    newExtent = xForm.transformBoundingBox( prevExtent );
 
  429  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map CRS" ) );
 
  430  mMapItem->setCrs( 
crs );
 
  432    mMapItem->zoomToExtent( newExtent );
 
  433  mMapItem->layout()->undoStack()->endCommand();
 
  434  mMapItem->invalidateCache();
 
  437void QgsLayoutMapWidget::overviewSymbolChanged()
 
  445  mMapItem->endCommand();
 
  446  mMapItem->invalidateCache();
 
  449void QgsLayoutMapWidget::showLabelSettings()
 
  453  if ( !mReportTypeString.isEmpty() )
 
  454    mLabelWidget->setReportTypeString( mReportTypeString );
 
  459void QgsLayoutMapWidget::showClipSettings()
 
  462  if ( !mReportTypeString.isEmpty() )
 
  463    mClipWidget->setReportTypeString( mReportTypeString );
 
  467void QgsLayoutMapWidget::switchToMoveContentTool()
 
  473void QgsLayoutMapWidget::aboutToShowLayersMenu()
 
  475  mLayersMenu->clear();
 
  477  if ( !mMapLayerModel )
 
  483  if ( mMapLayerModel->rowCount() == 0 )
 
  485    QAction *action = 
new QAction( tr( 
"No spatial layers available" ) );
 
  486    action->setEnabled( 
false );
 
  487    mLayersMenu->addAction( action );
 
  491  for ( 
int i = 0; i < mMapLayerModel->rowCount(); ++i )
 
  493    const QModelIndex index = mMapLayerModel->index( i, 0 );
 
  494    const QIcon icon = qvariant_cast<QIcon>( mMapLayerModel->data( index, Qt::DecorationRole ) );
 
  495    const QString text = mMapLayerModel->data( index, Qt::DisplayRole ).toString();
 
  496    const QString tooltip = mMapLayerModel->data( index, Qt::ToolTipRole ).toString();
 
  499    QAction *action = 
new QAction( icon, text, mLayersMenu );
 
  500    action->setToolTip( tooltip );
 
  501    connect( action, &QAction::triggered, 
this, [
this, layerId] {
 
  507    mLayersMenu->addAction( action );
 
  511void QgsLayoutMapWidget::aboutToShowBookmarkMenu()
 
  513  mBookmarkMenu->clear();
 
  517  if ( !mBookmarkModel )
 
  522  if ( mBookmarkModel->rowCount() == 0 )
 
  524    QAction *action = 
new QAction( tr( 
"No bookmarks available" ) );
 
  525    action->setEnabled( 
false );
 
  526    mBookmarkMenu->addAction( action );
 
  530  QMap<QString, QMenu *> groupMenus;
 
  531  for ( 
int i = 0; i < mBookmarkModel->rowCount(); ++i )
 
  534    QMenu *destMenu = mBookmarkMenu;
 
  535    if ( !group.isEmpty() )
 
  537      destMenu = groupMenus.value( group );
 
  540        destMenu = 
new QMenu( group, mBookmarkMenu );
 
  541        groupMenus[group] = destMenu;
 
  546    connect( action, &QAction::triggered, 
this, [
this, extent] {
 
  547      setToCustomExtent( extent );
 
  549    destMenu->addAction( action );
 
  552  QStringList groupKeys = groupMenus.keys();
 
  553  groupKeys.sort( Qt::CaseInsensitive );
 
  554  for ( 
int i = 0; i < groupKeys.count(); ++i )
 
  556    if ( mBookmarkMenu->actions().value( i ) )
 
  557      mBookmarkMenu->insertMenu( mBookmarkMenu->actions().at( i ), groupMenus.value( groupKeys.at( i ) ) );
 
  559      mBookmarkMenu->addMenu( groupMenus.value( groupKeys.at( i ) ) );
 
  565  if ( !mMapItem || referencedExtent.
isEmpty() )
 
  571  if ( referencedExtent.
crs() != mMapItem->crs() )
 
  576      coordinateTransform.setBallparkTransformsAreAppropriate( 
true );
 
  577      extent = coordinateTransform.transformBoundingBox( extent );
 
  586  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Extent" ) );
 
  587  mMapItem->zoomToExtent( extent );
 
  588  mMapItem->layout()->undoStack()->endCommand();
 
  591void QgsLayoutMapWidget::mTemporalCheckBox_toggled( 
bool checked )
 
  598  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Toggle Temporal Range" ) );
 
  599  mMapItem->setIsTemporal( checked );
 
  600  mMapItem->layout()->undoStack()->endCommand();
 
  604    whileBlocking( mStartDateTime )->setDateTime( mMapItem->temporalRange().begin() );
 
  605    whileBlocking( mEndDateTime )->setDateTime( mMapItem->temporalRange().end() );
 
  611void QgsLayoutMapWidget::updateTemporalExtent()
 
  618  const QDateTime begin = mStartDateTime->dateTime();
 
  619  const QDateTime end = mEndDateTime->dateTime();
 
  622  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Set Temporal Range" ) );
 
  623  mMapItem->setTemporalRange( range );
 
  624  mMapItem->layout()->undoStack()->endCommand();
 
  629void QgsLayoutMapWidget::mElevationRangeCheckBox_toggled( 
bool checked )
 
  636  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Toggle Z Range" ) );
 
  637  mMapItem->setZRangeEnabled( checked );
 
  638  mMapItem->layout()->undoStack()->endCommand();
 
  643void QgsLayoutMapWidget::updateZRange()
 
  650  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Set Z Range" ) );
 
  651  double zLower = mZLowerSpin->value();
 
  652  if ( zLower == mZLowerSpin->clearValue() )
 
  653    zLower = std::numeric_limits<double>::lowest();
 
  654  double zUpper = mZUpperSpin->value();
 
  655  if ( zUpper == mZUpperSpin->clearValue() )
 
  656    zUpper = std::numeric_limits<double>::max();
 
  659  mMapItem->layout()->undoStack()->endCommand();
 
  664void QgsLayoutMapWidget::mAtlasCheckBox_toggled( 
bool checked )
 
  671  mAtlasFixedScaleRadio->setEnabled( checked );
 
  672  mAtlasMarginRadio->setEnabled( checked );
 
  674  if ( mAtlasMarginRadio->isEnabled() && mAtlasMarginRadio->isChecked() )
 
  676    mAtlasMarginSpinBox->setEnabled( 
true );
 
  680    mAtlasMarginSpinBox->setEnabled( 
false );
 
  683  mAtlasPredefinedScaleRadio->setEnabled( checked );
 
  688    if ( mMapItem->layout() )
 
  690      toggleAtlasScalingOptionsByLayerType();
 
  695  if ( !hasPredefinedScales() )
 
  697    mAtlasPredefinedScaleRadio->setEnabled( 
false );
 
  700  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Set Atlas Driven" ) );
 
  701  mMapItem->setAtlasDriven( checked );
 
  702  mMapItem->layout()->undoStack()->endCommand();
 
  706void QgsLayoutMapWidget::updateMapForAtlas()
 
  709  if ( mMapItem->atlasDriven() )
 
  716    mMapItem->invalidateCache();
 
  720void QgsLayoutMapWidget::mAtlasMarginRadio_toggled( 
bool checked )
 
  722  mAtlasMarginSpinBox->setEnabled( checked );
 
  724  if ( checked && mMapItem )
 
  726    mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Atlas Mode" ) );
 
  728    mMapItem->layout()->undoStack()->endCommand();
 
  733void QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged( 
int value )
 
  741  mMapItem->setAtlasMargin( value / 100. );
 
  742  mMapItem->layout()->undoStack()->endCommand();
 
  746void QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled( 
bool checked )
 
  755    mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Atlas Mode" ) );
 
  757    mMapItem->layout()->undoStack()->endCommand();
 
  762void QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled( 
bool checked )
 
  769  if ( hasPredefinedScales() )
 
  773      mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Atlas Scales" ) );
 
  775      mMapItem->layout()->undoStack()->endCommand();
 
  783    mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Atlas Mode" ) );
 
  785    mMapItem->layout()->undoStack()->endCommand();
 
  789void QgsLayoutMapWidget::mScaleLineEdit_editingFinished()
 
  796  bool conversionSuccess = 
false;
 
  797  const double scaleDenominator = QLocale().toDouble( mScaleLineEdit->text(), &conversionSuccess );
 
  798  if ( !conversionSuccess )
 
  806  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Scale" ) );
 
  807  mMapItem->setScale( scaleDenominator );
 
  808  mMapItem->layout()->undoStack()->endCommand();
 
  811void QgsLayoutMapWidget::rotationChanged( 
double value )
 
  819  mMapItem->setMapRotation( value );
 
  820  mMapItem->layout()->undoStack()->endCommand();
 
  821  mMapItem->invalidateCache();
 
  824void QgsLayoutMapWidget::setToMapCanvasExtent()
 
  840      xForm.setBallparkTransformsAreAppropriate( 
true );
 
  841      newExtent = xForm.transformBoundingBox( newExtent );
 
  850  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Extent" ) );
 
  851  mMapItem->zoomToExtent( newExtent );
 
  852  mMapItem->layout()->undoStack()->endCommand();
 
  855void QgsLayoutMapWidget::setToMapCanvasScale()
 
  862  const double newScale = mMapCanvas->
scale();
 
  864  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Scale" ) );
 
  865  mMapItem->setScale( newScale );
 
  866  mMapItem->layout()->undoStack()->endCommand();
 
  869void QgsLayoutMapWidget::viewExtentInCanvas()
 
  876  const QgsRectangle currentMapExtent = mMapItem->extent();
 
  878  if ( !currentMapExtent.
isEmpty() )
 
  893void QgsLayoutMapWidget::viewScaleInCanvas()
 
  900  const double currentScale = mMapItem->scale();
 
  901  mMapCanvas->
zoomScale( currentScale, 
true );
 
  904void QgsLayoutMapWidget::mXMinLineEdit_editingFinished()
 
  906  updateComposerExtentFromGui();
 
  909void QgsLayoutMapWidget::mXMaxLineEdit_editingFinished()
 
  911  updateComposerExtentFromGui();
 
  914void QgsLayoutMapWidget::mYMinLineEdit_editingFinished()
 
  916  updateComposerExtentFromGui();
 
  919void QgsLayoutMapWidget::mYMaxLineEdit_editingFinished()
 
  921  updateComposerExtentFromGui();
 
  924void QgsLayoutMapWidget::updateGuiElements()
 
  931  blockAllSignals( 
true );
 
  932  mLabel->setText( mMapItem->displayName() );
 
  934  whileBlocking( mCrsSelector )->setCrs( mMapItem->presetCrs() );
 
  937  const double scale = mMapItem->scale();
 
  940  if ( scale >= 10000 )
 
  943    mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 
'f', 0 ) );
 
  945  else if ( scale >= 10 )
 
  947    mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 
'f', 3 ) );
 
  949  else if ( scale >= 1 )
 
  952    mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 
'f', 4 ) );
 
  957    mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 
'f', 10 ) );
 
  961  const QgsRectangle composerMapExtent = mMapItem->extent();
 
  962  mXMinLineEdit->setText( QLocale().toString( composerMapExtent.
xMinimum(), 
'f', 3 ) );
 
  963  mXMaxLineEdit->setText( QLocale().toString( composerMapExtent.
xMaximum(), 
'f', 3 ) );
 
  964  mYMinLineEdit->setText( QLocale().toString( composerMapExtent.
yMinimum(), 
'f', 3 ) );
 
  965  mYMaxLineEdit->setText( QLocale().toString( composerMapExtent.
yMaximum(), 
'f', 3 ) );
 
  970  mFollowVisibilityPresetCheckBox->setCheckState(
 
  971    mMapItem->followVisibilityPreset() ? Qt::Checked : Qt::Unchecked
 
  973  const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
 
  974  mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 ); 
 
  977  if ( mMapItem->keepLayerSet() )
 
  979    mKeepLayerListCheckBox->setCheckState( Qt::Checked );
 
  983    mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
 
  986  mKeepLayerStylesCheckBox->setEnabled( mMapItem->keepLayerSet() );
 
  987  mKeepLayerStylesCheckBox->setCheckState( mMapItem->keepLayerStyles() ? Qt::Checked : Qt::Unchecked );
 
  990  if ( mMapItem->drawAnnotations() )
 
  992    mDrawCanvasItemsCheckBox->setCheckState( Qt::Checked );
 
  996    mDrawCanvasItemsCheckBox->setCheckState( Qt::Unchecked );
 
 1000  mAtlasCheckBox->setChecked( mMapItem->atlasDriven() );
 
 1003  mAtlasFixedScaleRadio->setEnabled( mMapItem->atlasDriven() );
 
 1006  mAtlasMarginRadio->setEnabled( mMapItem->atlasDriven() );
 
 1008  mAtlasPredefinedScaleRadio->setEnabled( mMapItem->atlasDriven() );
 
 1011  if ( mMapItem->atlasDriven() )
 
 1013    toggleAtlasScalingOptionsByLayerType();
 
 1016  if ( !hasPredefinedScales() )
 
 1018    mAtlasPredefinedScaleRadio->setEnabled( 
false );
 
 1021  mTemporalCheckBox->setChecked( mMapItem->isTemporal() );
 
 1022  mTemporalCheckBox->setCollapsed( !mMapItem->isTemporal() );
 
 1023  mStartDateTime->setEnabled( mMapItem->isTemporal() );
 
 1024  mEndDateTime->setEnabled( mMapItem->isTemporal() );
 
 1025  if ( mMapItem->isTemporal() )
 
 1027    mStartDateTime->setDateTime( mMapItem->temporalRange().begin() );
 
 1028    mEndDateTime->setDateTime( mMapItem->temporalRange().end() );
 
 1031  whileBlocking( mElevationRangeCheckBox )->setChecked( mMapItem->zRangeEnabled() );
 
 1032  mElevationRangeCheckBox->setCollapsed( !mMapItem->zRangeEnabled() );
 
 1033  if ( mMapItem->zRange().lower() != std::numeric_limits<double>::lowest() )
 
 1034    whileBlocking( mZLowerSpin )->setValue( mMapItem->zRange().lower() );
 
 1037  if ( mMapItem->zRange().upper() != std::numeric_limits<double>::max() )
 
 1038    whileBlocking( mZUpperSpin )->setValue( mMapItem->zRange().upper() );
 
 1044  loadOverviewEntries();
 
 1046  blockAllSignals( 
false );
 
 1049void QgsLayoutMapWidget::toggleAtlasScalingOptionsByLayerType()
 
 1067      mAtlasFixedScaleRadio->setChecked( 
true );
 
 1068    mAtlasMarginRadio->setEnabled( 
false );
 
 1073    mAtlasMarginRadio->setEnabled( 
true );
 
 1077void QgsLayoutMapWidget::updateComposerExtentFromGui()
 
 1084  double xmin, ymin, xmax, ymax;
 
 1085  bool conversionSuccess;
 
 1087  xmin = QLocale().toDouble( mXMinLineEdit->text(), &conversionSuccess );
 
 1088  if ( !conversionSuccess )
 
 1090  xmax = QLocale().toDouble( mXMaxLineEdit->text(), &conversionSuccess );
 
 1091  if ( !conversionSuccess )
 
 1093  ymin = QLocale().toDouble( mYMinLineEdit->text(), &conversionSuccess );
 
 1094  if ( !conversionSuccess )
 
 1096  ymax = QLocale().toDouble( mYMaxLineEdit->text(), &conversionSuccess );
 
 1097  if ( !conversionSuccess )
 
 1100  const QgsRectangle newExtent( xmin, ymin, xmax, ymax );
 
 1102  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Extent" ) );
 
 1103  mMapItem->setExtent( newExtent );
 
 1104  mMapItem->layout()->undoStack()->endCommand();
 
 1107void QgsLayoutMapWidget::blockAllSignals( 
bool b )
 
 1109  mScaleLineEdit->blockSignals( b );
 
 1110  mXMinLineEdit->blockSignals( b );
 
 1111  mXMaxLineEdit->blockSignals( b );
 
 1112  mYMinLineEdit->blockSignals( b );
 
 1113  mYMaxLineEdit->blockSignals( b );
 
 1114  mDrawCanvasItemsCheckBox->blockSignals( b );
 
 1115  mOverviewFrameMapComboBox->blockSignals( b );
 
 1116  mOverviewFrameStyleButton->blockSignals( b );
 
 1117  mOverviewBlendModeComboBox->blockSignals( b );
 
 1118  mOverviewInvertCheckbox->blockSignals( b );
 
 1119  mOverviewCenterCheckbox->blockSignals( b );
 
 1120  mAtlasCheckBox->blockSignals( b );
 
 1121  mAtlasMarginSpinBox->blockSignals( b );
 
 1122  mAtlasFixedScaleRadio->blockSignals( b );
 
 1123  mAtlasMarginRadio->blockSignals( b );
 
 1124  mFollowVisibilityPresetCheckBox->blockSignals( b );
 
 1125  mFollowVisibilityPresetCombo->blockSignals( b );
 
 1126  mKeepLayerListCheckBox->blockSignals( b );
 
 1127  mKeepLayerStylesCheckBox->blockSignals( b );
 
 1128  mActionSetToCanvasExtent->blockSignals( b );
 
 1129  mActionUpdatePreview->blockSignals( b );
 
 1130  mTemporalCheckBox->blockSignals( b );
 
 1131  mStartDateTime->blockSignals( b );
 
 1132  mEndDateTime->blockSignals( b );
 
 1134  blockOverviewItemsSignals( b );
 
 1137void QgsLayoutMapWidget::updatePreview()
 
 1143  mMapItem->refresh();
 
 1146void QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged( 
int state )
 
 1153  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Preset" ) );
 
 1154  if ( state == Qt::Checked )
 
 1156    mMapItem->setFollowVisibilityPreset( 
true );
 
 1159    mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
 
 1160    mKeepLayerStylesCheckBox->setCheckState( Qt::Unchecked );
 
 1162    mMapItem->invalidateCache();
 
 1166    mMapItem->setFollowVisibilityPreset( 
false );
 
 1168  mMapItem->layout()->undoStack()->endCommand();
 
 1171void QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged( 
int state )
 
 1179  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Map Preset Changed" ) );
 
 1180  storeCurrentLayerSet();
 
 1181  mMapItem->setKeepLayerSet( state == Qt::Checked );
 
 1182  if ( state == Qt::Unchecked )
 
 1184    mMapItem->setLayers( QList<QgsMapLayer *>() );
 
 1186  mMapItem->layout()->undoStack()->endCommand();
 
 1189  if ( state == Qt::Checked )
 
 1192    mFollowVisibilityPresetCheckBox->setCheckState( Qt::Unchecked );
 
 1196    mKeepLayerStylesCheckBox->setChecked( Qt::Unchecked );
 
 1197    mMapItem->invalidateCache();
 
 1200  mKeepLayerStylesCheckBox->setEnabled( state == Qt::Checked );
 
 1203void QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged( 
int state )
 
 1210  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Map Preset" ) );
 
 1211  if ( state == Qt::Checked )
 
 1213    mMapItem->storeCurrentLayerStyles();
 
 1214    mMapItem->setKeepLayerStyles( 
true );
 
 1218    mMapItem->setLayerStyleOverrides( QMap<QString, QString>() );
 
 1219    mMapItem->setKeepLayerStyles( 
false );
 
 1221  mMapItem->layout()->undoStack()->endCommand();
 
 1224void QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged( 
int state )
 
 1231  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Toggle Map Item" ) );
 
 1232  mMapItem->setDrawAnnotations( state == Qt::Checked );
 
 1233  mMapItem->invalidateCache();
 
 1234  mMapItem->layout()->undoStack()->endCommand();
 
 1237void QgsLayoutMapWidget::atlasLayerChanged( 
QgsVectorLayer *layer )
 
 1242    mAtlasCheckBox->setChecked( 
false );
 
 1243    mAtlasCheckBox->setEnabled( 
false );
 
 1248    mAtlasCheckBox->setEnabled( 
true );
 
 1252  if ( mAtlasCheckBox->isChecked() )
 
 1253    toggleAtlasScalingOptionsByLayerType();
 
 1256bool QgsLayoutMapWidget::hasPredefinedScales()
 const 
 1261  if ( !hasProjectScales || scales.isEmpty() )
 
 1266    return !scales.isEmpty() && !scales[0].isEmpty();
 
 1271void QgsLayoutMapWidget::mAddGridPushButton_clicked()
 
 1278  const QString itemName = tr( 
"Grid %1" ).arg( mMapItem->grids()->size() + 1 );
 
 1280  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Add Map Grid" ) );
 
 1281  mMapItem->grids()->addGrid( grid );
 
 1282  mMapItem->layout()->undoStack()->endCommand();
 
 1283  mMapItem->updateBoundingRect();
 
 1286  addGridListItem( grid->
id(), grid->
name() );
 
 1287  mGridListWidget->setCurrentRow( 0 );
 
 1288  mGridListWidget_currentItemChanged( mGridListWidget->currentItem(), 
nullptr );
 
 1291void QgsLayoutMapWidget::mRemoveGridPushButton_clicked()
 
 1293  QListWidgetItem *item = mGridListWidget->currentItem();
 
 1299  mMapItem->beginCommand( tr( 
"Remove Grid" ) );
 
 1300  mMapItem->grids()->removeGrid( item->data( Qt::UserRole ).toString() );
 
 1301  QListWidgetItem *delItem = mGridListWidget->takeItem( mGridListWidget->row( item ) );
 
 1303  mMapItem->endCommand();
 
 1304  mMapItem->updateBoundingRect();
 
 1308void QgsLayoutMapWidget::mCopyGridPushButton_clicked()
 
 1310  QListWidgetItem *item = mGridListWidget->currentItem();
 
 1316  QgsLayoutItemMapGrid *sourceGrid = mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
 
 1322  QString itemName = tr( 
"%1 - Copy" ).arg( sourceGrid->
name() );
 
 1323  QList<QgsLayoutItemMapGrid *> grids = mMapItem->grids()->asList();
 
 1326    const auto it = std::find_if( grids.begin(), grids.end(), [&itemName]( 
const QgsLayoutItemMapGrid *grd ) { return grd->name() == itemName; } );
 
 1327    if ( it != grids.end() )
 
 1330      itemName = tr( 
"%1 - Copy %2" ).arg( sourceGrid->
name() ).arg( i );
 
 1338  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Duplicate Map Grid" ) );
 
 1339  mMapItem->grids()->addGrid( grid );
 
 1340  mMapItem->layout()->undoStack()->endCommand();
 
 1341  mMapItem->updateBoundingRect();
 
 1344  addGridListItem( grid->
id(), grid->
name() );
 
 1345  mGridListWidget->setCurrentRow( 0 );
 
 1346  mGridListWidget_currentItemChanged( mGridListWidget->currentItem(), 
nullptr );
 
 1349void QgsLayoutMapWidget::mGridUpButton_clicked()
 
 1351  QListWidgetItem *item = mGridListWidget->currentItem();
 
 1357  const int row = mGridListWidget->row( item );
 
 1362  mGridListWidget->takeItem( row );
 
 1363  mGridListWidget->insertItem( row - 1, item );
 
 1364  mGridListWidget->setCurrentItem( item );
 
 1365  mMapItem->beginCommand( tr( 
"Move Grid Up" ) );
 
 1366  mMapItem->grids()->moveGridUp( item->data( Qt::UserRole ).toString() );
 
 1367  mMapItem->endCommand();
 
 1371void QgsLayoutMapWidget::mGridDownButton_clicked()
 
 1373  QListWidgetItem *item = mGridListWidget->currentItem();
 
 1379  const int row = mGridListWidget->row( item );
 
 1380  if ( mGridListWidget->count() <= row )
 
 1384  mGridListWidget->takeItem( row );
 
 1385  mGridListWidget->insertItem( row + 1, item );
 
 1386  mGridListWidget->setCurrentItem( item );
 
 1387  mMapItem->beginCommand( tr( 
"Move Grid Down" ) );
 
 1388  mMapItem->grids()->moveGridDown( item->data( Qt::UserRole ).toString() );
 
 1389  mMapItem->endCommand();
 
 1400  QListWidgetItem *item = mGridListWidget->currentItem();
 
 1405  return mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
 
 1408void QgsLayoutMapWidget::mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
 
 1410  mGridPropertiesButton->setEnabled( 
static_cast<bool>( current ) );
 
 1413void QgsLayoutMapWidget::mGridListWidget_itemChanged( QListWidgetItem *item )
 
 1426  mMapItem->beginCommand( tr( 
"Rename Grid" ) );
 
 1427  grid->
setName( item->text() );
 
 1428  mMapItem->endCommand();
 
 1431void QgsLayoutMapWidget::mGridPropertiesButton_clicked()
 
 1448QListWidgetItem *QgsLayoutMapWidget::addGridListItem( 
const QString &
id, 
const QString &name )
 
 1450  QListWidgetItem *item = 
new QListWidgetItem( name, 
nullptr );
 
 1451  item->setData( Qt::UserRole, 
id );
 
 1452  item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
 
 1453  mGridListWidget->insertItem( 0, item );
 
 1457void QgsLayoutMapWidget::loadGridEntries()
 
 1460  QSet<QString> selectedIds;
 
 1461  const QList<QListWidgetItem *> itemSelection = mGridListWidget->selectedItems();
 
 1462  QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
 
 1463  for ( ; sIt != itemSelection.constEnd(); ++sIt )
 
 1465    selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
 
 1468  mGridListWidget->clear();
 
 1474  const QList<QgsLayoutItemMapGrid *> grids = mMapItem->grids()->asList();
 
 1475  QList<QgsLayoutItemMapGrid *>::const_iterator gridIt = grids.constBegin();
 
 1476  for ( ; gridIt != grids.constEnd(); ++gridIt )
 
 1478    QListWidgetItem *item = addGridListItem( ( *gridIt )->id(), ( *gridIt )->name() );
 
 1479    if ( selectedIds.contains( ( *gridIt )->id() ) )
 
 1481      item->setSelected( 
true );
 
 1482      mGridListWidget->setCurrentItem( item );
 
 1486  if ( mGridListWidget->currentItem() )
 
 1488    mGridListWidget_currentItemChanged( mGridListWidget->currentItem(), 
nullptr );
 
 1492    mGridListWidget_currentItemChanged( 
nullptr, 
nullptr );
 
 1496void QgsLayoutMapWidget::mAddOverviewPushButton_clicked()
 
 1503  const QString itemName = tr( 
"Overview %1" ).arg( mMapItem->overviews()->size() + 1 );
 
 1505  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Add Map Overview" ) );
 
 1506  mMapItem->overviews()->addOverview( overview );
 
 1507  mMapItem->layout()->undoStack()->endCommand();
 
 1508  mMapItem->invalidateCache();
 
 1510  addOverviewListItem( overview->
id(), overview->
name() );
 
 1512  mOverviewListWidget->setCurrentRow( 0 );
 
 1515void QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked()
 
 1517  QListWidgetItem *item = mOverviewListWidget->currentItem();
 
 1522  mMapItem->beginCommand( tr( 
"Remove Map Overview" ) );
 
 1523  mMapItem->overviews()->removeOverview( item->data( Qt::UserRole ).toString() );
 
 1524  mMapItem->endCommand();
 
 1525  QListWidgetItem *delItem = mOverviewListWidget->takeItem( mOverviewListWidget->row( item ) );
 
 1527  mMapItem->invalidateCache();
 
 1530void QgsLayoutMapWidget::mOverviewUpButton_clicked()
 
 1532  QListWidgetItem *item = mOverviewListWidget->currentItem();
 
 1538  const int row = mOverviewListWidget->row( item );
 
 1543  mOverviewListWidget->takeItem( row );
 
 1544  mOverviewListWidget->insertItem( row - 1, item );
 
 1545  mOverviewListWidget->setCurrentItem( item );
 
 1546  mMapItem->beginCommand( tr( 
"Move Overview Up" ) );
 
 1547  mMapItem->overviews()->moveOverviewUp( item->data( Qt::UserRole ).toString() );
 
 1548  mMapItem->endCommand();
 
 1549  mMapItem->invalidateCache();
 
 1552void QgsLayoutMapWidget::mOverviewDownButton_clicked()
 
 1554  QListWidgetItem *item = mOverviewListWidget->currentItem();
 
 1560  const int row = mOverviewListWidget->row( item );
 
 1561  if ( mOverviewListWidget->count() <= row )
 
 1565  mOverviewListWidget->takeItem( row );
 
 1566  mOverviewListWidget->insertItem( row + 1, item );
 
 1567  mOverviewListWidget->setCurrentItem( item );
 
 1568  mMapItem->beginCommand( tr( 
"Move Overview Down" ) );
 
 1569  mMapItem->overviews()->moveOverviewDown( item->data( Qt::UserRole ).toString() );
 
 1570  mMapItem->endCommand();
 
 1571  mMapItem->invalidateCache();
 
 1581  QListWidgetItem *item = mOverviewListWidget->currentItem();
 
 1587  return mMapItem->overviews()->overview( item->data( Qt::UserRole ).toString() );
 
 1590void QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous )
 
 1592  Q_UNUSED( previous )
 
 1595    mOverviewCheckBox->setEnabled( 
false );
 
 1599  mOverviewCheckBox->setEnabled( 
true );
 
 1600  setOverviewItems( mMapItem->overviews()->overview( current->data( Qt::UserRole ).toString() ) );
 
 1603void QgsLayoutMapWidget::mOverviewListWidget_itemChanged( QListWidgetItem *item )
 
 1616  mMapItem->beginCommand( QStringLiteral( 
"Rename Overview" ) );
 
 1617  overview->
setName( item->text() );
 
 1618  mMapItem->endCommand();
 
 1619  if ( item->isSelected() )
 
 1622    mOverviewCheckBox->setTitle( tr( 
"Draw \"%1\" overview" ).arg( overview->
name() ) );
 
 1626void QgsLayoutMapWidget::setOverviewItemsEnabled( 
bool enabled )
 
 1628  mOverviewFrameMapLabel->setEnabled( enabled );
 
 1629  mOverviewFrameMapComboBox->setEnabled( enabled );
 
 1630  mOverviewFrameStyleLabel->setEnabled( enabled );
 
 1631  mOverviewFrameStyleButton->setEnabled( enabled );
 
 1632  mOverviewBlendModeLabel->setEnabled( enabled );
 
 1633  mOverviewBlendModeComboBox->setEnabled( enabled );
 
 1634  mOverviewInvertCheckbox->setEnabled( enabled );
 
 1635  mOverviewCenterCheckbox->setEnabled( enabled );
 
 1636  mOverviewPositionComboBox->setEnabled( enabled );
 
 1642void QgsLayoutMapWidget::blockOverviewItemsSignals( 
const bool block )
 
 1644  mOverviewFrameMapComboBox->blockSignals( block );
 
 1645  mOverviewFrameStyleButton->blockSignals( block );
 
 1646  mOverviewBlendModeComboBox->blockSignals( block );
 
 1647  mOverviewInvertCheckbox->blockSignals( block );
 
 1648  mOverviewCenterCheckbox->blockSignals( block );
 
 1649  mOverviewPositionComboBox->blockSignals( block );
 
 1650  mOverviewStackingLayerComboBox->blockSignals( block );
 
 1660  blockOverviewItemsSignals( 
true );
 
 1662  mOverviewCheckBox->setTitle( tr( 
"Draw \"%1\" overview" ).arg( overview->
name() ) );
 
 1663  mOverviewCheckBox->setChecked( overview->
enabled() );
 
 1666  mOverviewFrameMapComboBox->setItem( overview->
linkedMap() );
 
 1669  mOverviewBlendModeComboBox->setBlendMode( overview->
blendMode() );
 
 1671  mOverviewInvertCheckbox->setChecked( overview->
inverted() );
 
 1673  mOverviewCenterCheckbox->setChecked( overview->
centered() );
 
 1675  mOverviewPositionComboBox->setCurrentIndex( mOverviewPositionComboBox->findData( overview->
stackingPosition() ) );
 
 1676  mOverviewStackingLayerComboBox->setLayer( overview->
stackingLayer() );
 
 1681  blockOverviewItemsSignals( 
false );
 
 1684void QgsLayoutMapWidget::storeCurrentLayerSet()
 
 1691  mMapItem->setLayers( layers );
 
 1693  if ( mMapItem->keepLayerStyles() )
 
 1696    mMapItem->storeCurrentLayerStyles();
 
 1700QList<QgsMapLayer *> QgsLayoutMapWidget::orderedPresetVisibleLayers( 
const QString &name )
 const 
 1705  QList<QgsMapLayer *> lst;
 
 1709    if ( visibleIds.contains( layer->
id() ) )
 
 1717QListWidgetItem *QgsLayoutMapWidget::addOverviewListItem( 
const QString &
id, 
const QString &name )
 
 1719  QListWidgetItem *item = 
new QListWidgetItem( name, 
nullptr );
 
 1720  item->setData( Qt::UserRole, 
id );
 
 1721  item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
 
 1722  mOverviewListWidget->insertItem( 0, item );
 
 1726void QgsLayoutMapWidget::loadOverviewEntries()
 
 1729  QSet<QString> selectedIds;
 
 1730  const QList<QListWidgetItem *> itemSelection = mOverviewListWidget->selectedItems();
 
 1731  QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
 
 1732  for ( ; sIt != itemSelection.constEnd(); ++sIt )
 
 1734    selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
 
 1737  mOverviewListWidget->clear();
 
 1743  mOverviewFrameMapComboBox->setExceptedItemList( QList<QgsLayoutItem *>() << mMapItem );
 
 1746  const QList<QgsLayoutItemMapOverview *> overviews = mMapItem->overviews()->asList();
 
 1747  QList<QgsLayoutItemMapOverview *>::const_iterator overviewIt = overviews.constBegin();
 
 1748  for ( ; overviewIt != overviews.constEnd(); ++overviewIt )
 
 1750    QListWidgetItem *item = addOverviewListItem( ( *overviewIt )->id(), ( *overviewIt )->name() );
 
 1751    if ( selectedIds.contains( ( *overviewIt )->id() ) )
 
 1753      item->setSelected( 
true );
 
 1754      mOverviewListWidget->setCurrentItem( item );
 
 1758  if ( mOverviewListWidget->currentItem() )
 
 1760    mOverviewListWidget_currentItemChanged( mOverviewListWidget->currentItem(), 
nullptr );
 
 1764    mOverviewListWidget_currentItemChanged( 
nullptr, 
nullptr );
 
 1768void QgsLayoutMapWidget::mOverviewCheckBox_toggled( 
bool state )
 
 1776  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Overview Display Toggled" ) );
 
 1778  mMapItem->invalidateCache();
 
 1779  mMapItem->layout()->undoStack()->endCommand();
 
 1782void QgsLayoutMapWidget::overviewMapChanged( 
QgsLayoutItem *item )
 
 1794  mMapItem->beginCommand( tr( 
"Change Overview Map" ) );
 
 1796  mMapItem->invalidateCache();
 
 1797  mMapItem->endCommand();
 
 1800void QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged( 
int index )
 
 1809  mMapItem->beginCommand( tr( 
"Change Overview Blend Mode" ) );
 
 1810  overview->
setBlendMode( mOverviewBlendModeComboBox->blendMode() );
 
 1811  mMapItem->invalidateCache();
 
 1812  mMapItem->endCommand();
 
 1815void QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled( 
bool state )
 
 1823  mMapItem->beginCommand( tr( 
"Toggle Overview Inverted" ) );
 
 1825  mMapItem->invalidateCache();
 
 1826  mMapItem->endCommand();
 
 1829void QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled( 
bool state )
 
 1837  mMapItem->beginCommand( tr( 
"Toggle Overview Centered" ) );
 
 1839  mMapItem->invalidateCache();
 
 1840  mMapItem->endCommand();
 
 1843void QgsLayoutMapWidget::overviewStackingChanged( 
int )
 
 1851  mMapItem->beginCommand( tr( 
"Change Overview Position" ) );
 
 1853  mMapItem->invalidateCache();
 
 1854  mMapItem->endCommand();
 
 1861      mOverviewStackingLayerComboBox->setEnabled( 
false );
 
 1866      mOverviewStackingLayerComboBox->setEnabled( 
true );
 
 1871void QgsLayoutMapWidget::overviewStackingLayerChanged( 
QgsMapLayer *layer )
 
 1879  mMapItem->beginCommand( tr( 
"Change Overview Position" ) );
 
 1881  mMapItem->invalidateCache();
 
 1882  mMapItem->endCommand();
 
 1896  mLabelBoundarySpinBox->setClearValue( 0 );
 
 1897  mLabelBoundarySpinBox->setShowClearButton( 
true );
 
 1899  mLabelBoundaryUnitsCombo->linkToWidget( mLabelBoundarySpinBox );
 
 1900  mLabelBoundaryUnitsCombo->setConverter( &mMapItem->layout()->renderContext().measurementConverter() );
 
 1903  connect( mLabelBoundarySpinBox, 
static_cast<void ( QDoubleSpinBox::* )( 
double )
>( &QDoubleSpinBox::valueChanged ), 
this, &QgsLayoutMapLabelingWidget::labelMarginChanged );
 
 1904  connect( mShowPartialLabelsCheckBox, &QCheckBox::toggled, 
this, &QgsLayoutMapLabelingWidget::showPartialsToggled );
 
 1905  connect( mShowUnplacedCheckBox, &QCheckBox::toggled, 
this, &QgsLayoutMapLabelingWidget::showUnplacedToggled );
 
 
 1922  mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
 
 1929  updateGuiElements();
 
 
 1934void QgsLayoutMapLabelingWidget::updateGuiElements()
 
 1936  whileBlocking( mLabelBoundarySpinBox )->setValue( mMapItem->labelMargin().length() );
 
 1937  whileBlocking( mLabelBoundaryUnitsCombo )->setUnit( mMapItem->labelMargin().units() );
 
 1941  if ( mBlockingItemsListView->model() )
 
 1943    QAbstractItemModel *oldModel = mBlockingItemsListView->model();
 
 1944    mBlockingItemsListView->setModel( 
nullptr );
 
 1945    oldModel->deleteLater();
 
 1949  mBlockingItemsListView->setModel( model );
 
 1954void QgsLayoutMapLabelingWidget::labelMarginChanged( 
double val )
 
 1961  mMapItem->layout()->undoStack()->endCommand();
 
 1962  mMapItem->invalidateCache();
 
 1965void QgsLayoutMapLabelingWidget::labelMarginUnitsChanged()
 
 1971  mMapItem->setLabelMargin( 
QgsLayoutMeasurement( mLabelBoundarySpinBox->value(), mLabelBoundaryUnitsCombo->unit() ) );
 
 1972  mMapItem->layout()->undoStack()->endCommand();
 
 1973  mMapItem->invalidateCache();
 
 1976void QgsLayoutMapLabelingWidget::showPartialsToggled( 
bool checked )
 
 1981  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Label Visibility" ) );
 
 1987  mMapItem->setMapFlags( flags );
 
 1988  mMapItem->layout()->undoStack()->endCommand();
 
 1989  mMapItem->invalidateCache();
 
 1992void QgsLayoutMapLabelingWidget::showUnplacedToggled( 
bool checked )
 
 1997  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Label Visibility" ) );
 
 2003  mMapItem->setMapFlags( flags );
 
 2004  mMapItem->layout()->undoStack()->endCommand();
 
 2005  mMapItem->invalidateCache();
 
 2009  : QSortFilterProxyModel( parent )
 
 2010  , mLayoutModel( layoutModel )
 
 2013  setSourceModel( layoutModel );
 
 
 2026  if ( i.column() != 0 )
 
 2039    case Qt::CheckStateRole:
 
 2040      switch ( i.column() )
 
 2043          return mMapItem ? ( mMapItem->isLabelBlockingItem( item ) ? Qt::Checked : Qt::Unchecked ) : Qt::Unchecked;
 
 2049      return mLayoutModel->
data( sourceIndex, role );
 
 
 2057  if ( !index.isValid() )
 
 2061  if ( !item || !mMapItem )
 
 2066  mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( 
"Change Label Blocking Items" ) );
 
 2068  if ( value.toBool() )
 
 2070    mMapItem->addLabelBlockingItem( item );
 
 2074    mMapItem->removeLabelBlockingItem( item );
 
 2076  emit dataChanged( index, index, QVector<int>() << role );
 
 2078  mMapItem->layout()->undoStack()->endCommand();
 
 2079  mMapItem->invalidateCache();
 
 
 2086  Qt::ItemFlags 
flags = QSortFilterProxyModel::flags( index );
 
 2088  if ( !index.isValid() )
 
 2093  switch ( index.column() )
 
 2096      return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
 
 2098      return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
 
 
 2105  if ( !item || item == mMapItem )
 
 
 2127  mLayersTreeView->setModel( mLayerModel );
 
 2133  for ( 
int i = 0; i < mAtlasClippingTypeComboBox->count(); ++i )
 
 2135    mItemClippingTypeComboBox->addItem( mAtlasClippingTypeComboBox->itemText( i ), mAtlasClippingTypeComboBox->itemData( i ) );
 
 2138  mClipItemComboBox->setCurrentLayout( map->
layout() );
 
 2141  connect( mRadioClipSelectedLayers, &QRadioButton::toggled, 
this, &QgsLayoutMapClippingWidget::toggleLayersSelectionGui );
 
 2142  mLayersTreeView->setEnabled( 
false );
 
 2143  mSelectAllButton->setEnabled( 
false );
 
 2144  mDeselectAllButton->setEnabled( 
false );
 
 2145  mInvertSelectionButton->setEnabled( 
false );
 
 2146  mRadioClipAllLayers->setChecked( 
true );
 
 2148  connect( mClipToAtlasCheckBox, &QGroupBox::toggled, 
this, [
this]( 
bool active ) {
 
 2149    if ( !mBlockUpdates )
 
 2151      mMapItem->beginCommand( tr( 
"Toggle Atlas Clipping" ) );
 
 2152      mMapItem->atlasClippingSettings()->setEnabled( active );
 
 2153      mMapItem->endCommand();
 
 2156  connect( mForceLabelsInsideCheckBox, &QCheckBox::toggled, 
this, [
this]( 
bool active ) {
 
 2157    if ( !mBlockUpdates )
 
 2159      mMapItem->beginCommand( tr( 
"Change Atlas Clipping Label Behavior" ) );
 
 2160      mMapItem->atlasClippingSettings()->setForceLabelsInsideFeature( active );
 
 2161      mMapItem->endCommand();
 
 2164  connect( mAtlasClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [
this] {
 
 2165    if ( !mBlockUpdates )
 
 2167      mMapItem->beginCommand( tr( 
"Change Atlas Clipping Behavior" ) );
 
 2169      mMapItem->endCommand();
 
 2173  connect( mRadioClipSelectedLayers, &QCheckBox::toggled, 
this, [
this]( 
bool active ) {
 
 2174    if ( active && !mBlockUpdates )
 
 2176      mBlockUpdates = 
true;
 
 2177      mMapItem->beginCommand( tr( 
"Change Atlas Clipping Layers" ) );
 
 2178      mMapItem->atlasClippingSettings()->setRestrictToLayers( 
true );
 
 2179      mMapItem->endCommand();
 
 2180      mBlockUpdates = 
false;
 
 2184  connect( mSelectAllButton, &QPushButton::clicked, 
this, &QgsLayoutMapClippingWidget::selectAll );
 
 2185  connect( mDeselectAllButton, &QPushButton::clicked, 
this, &QgsLayoutMapClippingWidget::deselectAll );
 
 2186  connect( mInvertSelectionButton, &QPushButton::clicked, 
this, &QgsLayoutMapClippingWidget::invertSelection );
 
 2188  connect( mRadioClipAllLayers, &QCheckBox::toggled, 
this, [
this]( 
bool active ) {
 
 2189    if ( active && !mBlockUpdates )
 
 2191      mBlockUpdates = 
true;
 
 2192      mMapItem->beginCommand( tr( 
"Change Atlas Clipping Layers" ) );
 
 2193      mMapItem->atlasClippingSettings()->setRestrictToLayers( 
false );
 
 2194      mMapItem->endCommand();
 
 2195      mBlockUpdates = 
false;
 
 2198  connect( mLayerModel, &QgsMapLayerModel::dataChanged, 
this, [
this]( 
const QModelIndex &, 
const QModelIndex &, 
const QVector<int> &roles = QVector<int>() ) {
 
 2199    if ( !roles.contains( Qt::CheckStateRole ) )
 
 2202    if ( !mBlockUpdates )
 
 2204      mBlockUpdates = 
true;
 
 2205      mMapItem->beginCommand( tr( 
"Change Atlas Clipping Layers" ) );
 
 2206      mMapItem->atlasClippingSettings()->setLayersToClip( mLayerModel->
layersChecked() );
 
 2207      mMapItem->endCommand();
 
 2208      mBlockUpdates = 
false;
 
 2214  connect( mClipToItemCheckBox, &QGroupBox::toggled, 
this, [
this]( 
bool active ) {
 
 2215    if ( !mBlockUpdates )
 
 2217      mMapItem->beginCommand( tr( 
"Toggle Map Clipping" ) );
 
 2218      mMapItem->itemClippingSettings()->setEnabled( active );
 
 2219      mMapItem->endCommand();
 
 2222  connect( mItemClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [
this] {
 
 2223    if ( !mBlockUpdates )
 
 2225      mMapItem->beginCommand( tr( 
"Change Map Clipping Behavior" ) );
 
 2227      mMapItem->endCommand();
 
 2230  connect( mForceLabelsInsideItemCheckBox, &QCheckBox::toggled, 
this, [
this]( 
bool active ) {
 
 2231    if ( !mBlockUpdates )
 
 2233      mMapItem->beginCommand( tr( 
"Change Map Clipping Label Behavior" ) );
 
 2234      mMapItem->itemClippingSettings()->setForceLabelsInsideClipPath( active );
 
 2235      mMapItem->endCommand();
 
 2239    if ( !mBlockUpdates )
 
 2241      mMapItem->beginCommand( tr( 
"Change Map Clipping Item" ) );
 
 2242      mMapItem->itemClippingSettings()->setSourceItem( item );
 
 2243      mMapItem->endCommand();
 
 2253    atlasToggled( atlas->enabled() );
 
 
 2259  mClipToAtlasCheckBox->setTitle( tr( 
"Clip to %1 feature" ).arg( 
string ) );
 
 2260  mClipToAtlasLabel->setText( tr( 
"<b>When enabled, map layers will be automatically clipped to the boundary of the current %1 feature.</b>" ).arg( 
string ) );
 
 2261  mForceLabelsInsideCheckBox->setText( tr( 
"Force labels inside %1 feature" ).arg( 
string ) );
 
 
 2274  mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
 
 2281  updateGuiElements();
 
 
 2286void QgsLayoutMapClippingWidget::updateGuiElements()
 
 2288  if ( mBlockUpdates )
 
 2291  mBlockUpdates = 
true;
 
 2292  mClipToAtlasCheckBox->setChecked( mMapItem->atlasClippingSettings()->enabled() );
 
 2293  mAtlasClippingTypeComboBox->setCurrentIndex( mAtlasClippingTypeComboBox->findData( 
static_cast<int>( mMapItem->atlasClippingSettings()->featureClippingType() ) ) );
 
 2294  mForceLabelsInsideCheckBox->setChecked( mMapItem->atlasClippingSettings()->forceLabelsInsideFeature() );
 
 2296  mRadioClipAllLayers->setChecked( !mMapItem->atlasClippingSettings()->restrictToLayers() );
 
 2297  mRadioClipSelectedLayers->setChecked( mMapItem->atlasClippingSettings()->restrictToLayers() );
 
 2298  mLayerModel->
setLayersChecked( mMapItem->atlasClippingSettings()->layersToClip() );
 
 2300  mClipToItemCheckBox->setChecked( mMapItem->itemClippingSettings()->enabled() );
 
 2301  mItemClippingTypeComboBox->setCurrentIndex( mItemClippingTypeComboBox->findData( 
static_cast<int>( mMapItem->itemClippingSettings()->featureClippingType() ) ) );
 
 2302  mForceLabelsInsideItemCheckBox->setChecked( mMapItem->itemClippingSettings()->forceLabelsInsideClipPath() );
 
 2303  mClipItemComboBox->setItem( mMapItem->itemClippingSettings()->sourceItem() );
 
 2305  mBlockUpdates = 
false;
 
 2308void QgsLayoutMapClippingWidget::atlasLayerChanged( 
QgsVectorLayer *layer )
 
 2313    mClipToAtlasCheckBox->setChecked( 
false );
 
 2314    mClipToAtlasCheckBox->setEnabled( 
false );
 
 2319    mClipToAtlasCheckBox->setEnabled( 
true );
 
 2323void QgsLayoutMapClippingWidget::atlasToggled( 
bool atlasEnabled )
 
 2325  if ( atlasEnabled && mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer()
 
 2328    mClipToAtlasCheckBox->setEnabled( 
true );
 
 2332    mClipToAtlasCheckBox->setEnabled( 
false );
 
 2333    mClipToAtlasCheckBox->setChecked( 
false );
 
 2337void QgsLayoutMapClippingWidget::invertSelection()
 
 2339  for ( 
int i = 0; i < mLayerModel->
rowCount( QModelIndex() ); i++ )
 
 2341    QModelIndex index = mLayerModel->
index( i, 0 );
 
 2342    Qt::CheckState currentState = Qt::CheckState( mLayerModel->
data( index, Qt::CheckStateRole ).toInt() );
 
 2343    Qt::CheckState newState = ( currentState == Qt::Checked ) ? Qt::Unchecked : Qt::Checked;
 
 2344    mLayerModel->
setData( index, newState, Qt::CheckStateRole );
 
 2348void QgsLayoutMapClippingWidget::selectAll()
 
 2350  for ( 
int i = 0; i < mLayerModel->
rowCount( QModelIndex() ); i++ )
 
 2352    QModelIndex index = mLayerModel->
index( i, 0 );
 
 2353    mLayerModel->
setData( index, Qt::Checked, Qt::CheckStateRole );
 
 2357void QgsLayoutMapClippingWidget::deselectAll()
 
 2359  for ( 
int i = 0; i < mLayerModel->
rowCount( QModelIndex() ); i++ )
 
 2361    QModelIndex index = mLayerModel->
index( i, 0 );
 
 2362    mLayerModel->
setData( index, Qt::Unchecked, Qt::CheckStateRole );
 
 2366void QgsLayoutMapClippingWidget::toggleLayersSelectionGui( 
bool toggled )
 
 2368  mLayersTreeView->setEnabled( toggled );
 
 2369  mSelectAllButton->setEnabled( toggled );
 
 2370  mDeselectAllButton->setEnabled( toggled );
 
 2371  mInvertSelectionButton->setEnabled( toggled );
 
@ SpatialLayer
All spatial layers.
 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
 
static QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks.
 
@ Extent
Bookmark extent as a QgsReferencedRectangle.
 
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
 
Represents a coordinate reference system (CRS).
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
 
Custom exception class for Coordinate Reference System related exceptions.
 
QgsRange which stores a range of double values.
 
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
 
@ MinimumValue
Reset value to minimum()
 
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
 
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
 
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas.
 
Used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.
 
void toggled(bool enabled)
Emitted when atlas is enabled or disabled.
 
A common interface for layout designer dialogs and widgets.
 
virtual void activateTool(StandardTool tool)=0
Activates a standard layout designer tool.
 
@ ToolMoveItemContent
Move item content tool.
 
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
 
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
 
void copyProperties(const QgsLayoutItemMapGrid *other)
Copies properties from specified map grid.
 
QString id() const
Returns the unique id for the map item.
 
StackingPosition
Item stacking position, specifies where the in the map's stack the item should be rendered.
 
@ StackBelowMapLabels
Render above all map layers, but below map labels.
 
@ StackAboveMapLabels
Render above all map layers and labels.
 
@ StackBelowMapLayer
Render below a specific map layer (see stackingLayer())
 
@ StackAboveMapLayer
Render above a specific map layer (see stackingLayer())
 
@ StackBelowMap
Render below all map layers.
 
void setStackingLayer(QgsMapLayer *layer)
Sets the item's stacking layer, which specifies where the in the map's stack the item should be rende...
 
virtual void setEnabled(bool enabled)
Controls whether the item will be drawn.
 
void setStackingPosition(StackingPosition position)
Sets the item's stacking position, which specifies where the in the map's stack the item should be re...
 
StackingPosition stackingPosition() const
Returns the item's stacking position, which specifies where the in the map's stack the item should be...
 
QString name() const
Returns the friendly display name for the item.
 
void setName(const QString &name)
Sets the friendly display name for the item.
 
bool enabled() const
Returns whether the item will be drawn.
 
QgsMapLayer * stackingLayer() const
Returns the item's stacking layer, which specifies where the in the map's stack the item should be re...
 
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
 
QgsFillSymbol * frameSymbol()
Returns the fill symbol used for drawing the overview extent.
 
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
 
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the overview.
 
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
 
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map to show the overview extent of.
 
void setFrameSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used for drawing the overview extent.
 
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
 
void setInverted(bool inverted)
Sets whether the overview frame is inverted, ie, whether the shaded area is drawn outside the extent ...
 
void setCentered(bool centered)
Sets whether the extent of the map is forced to center on the overview.
 
QgsLayoutItemMap * linkedMap()
Returns the source map to show the overview extent of.
 
Layout graphical items for displaying a map.
 
void extentChanged()
Emitted when the map's extent changes.
 
@ Predefined
A scale is chosen from the predefined scales.
 
@ Auto
The extent is adjusted so that each feature is fully visible.
 
@ Fixed
The current scale of the map is used for each feature of the atlas.
 
void mapRotationChanged(double newRotation)
Emitted when the map's rotation changes.
 
QFlags< MapItemFlag > MapItemFlags
 
@ ShowPartialLabels
Whether to draw labels which are partially outside of the map view.
 
@ ShowUnplacedLabels
Whether to render unplaced labels in the map view.
 
Base class for graphical items within a QgsLayout.
 
@ UndoOverviewStyle
Map overview style.
 
@ UndoMapRotation
Map rotation changed.
 
@ UndoAtlasMargin
Map atlas margin changed.
 
@ UndoMapLabelMargin
Margin for labels from edge of map.
 
int type() const override
Returns a unique graphics item type identifier.
 
@ FlagProvidesClipPath
Item can act as a clipping path provider (see clipPath())
 
Model for label blocking items.
 
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
 
QgsLayoutMapItemBlocksLabelsModel(QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent=nullptr)
constructor
 
Qt::ItemFlags flags(const QModelIndex &index) const override
 
bool setData(const QModelIndex &index, const QVariant &value, int role) override
 
QVariant data(const QModelIndex &index, int role) const override
 
int columnCount(const QModelIndex &parent=QModelIndex()) const override
 
Provides a method of storing measurements for use in QGIS layouts using a variety of different measur...
 
A model for items attached to a layout.
 
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QVariant data(const QModelIndex &index, int role) const override
 
QgsLayoutItem * itemFromIndex(const QModelIndex &index) const
Returns the QgsLayoutItem corresponding to a QModelIndex index, if possible.
 
const QgsLayout * layout() const
Returns the layout the object is attached to.
 
void changed()
Emitted when the object's properties change.
 
@ MapYMin
Map extent y minimum.
 
@ MapZRangeUpper
Map frame Z-range lower value.
 
@ StartDateTime
Temporal range's start DateTime.
 
@ MapLayers
Map layer set.
 
@ MapZRangeLower
Map frame Z-range lower value.
 
@ MapRotation
Map rotation.
 
@ MapXMax
Map extent x maximum.
 
@ MapStylePreset
Layer and style map theme.
 
@ MapYMax
Map extent y maximum.
 
@ MapAtlasMargin
Map atlas margin.
 
@ EndDateTime
Temporal range's end DateTime.
 
@ MapXMin
Map extent x minimum.
 
@ MapLabelMargin
Map label margin.
 
@ OriginalValue
Return the original, user set value.
 
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
 
void unitChanged(Qgis::LayoutUnit unit)
Emitted when the unit is changed.
 
QgsLayoutReportContext & reportContext()
Returns a reference to the layout's report context, which stores information relating to the current ...
 
Map canvas is a class for displaying all GIS data types on a canvas.
 
void zoomScale(double scale, bool ignoreScaleLock=false)
Zooms the canvas to a specific scale.
 
bool setReferencedExtent(const QgsReferencedRectangle &extent)
Sets the canvas to the specified extent.
 
double scale() const
Returns the last reported scale of the canvas.
 
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
 
void refresh()
Repaints the canvas map.
 
FeatureClippingType
Feature clipping behavior, which controls how features from vector layers will be clipped.
 
@ NoClipping
Only render features which intersect the clipping region, but do not clip these features to the regio...
 
@ ClipPainterOnly
Applying clipping on the painter only (i.e. feature boundaries will be unchanged, but may be invisibl...
 
@ ClipToIntersection
Clip the geometry of these features to the region prior to rendering (i.e. feature boundaries will fo...
 
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
 
A model for display of map layers in widgets.
 
int rowCount(const QModelIndex &parent=QModelIndex()) const override
 
QList< QgsMapLayer * > layersChecked(Qt::CheckState checkState=Qt::Checked)
Returns the list of layers which are checked (or unchecked)
 
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
 
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
void setItemsCheckable(bool checkable)
Defines if layers should be selectable in the widget.
 
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 
void setLayersChecked(const QList< QgsMapLayer * > &layers)
Sets which layers are checked in the model.
 
@ LayerId
Stores the map layer ID.
 
A proxy model which provides an easy to use model to display the list of layers in widgets.
 
QgsMapLayerProxyModel * setFilters(Qgis::LayerFilters filters)
Sets filter flags which affect how layers are filtered within the model.
 
Base class for all map layer types.
 
QList< QgsMapLayer * > layers(bool expandGroupLayers=false) const
Returns the list of layers which will be rendered in the map.
 
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
 
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
 
void mapThemesChanged()
Emitted when map themes within the collection are changed.
 
QStringList mapThemeVisibleLayerIds(const QString &name) const
Returns the list of layer IDs that are visible for the specified map theme.
 
Interface for master layout type objects, such as print layouts and reports.
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
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.
 
A rectangle specified with double values.
 
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
 
A QgsRectangle with associated coordinate reference system.
 
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
 
static const QgsSettingsEntryStringList * settingsMapScales
 
Stores settings for use within QGIS.
 
Represents a vector layer which manages a vector based dataset.
 
Q_INVOKABLE Qgis::WkbType wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
 
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
 
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
 
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
 
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
 
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
 
const QgsCoordinateReferenceSystem & crs